- 关于微信小程序 canvas 2d 的问题,下面这段码,苹果系统可,安卓不行,谁知道问题所在?
onClickConfirm() { const { dpr, imageSrc, x, y, initialScale, scale, clipWidth, clipHeight, } = this.data const totalScale = scale * initialScale const sx = -x / totalScale const sy = -y / totalScale const canvasWidth = clipWidth / totalScale const canvasHeight = clipHeight / totalScale this.setData({ canvasWidth, canvasHeight }) const query = wx.createSelectorQuery() query .select('.canvas') .fields({ node: true, size: true }) .exec((res) => { const canvas = res[0].node const context = canvas.getContext('2d') canvas.width = res[0].width * dpr canvas.height = res[0].height * dpr context.scale(dpr, dpr) const canvasImg = canvas.createImage() canvasImg.src = imageSrc canvasImg.onload = () => { context.drawImage( canvasImg, sx, sy, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight ) wx.canvasToTempFilePath({ fileType: 'jpg', canvas, success: (res) => { // TODO: 这里在实际项目中应该是调用 wx.uploadFile 来上传采集后图片 const app = getApp() app.globalData.avatar = res.tempFilePath var pages = getCurrentPages(); // 获取页面栈 var currPage = pages[pages.length - 1]; // 当前页面 var prevPage = pages[pages.length - 2]; // 上一个页面 var index3=this.data.index3; prevPage.data.fielddata[index3].img_arr=prevPage.data.fielddata[index3].img_arr.concat(res.tempFilePath) prevPage.setData({ fielddata:prevPage.data.fielddata// 假数据 }) wx.navigateBack() }, })} // }) }) },
2021-11-28 - 微信扫码支付后 能否通小程序得到收款方的名称,目的是做个记账功能,谢谢!
小程序调取微信扫码支付,返回收款商户名称、金额,或者扫码支付后,带信息调 起微信小程序,目的是做个记账功能,谢谢!
2021-02-19