个人案例
- 布谷词场
德语背单词小程序。
布谷词场扫码体验
- onShareAppMessage接口,imageUrl字段为本地文件路径BUG
onShareAppMessage接口自定义转发内容中,设置imageUrl字段为本地文件路径(此文件是从网络上获取)时,在开发者工具上不显示该图片,在真机上是可以显示的。 代码片段点击此处 [图片] 开发者工具不显示 [图片] 真机显示
2018-08-24 - canvas导出的图片有部分没了
[代码]wx.getImageInfo({[代码][代码] [代码][代码]src: [代码][代码]"https://dewordapi.tongjideyu.com/share.png"[代码][代码],[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]this[代码][代码].backgroundImagePath = res.path;[代码][代码] [代码][代码]const ctx = wx.createCanvasContext([代码][代码]"myCanvas"[代码][代码]);[代码][代码] [代码][代码]let info = wx.getSystemInfoSync();[代码][代码] [代码][代码]console.log(info)[代码][代码] [代码][代码]ctx.drawImage(res.path, 0, 0, 750, 1206);[代码][代码] [代码][代码]ctx.setGlobalAlpha(1);[代码][代码] [代码][代码]ctx.setFontSize(95);[代码][代码] [代码][代码]ctx.setFillStyle([代码][代码]"#AD89FF"[代码][代码]);[代码][代码] [代码][代码]ctx.setTextAlign([代码][代码]"left"[代码][代码]);[代码][代码] [代码][代码]ctx.fillText([代码][代码]"100"[代码][代码], 297, 195);[代码][代码] [代码][代码]ctx.setFontSize(45);[代码][代码] [代码][代码]ctx.setTextAlign([代码][代码]"center"[代码][代码]);[代码][代码] [代码][代码]ctx.fillText([代码][代码]"122"[代码][代码], 200, 423, 81);[代码][代码] [代码][代码]ctx.setFillStyle([代码][代码]"#AD89FF"[代码][代码]);[代码][代码] [代码][代码]ctx.setTextAlign([代码][代码]"center"[代码][代码]);[代码][代码] [代码][代码]ctx.setFontSize(45);[代码][代码] [代码][代码]ctx.fillText([代码][代码]"99"[代码][代码], 587, 423, 144);[代码][代码] [代码][代码]ctx.setFontSize(28);[代码][代码] [代码][代码]ctx.setFillStyle([代码][代码]"white"[代码][代码]);[代码][代码] [代码][代码]let text =[代码][代码] [代码][代码]"Zollbeamtin,Flughafen,Chinese,Koffer,Moment,sprechen,Geschwister,chinesisch,Maschinenbau,wen(A),wen(A),Gemüse,Samstag,Rindfleisch,Augenblick,Lebensmittel"[代码][代码];[代码][代码] [代码][代码]let metrics = ctx.measureText(text);[代码][代码] [代码][代码]// ctx.fillText("Zollbeamtin", 100, 295.5);[代码][代码] [代码][代码]ctx.setTextAlign([代码][代码]"left"[代码][代码]);[代码][代码] [代码][代码]var[代码] [代码]startX = 104;[代码][代码] [代码][代码]var[代码] [代码]startY = 567;[代码][代码] [代码][代码]var[代码] [代码]lineWidth = 0;[代码][代码] [代码][代码]var[代码] [代码]lastSubStrIndex = 0;[代码][代码] [代码][代码]var[代码] [代码]linecount = 1[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i = 0; i < text.length; i++) {[代码][代码] [代码][代码]lineWidth += ctx.measureText(text[i]).width;[代码][代码] [代码][代码]if[代码] [代码](lineWidth > 571) {[代码][代码] [代码][代码]ctx.fillText(text.substring(lastSubStrIndex, i), startX, startY);[代码][代码] [代码][代码]lineWidth = 0;[代码][代码] [代码][代码]lastSubStrIndex = i;[代码][代码] [代码][代码]startY += 70;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]console.log([代码][代码]'start to draw..'[代码][代码])[代码][代码] [代码][代码]var[代码] [代码]pointer = [代码][代码]this[代码][代码] [代码][代码]ctx.draw([代码][代码]true[代码][代码], [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]'done...'[代码][代码])[代码][代码] [代码][代码]wx.canvasToTempFilePath({[代码][代码] [代码][代码]canvasId: [代码][代码]'myCanvas'[代码][代码],[代码][代码] [代码][代码]width: 750,[代码][代码] [代码][代码]height: 1206,[代码][代码] [代码][代码]destWidth: 750,[代码][代码] [代码][代码]destHeight: 1206,[代码][代码] [代码][代码]success: (res) => {[代码][代码] [代码][代码]let tempPath = res.tempFilePath[代码][代码] [代码][代码]pointer.imgSrc = tempPath[代码][代码] [代码][代码]wx.saveImageToPhotosAlbum({[代码][代码] [代码][代码]filePath: tempPath,[代码][代码] [代码][代码]success: (res) => {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]pointer.showMask = [代码][代码]true[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: (err) => {[代码][代码] [代码][代码]console.log(err)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码]在canvas上画图,然后导出到相册,但是导出到相册的时候有一部分没了。 在iPhone 5上会出现这个问题,iPhone 6以及其它页面不会。 [图片] [图片]
2018-08-23