- APIwx.getImageInfo在苹果16手机下会报-202证据链有缺失?安卓正常
uni.getImageInfo({ src: imagePath, success: (res) => { ctx.drawImage(res.path, 0, 0, 270, 231); // 绘制第一张图片背景 drawLogos(ctx); // 调用函数绘制logo }, fail: (err) => { console.error('获取图片信息失败', err); uni.showToast({ title: '图片加载失败', icon: 'none' }); } });
10-18 - 链接转化二维码,用画布画上去后,部分机型不显示?
async paintedCake() { wx.createSelectorQuery() .select('#myCanvas') .fields({ node: true, size: true }) .exec(res => { let myData = this.data.myData; const canvas = res[0].node; const ctx = canvas.getContext('2d'); const dpr = wx.getSystemInfoSync().pixelRatio; const screenWidthRpx = wx.getSystemInfoSync().screenWidth / 375; canvas.width = wx.getSystemInfoSync().screenWidth * dpr * 1.8 * screenWidthRpx; canvas.height = res[0].height * dpr * 2; ctx.scale(dpr, dpr); ctx.font = '28px Arial'; ctx.fillStyle = '#7B481E'; let str = myData.name.slice(0, 10) const text = `${str}...`; const texts = `用户id:${myData.id}`; const image = canvas.createImage(); const image1 = canvas.createImage(); const image2 = canvas.createImage(); image.onload = () => { ctx.drawImage(image, 0, 0, 686 * screenWidthRpx, 1022 * screenWidthRpx); //乘以比例来自适应 const textWidth = ctx.measureText(text).width; const textWidths = ctx.measureText(texts).width; ctx.fillText(text, ((700 * screenWidthRpx - textWidth) / 2), 460 * screenWidthRpx); //计算字的位置 ctx.fillText(texts, ((700 * screenWidthRpx - textWidths) / 2), 500 * screenWidthRpx); image1.src = `${this.data.head}` }; image1.onload = () => { ctx.drawImage(image1, 292 * screenWidthRpx, 290 * screenWidthRpx, 370 * screenWidthRpx, 200 * screenWidthRpx); wxbarcode.qrcode('qrcode', this.data.InvitationCode, 364, 284); wx.canvasToTempFilePath({ canvasId: 'qrcode', success: (res) => { this.setData({ qrcodeTempFilePath: res.tempFilePath }) console.log('res.tempFilePath', res.tempFilePath); image2.src = `${this.data.qrcodeTempFilePath}`; }, fail: (err) => { console.log('errsss', err); } }, 0); }; image2.onload = () => { console.log('qwe'); ctx.drawImage(image2, ((700 - 305) / 2) * screenWidthRpx, 530* screenWidthRpx, 650 * screenWidthRpx, 300 * screenWidthRpx); wx.canvasToTempFilePath({ canvas, success: res => { const tempFilePath = res.tempFilePath; this.setData({ image: tempFilePath }); }, fail: err => { console.error('err:', err); } }); }; image.src = 'https://channels-network.oss-cn-qingdao.aliyuncs.com/images/profile/invitefriends.png'; }); },
07-11