From b5efdb89b096906a9cf20e04610bda7f460cbb0f Mon Sep 17 00:00:00 2001
From: Liuyi <candymxq888@outlook.com>
Date: 星期六, 12 十月 2024 15:43:47 +0800
Subject: [PATCH] 添加充值记录页面,完善首页用户会员卡绑定信息,添加用户水卡注销及删除

---
 unpackage/dist/dev/mp-weixin/pages/recharge/index.js |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 107 insertions(+), 9 deletions(-)

diff --git a/unpackage/dist/dev/mp-weixin/pages/recharge/index.js b/unpackage/dist/dev/mp-weixin/pages/recharge/index.js
index 8a9776d..2872b67 100644
--- a/unpackage/dist/dev/mp-weixin/pages/recharge/index.js
+++ b/unpackage/dist/dev/mp-weixin/pages/recharge/index.js
@@ -1,6 +1,6 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
-const _sfc_main = {};
+const api_index = require("../../api/index.js");
 if (!Array) {
   const _easycom_navbar2 = common_vendor.resolveComponent("navbar");
   _easycom_navbar2();
@@ -9,12 +9,110 @@
 if (!Math) {
   _easycom_navbar();
 }
-function _sfc_render(_ctx, _cache) {
-  return {
-    a: common_vendor.p({
-      title: "绑定会员卡"
-    })
-  };
-}
-const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
+const _sfc_main = {
+  __name: "index",
+  setup(__props) {
+    const choosedMoney = common_vendor.ref(50);
+    const disabled = common_vendor.ref(true);
+    const moneyList = common_vendor.ref([
+      { value: 50, active: true },
+      { value: 100, active: false },
+      { value: 200, active: false },
+      { value: 500, active: false },
+      { value: 1e3, active: false },
+      { value: "其他金额", active: false }
+    ]);
+    const activeStyle = common_vendor.ref({
+      backgroundColor: "#5EADFF",
+      color: "#fff"
+    });
+    function chooseMoney(index1) {
+      moneyList.value.forEach((item, index) => {
+        if (item.active == true) {
+          item.active = false;
+        }
+      });
+      moneyList.value[index1].active = true;
+      if (index1 == 5) {
+        disabled.value = false;
+        choosedMoney.value = "";
+      } else {
+        choosedMoney.value = moneyList.value[index1].value;
+        otherMoney.value = "";
+        disabled.value = true;
+      }
+    }
+    const otherMoney = 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: true, img: "../../static/images/recharge/wx.png" }
+      // {text:"余额",value:3,checked:false,img:'../../static/images/recharge/balance.png'},
+    ]);
+    async function submit() {
+      let money = "";
+      if (disabled.value) {
+        money = choosedMoney.value;
+      } else {
+        money = Number(otherMoney.value);
+      }
+      await api_index.wxPayApi({ businessType: 1, tradeAmount: money }).then((res) => {
+        console.log("reswxpay", res);
+        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);
+            } else {
+              console.log("支付失败");
+            }
+          },
+          fail(res2) {
+            console.log("支付失败", res2);
+          }
+        });
+      });
+    }
+    return (_ctx, _cache) => {
+      return {
+        a: common_vendor.p({
+          title: "账户充值"
+        }),
+        b: common_vendor.f(moneyList.value, (item, index, i0) => {
+          return {
+            a: common_vendor.t(item.value),
+            b: common_vendor.s(item.active ? activeStyle.value : ""),
+            c: common_vendor.o(($event) => chooseMoney(index), index),
+            d: index
+          };
+        }),
+        c: disabled.value,
+        d: !disabled.value,
+        e: otherMoney.value,
+        f: common_vendor.o(($event) => otherMoney.value = $event.detail.value),
+        g: common_vendor.f(payList.value, (item, index, i0) => {
+          return {
+            a: item.img,
+            b: common_vendor.t(item.text),
+            c: item.value,
+            d: item.checked
+          };
+        }),
+        h: common_vendor.o(($event) => submit())
+      };
+    };
+  }
+};
+const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f06186df"]]);
 wx.createPage(MiniProgramPage);

--
Gitblit v1.9.3