你在绘制成功之后再执行弹窗不行么?就一个回调函数的事。等待期间先show个等待toast
小程序转发点击转发后选择转发好友,能不能把发送弹窗延迟弹出
2018-08-29我也是,经过我的测试发现,好像跟canvas这个控件的width和height有关,比如你设置了50px * 50px的canvas,无论图在里面铺多大(比如100*100),你只能截在canvas里能看见的那50*50的那部分,由于我们大多是从坐标(0,0)开始铺,所以一般只能截到左上角的一部分图
canvas处理图片上传保存图片流只显示一半- 当前 Bug 的表现(可附上截图) [图片] - 预期表现 - 复现路径 - 提供一个最简复现 Demo js代码 wx.chooseImage({ count: 1, // 默认9 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: itemIndex == 0 ? ['album'] : ['camera'], success: (res) => { console.log(res.tempFilePaths) const item = new IMOperator(this).createNormalChatItem({ type: 'image', content: res.tempFilePaths, isMy: true, }); that.data.chatItems.push(item); that.setData({ chatItems: that.data.chatItems, scrollTopVal: that.data.scrollTopVal + 999, }); // 图片加水印功能 // var arr = that.data.fileList // res.tempFilePaths.forEach(function(item) { // arr.push(item) // }) // that.setData({ // fileList: arr // }) //获取图片详细信息 wx.getImageInfo({ src: res.tempFilePaths[0], success: (ress) => { console.log(ress) let date = new Date(); let time = that.formartDate(date); let ctx = wx.createCanvasContext('firstCanvas'); that.setData({ canvasHeight: ress.height, canvasWidth: ress.width }) //将图片src放到cancas内,宽高为图片大小 ctx.drawImage(res.tempFilePaths[0], 0, 0, ress.width, ress.height) //将声明的时间放入canvas ctx.setFontSize(20) //注意:设置文字大小必须放在填充文字之前,否则不生效 ctx.setFillStyle('blue') // ctx.setGlobalAlpha(0.5) ctx.fillText('15200000001', that.data.canvasWidth - 400, that.data.canvasHeight - 150) ctx.fillText(time, that.data.canvasWidth - 500, that.data.canvasHeight - 100) ctx.draw(false, function() { wx.canvasToTempFilePath({ canvasId: 'firstCanvas', success: (res) => { that.setData({ canvesimgurl:res.tempFilePath }) }, fail: (e) => { console.log(e) } }) }) wx.uploadFile({ url: '、、、', filePath: that.data.canvesimgurl, name: 'file', formData: {}, header: { "Content-Type": "multipart/form-data" }, success: function (res) { console.log(res) var url = res.data.url; var data = res.data.fileId; var imgtype = "image"; if (res.statusCode == 200) { that.sendmessage(data, url, imgtype) } else { let index = parseInt(that.data.chatItems.length - 1); that.updateViewWhenSendFailed(index) } console.log(res.data) }, fail: function (res) { console.log(res) }, complete: function (res) { console.log(res) } }) } }) } }); });
2018-08-29