- canvas 获取轮播图图片的颜色,开发者工具展示无问题,手机预览功能无效,求大佬看看啥问题?
// 获取的颜色 onColor(event) { //canvas2d return new Promise((resolve, reject) => { var query = wx.createSelectorQuery(); var dpr = getApp().globalData.dpr; query.select('#canvas-img').fields({ node: true, size: true }).exec((res) => { //可能报错 if (res[0] == null || res[0].node == null) { return; }; var canvas = res[0].node; var ctx = canvas.getContext('2d'); canvas.width = res[0].width * dpr; canvas.height = res[0].height * dpr; var img = canvas.createImage(); wx.downloadFile({ url: event.url, success: ((x) => { img.src = x.tempFilePath; img.onload = (e) => { ctx.drawImage(img, 20, 20, 343, 150); var imageData = ctx.getImageData(21, 25, 343, 150).data; var color = []; for (var i = 0; i < 2; i++) { var R = imageData[i == 0 ? 100 : 2800]; var G = imageData[i == 0 ? 101 : 2801]; var B = imageData[i == 0 ? 102 : 2802]; color.push("rgba(" + R + "," + G + "," + B + ")"); }; var color = [color[0], color[color.length - 1]]; resolve({ 'color': color, 'i': event.i }); }; }), fail: ((err) => {}) }); }); }); }, //处理函数 getHomeSwipe() { var that = this $fn.post('getHomeSwipe').then(res => { var arry = res.data.data; arry.bannerList.map((item,index)=>{ console.log(index,item) that.onColor({ 'url': item.photoUrl, 'i': index }).then((res) => { console.log(1111) arry.bannerList[res.i].color = res.color this.setData({ ['swipe[' + res.i + '].color']: res.color }) }) }) that.setData({ swipe: arry.bannerList, }); }) } //swipe数组 bannerlist swipe:[ {"id":"10", "bannerName":"福袋", "weight":8, "photoUrl":"http://qiniuoss.vipcaihui.cn/1615198935408984944646", "redirectUrl":"", "remark":"", "type":1, "publishStatus":1, "delStatus":0, "createTime":"2020-12-08 02:02:35" }, {"id":"11", "bannerName":"福袋新年", "weight":0, "photoUrl":"http://qiniuoss.vipcaihui.cn/1611973057757306578063", "redirectUrl":"", "remark":"", "type":1, "publishStatus":1, "delStatus":0, "createTime":"2021-01-30 10:18:03"}] 麻烦大佬看看😂😂😂,是啥问题导致的
2021-03-12 - wx.canvasToTempFilePath 在选择原图的情况下导出图片倾斜变形?
[图片]导出后正常的图片就变形了 var canvas = res[0].node; var ctx = canvas.getContext('2d'); var width = this.data.xRight - this.data.xLeft; var height = this.data.yBottom - this.data.yTop; wx.canvasToTempFilePath({ x: this.data.xLeft + this.data.maxLeft, y: this.data.yTop + this.data.maxTop, width: width, height: height, destWidth: width * 4, destHeight: height * 4, canvas: canvas, success: ((res => { var obj = { 'url': res.tempFilePath }; if (isSave) { this.triggerEvent('run', obj); this.setData({ show: false }) } else { wx.previewImage({ url: res.tempFilePath, urls: [res.tempFilePath], }) } wx.hideLoading() })) })
2020-08-31 - canvas 渲染大转盘的小圆点设置context.arc的y轴属性无法生效?
for (var i = 0; i < 32; i++) { context.beginPath() context.setFillStyle(i % 2 == 0 ? "#ffffff" : "#FFF7AF") context.arc(r+20, -50, 4, 0, 2 * Math.PI) context.rotate((360 / 32) * Math.PI / 180); context.fill() } r 是转盘半径加大的 -50这个值设置y轴不生效,请问是什么导致的
2020-06-30 - wx.chooseimage 触发了onshow 事件导致页面刷新?
加载数据在onload里,但是在上传图片后导致页面onshow执行,导致页面数据被刷新掉了,有处理的方案吗?
2020-06-19 - 小程序转发的那个小logo可以不显示为小程序的logo吗?
[图片]需求是需要把这个小程序logo更换另一个logo
2020-06-16 - tabbar 进入分包页面报错,请问怎么处理?
在两台电脑上,一个可以通过设置编译模式打开,另一个无法设置打开 [图片][图片][图片] [图片]
2020-06-01