From 2a0fa0836d8452de64cd983b831f6a4920e4a108 Mon Sep 17 00:00:00 2001 From: Lufaneng Date: Wed, 15 Oct 2025 15:13:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E4=BD=8D=E7=BD=AE=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.json | 7 + pages/mine/mine.vue | 1290 +++++++++++--------------- pages/order/order.vue | 58 +- pagesA/edit-profile/edit-profile.vue | 290 +++--- pagesA/payment/payment.vue | 510 ++++++++++ 5 files changed, 1212 insertions(+), 943 deletions(-) create mode 100644 pagesA/payment/payment.vue diff --git a/pages.json b/pages.json index 32146a9..3c7236f 100644 --- a/pages.json +++ b/pages.json @@ -100,6 +100,13 @@ { "navigationBarTitleText" : "充值" } + }, + { + "path" : "payment/payment", + "style" : + { + "navigationBarTitleText" : "确认支付" + } } ] } diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue index b1134cd..0efa5ba 100644 --- a/pages/mine/mine.vue +++ b/pages/mine/mine.vue @@ -1,55 +1,83 @@ \ No newline at end of file diff --git a/pages/order/order.vue b/pages/order/order.vue index 6d4318b..8cdf83d 100644 --- a/pages/order/order.vue +++ b/pages/order/order.vue @@ -2,7 +2,7 @@
-
全部
+
全部
图纸生成
会员购买
钱包充值
@@ -124,7 +124,7 @@ import HeaderCustom from '/components/HeaderCustom/HeaderCustom.vue' import RPC from "@/utils/request"; import dayjs from "dayjs"; - + const isWeChatH5 = ref(false) // #ifdef H5 if (navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) { @@ -315,40 +315,12 @@ // #ifdef H5 // H5微信支付 - if (typeof WeixinJSBridge !== "undefined") { - return new Promise((resolve, reject) => { - WeixinJSBridge.invoke( - "getBrandWCPayRequest", { - appId: 'wxc504638e03981812', - timeStamp: orderInfo.timeStamp, - nonceStr: orderInfo.nonceStr, - package: orderInfo.package, - signType: orderInfo.signType, - paySign: orderInfo.paySign, - }, - (res) => { - if (res.err_msg === "get_brand_wcpay_request:ok") { - resolve({ - success: true, - data: res - }); - } else if (res.err_msg === "get_brand_wcpay_request:cancel") { - reject(new Error("用户取消支付")); - } else { - reject(new Error("微信支付失败")); - } - } - ); - }); - } else { - // 不在微信环境,跳转到支付页面 - const payUrl = orderInfo.mwebUrl; // 后端返回的H5支付链接 - window.location.href = payUrl; - return { - success: true, - redirect: true - }; - } + const payUrl = orderInfo.mwebUrl; // 后端返回的H5支付链接 + window.location.href = payUrl; + return { + success: true, + redirect: true + }; // #endif }; @@ -390,13 +362,22 @@ let paymentResult; if (order.pay_channel === "wxpay") { + // #ifdef MP-WEIXIN const res = await uni.login({ provider: 'weixin' }) - const orderResult = await RPC.post('/membership/order/pay_by_wechat_mini', { + orderResult = await RPC.post('/membership/order/pay_by_wechat_mini', { code: res.code, - "order_no": order.order_no + "order_no": orderNum.order_no + }) + // #endif + + // #ifdef H5 + orderResult = await RPC.post('/membership/order/pay_by_wechat_h5', { + "order_no": orderNum.order_no }) + // #endif + uni.showLoading({ title: "正在跳转微信支付...", }); @@ -411,6 +392,7 @@ }); paymentResult = await alipayPay(orderResult); } else if (order.pay_channel === 'wallet') { + uni.hideLoading() const res = await showModalAsync({ title: '确认支付', content: '确认使用钱包余额支付?' diff --git a/pagesA/edit-profile/edit-profile.vue b/pagesA/edit-profile/edit-profile.vue index 02c426e..de2e84f 100644 --- a/pagesA/edit-profile/edit-profile.vue +++ b/pagesA/edit-profile/edit-profile.vue @@ -37,7 +37,7 @@ 手机号 - {{ userStore.userInfo.phone }} + {{ userStore.userInfo.phone }} @@ -45,17 +45,8 @@ - - - + 用户协议 @@ -63,21 +54,20 @@ - 关于我们 - + --> - + @@ -463,14 +453,14 @@ const bindPhoneInfo = ref({ phone: "", code: "", - }); - - const changePhone = () => { + }); + + const changePhone = () => { bindPhoneInfo.value = { phone: "", code: "", - } - popup.value.open() + } + popup.value.open() } const bindPhoneRules = ref({ phone: [{ @@ -489,98 +479,98 @@ message: "请输入验证码", trigger: ["blur", "change"], }, - }); - - const bindCodeChange = (text) => { - bindCodeTips.value = text; - }; - - const closeBindPhoneModal = () => { - popup.value.close(); - bindPhoneInfo.value = { - phone: "", - code: "", - }; - bindCodeTips.value = "获取验证码"; - }; - - const confirmBindPhone = async () => { - try { - await bindPhoneForm.value.validate(); - - bindingPhone.value = true; - - // 调用绑定手机号API - RPC.post('/user/bind_phone', { - phone: bindPhoneInfo.value.phone, - code: bindPhoneInfo.value.code, - token: authStore.accessToken - }).then((res) => { - console.log('bind_phone', res) - bindingPhone.value = false; - uni.showToast({ - title: "换绑成功", - icon: "success", - }); - popup.value.close() - RPC.post('/user/info', { - token: authStore.accessToken, - }) - .then((res) => { - userStore.setUserInfo(res) - }) - }) - } catch (error) { - console.error("换绑手机号失败:", error); - bindingPhone.value = false; - } - }; - - const getBindCode = () => { - if (!bindPhoneInfo.value.phone) { - uni.showToast({ - title: "请输入手机号", - icon: "none", - }); - return; - } - - if (!/^1[3-9]\d{9}$/.test(bindPhoneInfo.value.phone)) { - uni.showToast({ - title: "请输入正确的手机号", - icon: "none", - }); - return; - } - - if (bindCodeRef.value.canGetCode) { - uni.showLoading({ - title: "正在获取验证码", - }); - // 调用发送验证码API - RPC.post('/user/bind_phone/send_code', { - phone: bindPhoneInfo.value.phone, - token: authStore.accessToken - }).then(() => { - uni.hideLoading() - uni.showToast({ - title: '验证码已发送', - icon: 'success' - }) - bindCodeRef.value.start() - }).catch(() => { - uni.hideLoading() - uni.showToast({ - title: '发送失败,请重试', - icon: 'none' - }) - }) - } else { - uni.showToast({ - title: "倒计时结束后再发送", - icon: "none", - }); - } + }); + + const bindCodeChange = (text) => { + bindCodeTips.value = text; + }; + + const closeBindPhoneModal = () => { + popup.value.close(); + bindPhoneInfo.value = { + phone: "", + code: "", + }; + bindCodeTips.value = "获取验证码"; + }; + + const confirmBindPhone = async () => { + try { + await bindPhoneForm.value.validate(); + + bindingPhone.value = true; + + // 调用绑定手机号API + RPC.post('/user/bind_phone', { + phone: bindPhoneInfo.value.phone, + code: bindPhoneInfo.value.code, + token: authStore.accessToken + }).then((res) => { + console.log('bind_phone', res) + bindingPhone.value = false; + uni.showToast({ + title: "换绑成功", + icon: "success", + }); + popup.value.close() + RPC.post('/user/info', { + token: authStore.accessToken, + }) + .then((res) => { + userStore.setUserInfo(res) + }) + }) + } catch (error) { + console.error("换绑手机号失败:", error); + bindingPhone.value = false; + } + }; + + const getBindCode = () => { + if (!bindPhoneInfo.value.phone) { + uni.showToast({ + title: "请输入手机号", + icon: "none", + }); + return; + } + + if (!/^1[3-9]\d{9}$/.test(bindPhoneInfo.value.phone)) { + uni.showToast({ + title: "请输入正确的手机号", + icon: "none", + }); + return; + } + + if (bindCodeRef.value.canGetCode) { + uni.showLoading({ + title: "正在获取验证码", + }); + // 调用发送验证码API + RPC.post('/user/bind_phone/send_code', { + phone: bindPhoneInfo.value.phone, + token: authStore.accessToken + }).then(() => { + uni.hideLoading() + uni.showToast({ + title: '验证码已发送', + icon: 'success' + }) + bindCodeRef.value.start() + }).catch(() => { + uni.hideLoading() + uni.showToast({ + title: '发送失败,请重试', + icon: 'none' + }) + }) + } else { + uni.showToast({ + title: "倒计时结束后再发送", + icon: "none", + }); + } }; @@ -707,43 +697,43 @@ .sheet-cancel { margin-top: 10px; } - } - .bind-phone-modal { - width: 320px; - padding: 24px; - - .modal-header { - text-align: center; - margin-bottom: 24px; - - .modal-title { - font-size: 18px; - font-weight: bold; - color: #333; - margin-bottom: 8px; - } - - .modal-subtitle { - font-size: 14px; - color: #666; - } - } - - .modal-form { - margin-bottom: 24px; - - .uv-form-item { - margin-bottom: 16px; - } - } - - .modal-actions { - display: flex; - gap: 12px; - - .uv-button { - flex: 1; - } - } + } + .bind-phone-modal { + width: 320px; + padding: 24px; + + .modal-header { + text-align: center; + margin-bottom: 24px; + + .modal-title { + font-size: 18px; + font-weight: bold; + color: #333; + margin-bottom: 8px; + } + + .modal-subtitle { + font-size: 14px; + color: #666; + } + } + + .modal-form { + margin-bottom: 24px; + + .uv-form-item { + margin-bottom: 16px; + } + } + + .modal-actions { + display: flex; + gap: 12px; + + .uv-button { + flex: 1; + } + } } \ No newline at end of file diff --git a/pagesA/payment/payment.vue b/pagesA/payment/payment.vue new file mode 100644 index 0000000..5af5892 --- /dev/null +++ b/pagesA/payment/payment.vue @@ -0,0 +1,510 @@ + + + + + \ No newline at end of file