From ac09a2a8d44f5e471b8768d489892cf30f3f8f0b Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Sat, 17 Jul 2021 14:11:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=B7=E6=8A=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goodsDetail/index.vue | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/pages/goodsDetail/index.vue b/pages/goodsDetail/index.vue index 1cad73e..d8350da 100644 --- a/pages/goodsDetail/index.vue +++ b/pages/goodsDetail/index.vue @@ -172,6 +172,7 @@ wx.getImageInfo({ src: img, success: function(sres) { + uni.showLoading({title:'生成海报中...'}) _this.backgroundImg = sres.path; _this.isShowButtonCount++; resolve(); // 成功回调 @@ -224,6 +225,9 @@ }, getWxCode() { let that = this; + uni.showLoading({ + title: '生成海报中...' + }) return new Promise((resolve, reject) => { const token = that.$shared.createToken({ user_id: that.userInfo.id, @@ -256,6 +260,9 @@ var imgSrc = this.wxCode; //base64编码 var save = wx.getFileSystemManager(); var number = Math.random(); + uni.showLoading({ + title: '生成海报中...' + }) save.writeFile({ filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.jpg', data: imgSrc, @@ -325,7 +332,6 @@ context.draw(); //将生成好的图片保存到本地,需要延迟一会,绘制期间耗时 setTimeout(function() { - uni.hideLoading(); // 关闭loading wx.canvasToTempFilePath({ canvasId: 'mycanvas', success: function(res) { @@ -334,7 +340,7 @@ that.canvasHidden = true that.maskHidden = true } - wx.hideToast() + uni.hideLoading() console.log('海报生成成功') console.log(res) console.log('图片链接', that.imagePath) @@ -370,16 +376,19 @@ }, formSubmit() { var that = this; - wx.showToast({ - title: '生成海报中...', - icon: 'loading', - duration: 100000 - }); - Promise.all([that.getWxCode(), that.getBackground()]).then(res => { - that.createNewImg(); - }).catch(err => { - this.$msg('生成失败,请稍后重试!'); + uni.showLoading({ + title: '生成海报中...' }) + if(that.backgroundImg && that.onceCode){ + that.createNewImg(); + }else { + Promise.all([that.getWxCode(), that.getBackground()]).then(res => { + that.createNewImg(); + }).catch(err => { + this.$msg('生成失败,请稍后重试!'); + }) + } + }, //海报结束 getGoodsDetail() {