- 小程序正式版无法保存图片,但是测试版可以?
用户隐私已经更新了,然后代码审核的时候也勾选了采集用户隐私,但是扫码进入小程序后还是无法保存图片,我的小程序也只有一个保存图片的功能[图片]
02-23 - 测试版保存图片到本地没问题,但是正式版不行?
[图片]就是一个表情包制作,然后保存,真机调试没有问题可以保存,但是审核后就不能保存了这是为啥啊
02-22 - 电脑上能进行保存操作,但是真机调试无法保存
downloadImages: function (path, context, p) { const that = this; const ob = path.split('Url')[0]; return new Promise((resolve, reject) => { wx.downloadFile({ url: String(this.data[path]), success(res) { context.drawImage(res.tempFilePath, that.data[ob].x, that.data[ob].y, p, p); context.draw(true, () => { resolve(); // 成功时 resolve }); }, fail(error) { console.log(error); reject(error); // 失败时 reject } }); }); }, saveImage: function () { this.getCanvas().then(async () => { const context = wx.createCanvasContext('myCanvas'); context.width = this.data.canvasWidth; context.height = this.data.canvasHeight; context.setFillStyle('white'); context.fillRect(0, 0, 600, 700); async function getSystemInfoAsync(context) { return new Promise((resolve, reject) => { wx.getSystemInfo({ success: (res) => { var rpx = 150; var px = rpx * (res.windowWidth / 750); context.setData({ imgSize: px, }); resolve(); }, fail: (error) => { reject(error); } }); }); } await getSystemInfoAsync(this); const p = this.data.imgSize const that = this; console.log("sss"); // 绘制图片 if (this.data.faceUrl) { await this.downloadImages('faceUrl', context, p); } if (this.data.eyeUrl) { await this.downloadImages('eyeUrl', context, p); } if (this.data.eyebrowUrl) { await this.downloadImages('eyebrowUrl', context, p); } if (this.data.mouthUrl) { await this.downloadImages('mouthUrl', context, p); } if (this.data.gestureUrl) { await this.downloadImages('gestureUrl', context, p); } if (this.data.footUrl) { await this.downloadImages('footUrl', context, p); } if (this.data.decorateUrl) { await this.downloadImages('decorateUrl', context, p); } console.log("aaa"); context.draw(true, function () { // 将Canvas内容保存为本地文件 console.log("bbb") wx.canvasToTempFilePath({ canvasId: 'myCanvas', success: function (res) { // 保存到相册 wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: function () { wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 }); }, fail: function (error) { console.error('保存失败', error); } }); // 清空 Canvas context.clearRect(0, 0, that.data.canvasWidth, that.data.canvasHeight); context.draw(); // 重新绘制空画布 }, fail: function (error) { console.error('canvasToTempFilePath 失败', error); } }); }); }) },
02-20