From 1dfda155e521c2560a8033ea89e43b59b80c3363 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Mon, 20 Jan 2025 18:44:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 5 +-- pages_order/mine/promotion.vue | 69 ++++++++++++++++++++++++------------------ store/store.js | 4 +++ 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/manifest.json b/manifest.json index 99308e9..c282c72 100644 --- a/manifest.json +++ b/manifest.json @@ -58,14 +58,11 @@ }, "usingComponents" : true, "permission" : { - "scope.userLocation" : { - "desc" : "你的位置信息将用于小程序位置接口的效果展示" - }, "scope.userFuzzyLocation" : { "desc" : "你的位置信息将用于小程序位置接口的效果展示" } }, - "requiredPrivateInfos" : [ "chooseLocation", "getLocation" ] + "requiredPrivateInfos" : [ "chooseLocation" ] }, "mp-alipay" : { "usingComponents" : true diff --git a/pages_order/mine/promotion.vue b/pages_order/mine/promotion.vue index 67ddb6f..336e82c 100644 --- a/pages_order/mine/promotion.vue +++ b/pages_order/mine/promotion.vue @@ -53,7 +53,7 @@ export default { name: 'Promotion', computed: { - ...mapState(['userInfo']), + ...mapState(['userInfo', 'promotionUrl']), }, data() { return { @@ -65,6 +65,7 @@ show : false, bgColor : '#fe6c17', load : false, + index : 0, } }, onShow() { @@ -86,7 +87,9 @@ clickTab(){ this.bgColor = '#de0917' this.show = true - if(this.load){ + if(this.promotionUrl){ + this.imagePath = this.promotionUrl + }else if(this.load){ uni.showLoading({ title: "拼命绘画中..." }) @@ -134,13 +137,25 @@ const bgImage = canvas.createImage() bgImage.src = this.configList.qr_image + const coderImage = canvas.createImage() + coderImage.src = this.baseUrl + this.url + bgImage.onload = () => { canvas.width = bgImage.width canvas.height = bgImage.height ctx.drawImage(bgImage, - 0, 0, bgImage.width, bgImage.height) + 0, 0, bgImage.width, bgImage.height) + + + //二维码图片 + coderImage.onload = () => { + + ctx.drawImage(coderImage, + canvas.width / 2 - 175, canvas.height / 2 - 100, 350, 350) + this.canvasToTempFilePath() + } } //用户图片 @@ -163,36 +178,30 @@ let s = this.title || '' // ctx.fillText(s, canvas.width / Ratio - s.length * 11, 50); - //二维码图片 - const coderImage = canvas.createImage() - coderImage.src = this.baseUrl + this.url - coderImage.onload = () => { - ctx.drawImage(coderImage, - canvas.width / 2 - 175, canvas.height / 2 - 100, 350, 350) - } - - - // 绘制完成后存储路径 - - setTimeout(() => { - wx.canvasToTempFilePath({ - x: 0, - y: 0, - width: this.canvas.width, - height: this.canvas.height, - canvas, - success: (res) => { - var tempFilePath = res.tempFilePath; - this.imagePath = tempFilePath - uni.hideLoading() - this.load = false - } - }); - }, 600); - }) }, + canvasToTempFilePath(){ + // 绘制完成后存储路径 + setTimeout(() => { + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: this.canvas.width, + height: this.canvas.height, + canvas : this.canvas, + success: (res) => { + var tempFilePath = res.tempFilePath; + this.imagePath = tempFilePath + + this.$store.commit('setPromotionUrl', res.tempFilePath) + + uni.hideLoading() + this.load = false + } + }); + }, 200); + }, back() { uni.navigateBack(-1) }, diff --git a/store/store.js b/store/store.js index dfeb953..504c76f 100644 --- a/store/store.js +++ b/store/store.js @@ -13,6 +13,7 @@ const store = new Vuex.Store({ riceInfo : {},//用户相关信息 category : [],//分类信息 payOrderProduct : [],//支付订单中的商品 + promotionUrl : '',//分享二维码 }, getters: { }, @@ -143,6 +144,9 @@ const store = new Vuex.Store({ setPayOrderProduct(state, data){ state.payOrderProduct = data }, + setPromotionUrl(state, data){ + state.promotionUrl = data + }, }, actions: {}, })