From 31c341148f845ec31265fbdaa1c6665e7d0cbae1 Mon Sep 17 00:00:00 2001 From: RyanRan <1410277647@qq.com> Date: Tue, 2 Jul 2024 11:58:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=201:=E4=BF=AE=E6=94=B9=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E8=AE=A2=E9=98=85=EF=BC=8C=E6=9B=B4=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E6=94=AF=E4=BB=98=E6=88=90=E5=8A=9F=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E8=AF=B7=E6=B1=82=E8=AE=A2=E9=98=85=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E3=80=822:=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=9C=A8=E7=9C=9F=E6=9C=BA=E4=B8=AD=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 26 ++--- js_sdk/lili-pay/wx-pay.js | 80 +++++++-------- pages/cart/payment/success.vue | 16 ++- pages/order/fillorder.vue | 34 +++++-- utils/request.js | 180 ++++++++++++++++----------------- 5 files changed, 164 insertions(+), 172 deletions(-) diff --git a/App.vue b/App.vue index f8f76ae..6318898 100644 --- a/App.vue +++ b/App.vue @@ -2,15 +2,15 @@ /** * vuex管理登录状态,具体可以参考官方登录模板示例 */ - import { - mapMutations - } from "vuex"; - import APPUpdate from "@/plugins/APPUpdate"; - import { - getClipboardData - } from "@/js_sdk/h5-copy/h5-copy.js"; import config from "@/config/config"; - import storage from "@/utils/storage"; +import { + getClipboardData +} from "@/js_sdk/h5-copy/h5-copy.js"; +import APPUpdate from "@/plugins/APPUpdate"; +import storage from "@/utils/storage"; +import { + mapMutations +} from "vuex"; @@ -20,14 +20,7 @@ * */ // #ifdef MP-WEIXIN wx.onAppRoute((res) => { - const pages = getCurrentPages(); - console.log("pages:" + pages.length,pages); - if (pages.length > 3) { - delete getCurrentPages()[2] - } - console.log('路由监听', { - res - }) + }) // #endif @@ -43,6 +36,7 @@ * 监听返回 */ onBackPress(e) { + console.log("onBackPress-APP", e); if (e.from == "backbutton") { let routes = getCurrentPages(); let curRoute = routes[routes.length - 1].options; diff --git a/js_sdk/lili-pay/wx-pay.js b/js_sdk/lili-pay/wx-pay.js index 5d292d1..14991cd 100644 --- a/js_sdk/lili-pay/wx-pay.js +++ b/js_sdk/lili-pay/wx-pay.js @@ -7,8 +7,8 @@ * @param {sn,price} */ -import { initiatePay } from "@/api/trade"; import { getWeChatMpMessage } from "@/api/message.js"; +import { initiatePay } from "@/api/trade"; class LiLiWXPay { constructor(...payList) { this.data = payList[0]; @@ -65,52 +65,40 @@ class LiLiWXPay { } function sendMessage(price) { - //判断用户是否已经进行了订阅 - if (!uni.getStorageSync("acceptSubscribeMessage")) { - //订阅消息 - getWeChatMpMessage().then((res) => { - var message = res.data.result; - var templateid = message.map((item) => item.code); - uni.requestSubscribeMessage({ - tmplIds: templateid, - success: (res) => { - for (let key in res) { - // 表示用户拒绝订阅该信息 - if (res[key] == "reject") { - this.checked = false; - } else { - uni.setStorageSync("acceptSubscribeMessage", res); - } - } - }, - fail: (res) => { - uni.removeStorageSync("acceptSubscribeMessage"); - this.checked = false; - }, - complete: () => { - /** - * 已经支付成功 - */ - uni.redirectTo({ - url: - "/pages/cart/payment/success?paymentMethod=WECHAT" + - "&payPrice=" + - price, - }); - }, - }); + + + //订阅消息 + getWeChatMpMessage().then((res) => { + var message = res.data.result; + var templateid = message.map((item) => item.code); + uni.requestSubscribeMessage({ + tmplIds: templateid, + success: (res) => { + + }, + fail: (res) => { + console.log('fail', res) + uni.showToast({ + icon: "none", + title: "订阅消息失败", + }) + }, + complete: (res) => { + console.log('complete', res) + + /** + * 已经支付成功 + */ + uni.redirectTo({ + url: + "/pages/cart/payment/success?paymentMethod=WECHAT" + + "&payPrice=" + + price, + }); + }, }); - } else { - /** - * 已经支付成功 - */ - uni.redirectTo({ - url: - "/pages/cart/payment/success?paymentMethod=WECHAT" + - "&payPrice=" + - price, - }); - } + }); + } export default LiLiWXPay; diff --git a/pages/cart/payment/success.vue b/pages/cart/payment/success.vue index aa2892a..4e323a6 100644 --- a/pages/cart/payment/success.vue +++ b/pages/cart/payment/success.vue @@ -5,7 +5,7 @@ ¥{{ Number(payPrice) | unitPrice }}
-
查看{{this.orderType == "RECHARGE" ? '余额' : '订单'}}
+
查看{{ this.orderType == "RECHARGE" ? '余额' : '订单' }}
回到首页
@@ -16,7 +16,7 @@
支付方式:
-
{{paymentMethod | paymentTypeFilter}}
+
{{ paymentMethod | paymentTypeFilter }}
@@ -60,7 +60,7 @@ export default { this.from = options.from || ""; this.payPrice = options.payPrice || 0; this.orderType = options.orderType; - // this.sendMessage() + }, methods: { checkOrder() { @@ -77,11 +77,6 @@ export default { this.navigateTo("/pages/order/myOrder?status=0"); } }, - changeStatus(val) { - if (val) { - this.sendMessage(); - } - }, navigateTo(url, type) { if (type === "switch") { @@ -105,6 +100,7 @@ export default { padding: 0 20rpx 20rpx; width: 80%; } + .pay-btns { display: flex; width: 50%; @@ -112,7 +108,7 @@ export default { margin: 0 auto; color: #fff; - > div { + >div { padding: 6px 12px; border: 1px solid #fff; border-radius: 100px; @@ -146,7 +142,7 @@ export default { border-radius: 20rpx; background: rgba($color: $main-color, $alpha: 0.2); - > h2 { + >h2 { margin-top: 20rpx; font-size: 40rpx; color: $main-color; diff --git a/pages/order/fillorder.vue b/pages/order/fillorder.vue index d3e94e7..eeadac9 100644 --- a/pages/order/fillorder.vue +++ b/pages/order/fillorder.vue @@ -386,13 +386,13 @@