- wx.canvasToTempFilePath安卓手机无法生成图片
wx.canvasToTempFilePath安卓手机无法生成图片,执行fail返回create bitmap failed,ios测试和开发者工具没有问题,什么时候可以修复
2018-02-09 - wx.canvasToTempFilePath
[代码]eventGetImage(event) {[代码][代码] [代码][代码]console.log(event);[代码][代码] [代码][代码]const _that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]if[代码] [代码](event.detail.errMsg == [代码][代码]'canvasdrawer:ok'[代码][代码]){[代码][代码] [代码][代码]if[代码] [代码]([代码][代码]this[代码][代码].data.result.flowPriceUnit < 0 || [代码][代码]this[代码][代码].data.result.flowPriceUnit > 100){[代码][代码] [代码][代码]console.log([代码][代码]'haohaoaoh'[代码][代码])[代码][代码] [代码][代码]//这个地方就也不执行了[代码][代码] [代码][代码]wx.canvasToTempFilePath({[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]width: 345,[代码][代码] [代码][代码]height: 520,[代码][代码] [代码][代码]canvasId: [代码][代码]'canvasdrawer'[代码][代码],[代码][代码] [代码][代码]success(resFilePath) {[代码][代码] [代码][代码]console.log(resFilePath);[代码][代码] [代码][代码]wx.saveImageToPhotosAlbum({[代码][代码] [代码][代码]filePath: resFilePath.tempFilePath,[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]wx.hideLoading()[代码][代码] [代码][代码]console.log([代码][代码]'绘图成功'[代码][代码])[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'保存图片成功'[代码][代码],[代码][代码] [代码][代码]icon: [代码][代码]'success'[代码][代码],[代码][代码] [代码][代码]duration: 2000[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}, _that.canvasdrawerComponent);[代码][代码] [代码][代码]return[代码][代码] [代码][代码]}[代码][代码] [代码][代码]console.log([代码][代码]'单价在0至100之间'[代码][代码])[代码][代码] [代码][代码]wx.canvasGetImageData({[代码][代码] [代码][代码]canvasId: [代码][代码]'mychart-line'[代码][代码],[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]width: 304,[代码][代码] [代码][代码]height: 122,[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]wx.canvasPutImageData({[代码][代码] [代码][代码]canvasId: [代码][代码]'canvasdrawer'[代码][代码],[代码][代码] [代码][代码]data: res.data,[代码][代码] [代码][代码]x: 20,[代码][代码] [代码][代码]y: 285,[代码][代码] [代码][代码]width: 304,[代码][代码] [代码][代码]height: 122,[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log(res);[代码][代码] [代码][代码]console.log([代码][代码]'绘画完成'[代码][代码])[代码][代码] [代码][代码]console.log([代码][代码]'开始保存'[代码][代码])[代码][代码] [代码][代码]//这个地方就不在执行了[代码][代码] [代码][代码]wx.canvasToTempFilePath({[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]width: 345,[代码][代码] [代码][代码]height: 520,[代码][代码] [代码][代码]canvasId: [代码][代码]'canvasdrawer'[代码][代码],[代码][代码] [代码][代码]success(resFilePath) {[代码][代码] [代码][代码]console.log(resFilePath);[代码][代码] [代码][代码]wx.saveImageToPhotosAlbum({[代码][代码] [代码][代码]filePath: resFilePath.tempFilePath,[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]wx.hideLoading()[代码][代码] [代码][代码]console.log([代码][代码]'绘图成功'[代码][代码])[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'保存图片成功'[代码][代码],[代码][代码] [代码][代码]icon: [代码][代码]'success'[代码][代码],[代码][代码] [代码][代码]duration: 2000[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}, _that.canvasdrawerComponent)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}, _that.canvasdrawerComponent)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}, _that.echartsComponnet)[代码][代码] [代码][代码]}[代码][代码]},[代码]每次走到[代码] [代码][代码]wx.canvasToTempFilePath函数就不再执行了,也不知道为什么,不报错[代码]
2018-07-31 - canvasToTempFilePath 安卓无法执行 iOS正常
家中两部安卓 一部魅蓝note5 一部小米MIX2 版本都是微信版本 6.6.7 2.2.1 在canvasPutImageData的 success回调中执行draw 后无法再次执行canvasToTempFilePath 但是IOS上的基础库版本2.1.3 微信版本6.6.7 相同的代码却正常执行 [代码]let windowSize = [代码][代码]this[代码][代码].windowSize[代码][代码] [代码][代码]let bookmark = [代码][代码]this[代码][代码].bookmark[代码][代码] [代码][代码]let mainCtx = [代码][代码]this[代码][代码].mainCtx[代码][代码] [代码][代码]let $store = [代码][代码]this[代码][代码].$store[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码] [代码][代码]wx.canvasGetImageData({[代码][代码] [代码][代码]canvasId: [代码][代码]'canvas'[代码][代码],[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: ((windowSize.windowHeight * 0.9) - bookmark.backgroundImage.style.height) / 2,[代码][代码] [代码][代码]width: windowSize.windowWidth,[代码][代码] [代码][代码]height: bookmark.backgroundImage.style.height,[代码][代码] [代码][代码]success (res) {[代码][代码] [代码][代码]let d = res.data[代码][代码] [代码][代码]let filterData = filters[type](d, {[代码][代码] [代码][代码]height: bookmark.backgroundImage.style.height,[代码][代码] [代码][代码]width: bookmark.backgroundImage.style.width[代码][代码] [代码][代码]})[代码][代码] [代码][代码]wx.canvasPutImageData({[代码][代码] [代码][代码]canvasId: [代码][代码]'canvas'[代码][代码],[代码][代码] [代码][代码]data: filterData,[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: ((windowSize.windowHeight * 0.9) - bookmark.backgroundImage.style.height) / 2,[代码][代码] [代码][代码]width: windowSize.windowWidth,[代码][代码] [代码][代码]height: bookmark.backgroundImage.style.height,[代码][代码] [代码][代码]success: (res) => {[代码] [代码][代码] // 安卓上执行到这一步没反应 打印mainCtx也有对象 iOS正常 [代码] [代码][代码]mainCtx.draw([代码][代码]true[代码][代码], () => {[代码][代码] [代码][代码]console.log(wx)[代码][代码] [代码][代码]wx.canvasToTempFilePath({[代码][代码] [代码][代码]canvasId: [代码][代码]'canvas'[代码][代码],[代码][代码] [代码][代码]height: windowSize.windowHeight * 0.9,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]success: (e) => {[代码][代码] [代码][代码]console.log(e)[代码][代码] [代码][代码]$store.dispatch([代码][代码]'SET_BACKGROUND_IMAGE'[代码][代码], e.tempFilePath)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: (e) => {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: (e) => {[代码][代码] [代码][代码]console.log([代码][代码]'complete'[代码][代码])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}, that)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码] 我提交到体验版了 不知管理员能不能直接打开体验版查一下问题
2018-07-27