From 7cbda90b02e31447122f1d22c9797b423d7bd9fc Mon Sep 17 00:00:00 2001
From: Liuyi <candymxq888@outlook.com>
Date: 星期三, 16 十月 2024 17:26:06 +0800
Subject: [PATCH] 添加扫码成功操作页,修改主页面样式,更换主页图标

---
 unpackage/dist/dev/mp-weixin/pages/recharge/index.js |   67 ++++++++++++++++++++++++---------
 1 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/unpackage/dist/dev/mp-weixin/pages/recharge/index.js b/unpackage/dist/dev/mp-weixin/pages/recharge/index.js
index a60365c..1bb393f 100644
--- a/unpackage/dist/dev/mp-weixin/pages/recharge/index.js
+++ b/unpackage/dist/dev/mp-weixin/pages/recharge/index.js
@@ -1,5 +1,6 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
+const api_index = require("../../api/index.js");
 if (!Array) {
   const _easycom_navbar2 = common_vendor.resolveComponent("navbar");
   _easycom_navbar2();
@@ -11,7 +12,7 @@
 const _sfc_main = {
   __name: "index",
   setup(__props) {
-    const choosedMoney = common_vendor.ref();
+    const choosedMoney = common_vendor.ref(50);
     const disabled = common_vendor.ref(true);
     const moneyList = common_vendor.ref([
       { value: 50, active: true },
@@ -42,29 +43,60 @@
       }
     }
     const otherMoney = common_vendor.ref();
-    const payMethod = common_vendor.ref();
+    common_vendor.ref();
     const payList = common_vendor.ref([
       // {text:"支付宝支付",value:1,checked:true,img:'../../static/images/recharge/pay.png'},
-      { text: "微信支付", value: 2, checked: false, img: "../../static/images/recharge/wx.png" },
-      { text: "余额", value: 3, checked: false, img: "../../static/images/recharge/balance.png" }
+      { text: "微信支付", value: 2, checked: true, img: "../../static/images/recharge/wx.png" }
+      // {text:"余额",value:3,checked:false,img:'../../static/images/recharge/balance.png'},
     ]);
-    function choosePay(index1) {
-      payList.value.forEach((item, index) => {
-        if (item.checked == true) {
-          item.checked = false;
-        }
-      });
-      payList.value[index1].checked = true;
-      payMethod.value = payList.value[index1].value;
-    }
-    function submit() {
+    async function submit() {
       let money = "";
       if (disabled.value) {
         money = choosedMoney.value;
       } else {
-        money = otherMoney.value;
+        money = Number(otherMoney.value);
       }
-      console.log("money", money);
+      await api_index.wxPayApi({ businessType: 1, tradeAmount: money }).then((res) => {
+        if (res.code == 200) {
+          common_vendor.wx$1.requestPayment({
+            //预支付订单信息
+            // appId: res.data.appId,
+            timeStamp: res.data.timeStamp,
+            //时间戳 
+            nonceStr: res.data.nonceStr,
+            //随机串     
+            package: res.data.package,
+            //prepay_id
+            signType: res.data.signType,
+            //签名算法MD5		
+            paySign: res.data.paySign,
+            //微信签名 
+            success(res2) {
+              if (res2.errMsg == "requestPayment:ok") {
+                console.log("支付成功", res2);
+                common_vendor.index.showToast({
+                  title: "支付成功",
+                  duration: 2e3
+                });
+                common_vendor.index.navigateBack();
+              } else {
+                common_vendor.index.showToast({
+                  title: "支付失败",
+                  duration: 2e3,
+                  icon: "none"
+                });
+              }
+            },
+            fail(res2) {
+              common_vendor.index.showToast({
+                title: "微信支付失败",
+                duration: 2e3,
+                icon: "none"
+              });
+            }
+          });
+        }
+      });
     }
     return (_ctx, _cache) => {
       return {
@@ -88,8 +120,7 @@
             a: item.img,
             b: common_vendor.t(item.text),
             c: item.value,
-            d: item.checked,
-            e: common_vendor.o(($event) => choosePay(index))
+            d: item.checked
           };
         }),
         h: common_vendor.o(($event) => submit())

--
Gitblit v1.9.3