From b9c043c24969cbdb896e2434a222ff950a33599f Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Tue, 6 Jul 2021 14:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=9C=9F=E6=B5=B7=E6=8A=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/bill/bill.vue | 79 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 15 deletions(-) diff --git a/pages/bill/bill.vue b/pages/bill/bill.vue index a1f06fc..74b6487 100644 --- a/pages/bill/bill.vue +++ b/pages/bill/bill.vue @@ -1,17 +1,21 @@ @@ -24,7 +28,7 @@ }, data() { return { - base64Img: '', // + base64Img: '', // checkArea: '0', @@ -35,7 +39,16 @@ inputValue: "", maskHidden: false, name: "kk", - code: "E7A93C" + code: "E7A93C", + + info: { + avatar: '', + nickname: '', + id: '', + tel: '', + tags: [] + }, + showLogin: true } }, methods: { @@ -44,18 +57,47 @@ }, + verifyUserInfo() { + let userInfo = uni.getStorageSync('userinfo') || {}; + if (!userInfo.id || !userInfo.nickname || !userInfo.avatar) { + if (this.showLogin) { + this.showLogin = false; + this.$url('/pages/login/index?type=userinfo'); + } else { + this.showLogin = true; + this.$url('/pages/index/index', { + type: 'switch' + }); + } + } + }, + getData() { + let userinfo = uni.getStorageSync('userinfo') || {}; + if(userinfo) { + this.info = userinfo + }else { + this.$http(this.API.API_USER_CENTER).then(res => { + this.info = res.data; + console.log(this.info) + }) + } + + + }, + + createNewImg() { var that = this; var context = wx.createCanvasContext('mycanvas'); context.setFillStyle("#ffe200") context.fillRect(0, 0, 375, 667) var path = "../../static/images/empty.png"; - //将模板图片绘制到canvas,在开发工具中drawImage()函数有问题,不显示图片 - //不知道是什么原因,手机环境能正常显示 context.drawImage(path, 0, 0, 375, 183); - var path1 = that.touxiang; + + that.info.avatar = "../../static/images/system/payfail.png" + var path1 = that.info.avatar; console.log(path1, "path1") - //将模板图片绘制到canvas,在开发工具中drawImage()函数有问题,不显示图片 + //定义图片 var path2 = "../../static/images/system/payfail.png"; var path3 = "../../static/images/system/paysuccess.png"; var path4 = "../../static/images/system/paysuccess.png"; @@ -64,7 +106,7 @@ //不知道是什么原因,手机环境能正常显示 // context.save(); // 保存当前context的状态 - var name = that.name; + var name = that.info.nickname; //绘制名字 context.setFontSize(24); context.setFillStyle('#333333'); @@ -118,8 +160,9 @@ var tempFilePath = res.tempFilePath; that.imagePath = tempFilePath that.canvasHidden = true - console.log('成功') + console.log('海报生成成功') console.log(res) + console.log(that.imagePath) }, fail: function(res) { console.log(res); @@ -140,10 +183,11 @@ success: function(res) { if (res.confirm) { console.log('用户点击确定'); + that.maskHidden = false } }, fail: function(res) { - console.log(11111) + that.maskHidden = false } }) } @@ -152,18 +196,23 @@ formSubmit() { var that = this; wx.showToast({ - title: '装逼中...', + title: '生成海报中...', icon: 'loading', duration: 1000 }); setTimeout(function() { wx.hideToast() that.createNewImg(); + + that.maskHidden = true }, 1000) } }, onLoad(options) { this.qrcode = 'dadaa' + + this.verifyUserInfo(); + this.getData(); } }