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/index/index.js |  202 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 166 insertions(+), 36 deletions(-)

diff --git a/unpackage/dist/dev/mp-weixin/pages/index/index.js b/unpackage/dist/dev/mp-weixin/pages/index/index.js
index e1e3762..00026c3 100644
--- a/unpackage/dist/dev/mp-weixin/pages/index/index.js
+++ b/unpackage/dist/dev/mp-weixin/pages/index/index.js
@@ -1,63 +1,193 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
 const common_assets = require("../../common/assets.js");
+const api_index = require("../../api/index.js");
 const _sfc_main = {
   __name: "index",
   setup(__props) {
     const topHeight = common_vendor.ref(0);
+    function getTopHeight() {
+      if (common_vendor.index.getMenuButtonBoundingClientRect) {
+        topHeight.value = common_vendor.index.getMenuButtonBoundingClientRect().top * 2;
+      }
+    }
+    const cardInfo = common_vendor.ref({
+      id: "",
+      userName: "微信用户",
+      headImg: "",
+      userPhone: "",
+      waterCardNumber: "",
+      balance: "",
+      count: ""
+    });
     const isVip = common_vendor.ref(false);
-    function navToAddCard() {
-      common_vendor.index.navigateTo({
-        url: "/pages/addCard/index"
+    async function getVipInfo() {
+      await api_index.getVipInfoApi().then((res) => {
+        if (res.code == 200) {
+          cardInfo.value.waterCardNumber = res.data.cardNumber;
+          if (res.data.cardType == 1) {
+            cardInfo.value.balance = res.data.balance;
+          } else if (res.data.cardType == 2) {
+            cardInfo.value.count = res.data.count;
+          }
+          isVip.value = true;
+        }
+      });
+    }
+    async function getInfo() {
+      await api_index.getUserInfo().then(async (res) => {
+        if (res.code == 200) {
+          cardInfo.value.userName = res.data.userInfo.userName ? res.data.userInfo.userName : cardInfo.value.userName;
+          cardInfo.value.headImg = res.data.userInfo.headImg;
+          cardInfo.value.userPhone = res.data.userInfo.userPhone;
+          cardInfo.value.id = res.data.userInfo.id;
+          if (res.data.userInfo.waterCardNumber) {
+            await getVipInfo();
+          } else {
+            isVip.value = false;
+          }
+          common_vendor.index.setStorageSync("userInfo", JSON.stringify(cardInfo.value));
+        }
+      });
+    }
+    function toScan() {
+      common_vendor.index.scanCode({
+        scanType: ["qrCode"],
+        success: function(res) {
+          console.log("条码内容:" + res.result);
+          common_vendor.index.navigateTo({
+            url: "/pages/scanWater/index"
+          });
+        }
       });
     }
     const functionList = common_vendor.ref([
-      { text: "余额记录", icon: "../../static/images/index/icon31.png", url: "/pages/balanceRecord/index" },
-      { text: "消费记录", icon: "../../static/images/index/icon32.png", url: "/pages/login/index" },
-      { text: "充值记录", icon: "../../static/images/index/icon33.png", url: "/pages/login/index" },
-      { text: "账户共享", icon: "../../static/images/index/icon34.png", url: "/pages/login/index" },
-      { text: "优惠卷", icon: "../../static/images/index/icon35.png", url: "/pages/login/index" },
-      { text: "电子发票", icon: "../../static/images/index/icon36.png", url: "/pages/login/index" },
-      { text: "联系客服", icon: "../../static/images/index/icon37.png", url: "/pages/login/index" },
-      { text: "推广分佣", icon: "../../static/images/index/icon38.png", url: "/pages/login/index" }
+      { text: "余额记录", icon: "../../static/images/index/icon31.png", url: "/pages/functionList/balanceRecord/index", isUrl: 1 },
+      { text: "消费记录", icon: "../../static/images/index/icon32.png", url: "/pages/functionList/paymentRecord/index", isUrl: 1 },
+      { text: "充值记录", icon: "../../static/images/index/icon33.png", url: "/pages/functionList/rechargeRecord/index", isUrl: 1 },
+      { text: "账户共享", icon: "../../static/images/index/icon34.png", url: "", isUrl: 1 },
+      { text: "优惠卷", icon: "../../static/images/index/icon35.png", url: "", isUrl: 1 },
+      { text: "电子发票", icon: "../../static/images/index/icon36.png", url: "", isUrl: 1 },
+      { text: "会员卡挂失", icon: "../../static/images/index/icon37.png", url: "", isUrl: 2 },
+      { text: "会员卡注销", icon: "../../static/images/index/icon38.png", url: "", isUrl: 3 }
     ]);
     function navTo(itemUrl) {
-      common_vendor.index.navigateTo({
-        url: itemUrl
-      });
-    }
-    common_vendor.onMounted(() => {
-      if (common_vendor.index.getMenuButtonBoundingClientRect) {
-        topHeight.value = (common_vendor.index.getMenuButtonBoundingClientRect().top + common_vendor.index.getMenuButtonBoundingClientRect().height) * 2;
+      if (itemUrl) {
+        common_vendor.index.navigateTo({
+          url: itemUrl
+        });
       }
+    }
+    async function setEvent(isUrl, url) {
+      if (isUrl == 1) {
+        navTo(url);
+      } else if (isUrl == 2) {
+        common_vendor.index.showModal({
+          title: "会员卡挂失",
+          content: "确认挂失会员卡?",
+          success: async function(res) {
+            if (res.confirm) {
+              await api_index.reportLossApi(cardInfo.value.waterCardNumber).then((res2) => {
+                if (res2.code == 200) {
+                  common_vendor.index.showToast({
+                    title: "已挂失",
+                    duration: 2e3
+                  });
+                }
+              });
+            } else {
+              console.log("点击了取消7");
+            }
+          }
+        });
+      } else if (isUrl == 3) {
+        common_vendor.index.showModal({
+          title: "会员卡注销",
+          content: "确认注销会员卡?",
+          success: async function(res) {
+            if (res.confirm) {
+              await api_index.removeCardApi(cardInfo.value.waterCardNumber).then(async (res2) => {
+                if (res2.code == 200) {
+                  common_vendor.index.showToast({
+                    title: "已注销",
+                    duration: 2e3
+                  });
+                  await getVipInfo().then((res3) => {
+                    if (res3.code == 200) {
+                      if (!res3.data.id) {
+                        isVip.value = false;
+                        cardInfo.value.balance = "";
+                        cardInfo.value.count = "";
+                        cardInfo.value.waterCardNumber = "";
+                        common_vendor.index.setStorageSync("userInfo", JSON.stringify(cardInfo.value));
+                      }
+                    }
+                  });
+                }
+              });
+            } else {
+              console.log("点击了取消8");
+            }
+          }
+        });
+      }
+    }
+    common_vendor.onMounted(async () => {
+      getTopHeight();
+    });
+    common_vendor.onShow(async () => {
+      await getInfo();
     });
     return (_ctx, _cache) => {
       return common_vendor.e({
-        a: isVip.value
-      }, isVip.value ? {
-        b: common_assets._imports_0$1
-      } : {
-        c: common_assets._imports_1
-      }, {
+        a: common_assets._imports_0$1,
+        b: common_vendor.t(cardInfo.value.userName),
+        c: common_assets._imports_1$1,
         d: common_assets._imports_2,
-        e: common_assets._imports_3,
-        f: common_vendor.o(($event) => navToAddCard()),
-        g: topHeight.value + "rpx",
-        h: common_assets._imports_4,
-        i: common_assets._imports_5,
-        j: common_vendor.f(functionList.value, (item, index, i0) => {
+        e: common_vendor.o(($event) => navTo("/pages/addCard/index")),
+        f: common_vendor.o(($event) => navTo("/pages/userInfo/index")),
+        g: common_assets._imports_3,
+        h: isVip.value
+      }, isVip.value ? {
+        i: common_assets._imports_4
+      } : {}, {
+        j: isVip.value
+      }, isVip.value ? {
+        k: common_vendor.t(cardInfo.value.waterCardNumber)
+      } : {}, {
+        l: isVip.value
+      }, isVip.value ? {} : {}, {
+        m: !isVip.value
+      }, !isVip.value ? {} : {}, {
+        n: isVip.value
+      }, isVip.value ? {
+        o: common_vendor.t(cardInfo.value.balance)
+      } : {}, {
+        p: isVip.value
+      }, isVip.value ? {
+        q: common_vendor.o(($event) => navTo("/pages/recharge/index"))
+      } : {}, {
+        r: topHeight.value + "rpx",
+        s: common_assets._imports_5,
+        t: common_vendor.o(($event) => navTo("/pages/sendWater/index")),
+        v: common_assets._imports_1,
+        w: common_vendor.o(($event) => navTo("/pages/facilityList/index")),
+        x: common_assets._imports_7,
+        y: common_vendor.o(($event) => toScan()),
+        z: common_vendor.f(functionList.value, (item, index, i0) => {
           return {
             a: item.icon,
             b: common_vendor.t(item.text),
-            c: common_vendor.o(($event) => navTo(item.url), index),
+            c: common_vendor.o(($event) => setEvent(item.isUrl, item.url), index),
             d: index
           };
         }),
-        k: common_assets._imports_6,
-        l: common_assets._imports_7,
-        m: common_assets._imports_8,
-        n: common_assets._imports_9,
-        o: common_assets._imports_8
+        A: common_assets._imports_8,
+        B: common_assets._imports_9,
+        C: common_assets._imports_10,
+        D: common_vendor.o(($event) => navTo("/pages/station/index")),
+        E: common_assets._imports_11,
+        F: common_assets._imports_10
       });
     };
   }

--
Gitblit v1.9.3