unpackage/dist/dev/mp-weixin/pages/index/index.js
@@ -12,39 +12,48 @@
      }
    }
    const cardInfo = common_vendor.ref({
      userName: "",
      id: "",
      userName: "微信用户",
      headImg: "",
      userPhone: "",
      waterCardNumber: "",
      balance: "",
      count: "",
      userPhone: ""
      count: ""
    });
    const isVip = common_vendor.ref(false);
    async function getInfo() {
      let res = await api_index.getUserInfo();
      console.log("res", res.data);
      cardInfo.value.userName = res.data.userInfo.userName;
      cardInfo.value.headImg = res.data.userInfo.headImg;
      cardInfo.value.userPhone = res.data.userInfo.userPhone;
      if (res.data.userInfo.waterCardNumber) {
        let res1 = await api_index.getVipInfoApi();
        cardInfo.value.waterCardNumber = res1.data.cardNumber;
        if (res1.data.cardType == 1) {
          cardInfo.value.balance = res1.data.balance;
        } else if (res1.data.cardType == 2) {
          cardInfo.value.count = res1.data.count;
    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;
        }
        isVip.value = true;
      } else {
        isVip.value = false;
      }
      common_vendor.index.setStorageSync("userInfo", JSON.stringify(cardInfo.value));
      });
    }
    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.scanType);
          console.log("条码内容:" + res.result);
          common_vendor.index.navigateTo({
            url: "/pages/scanWater/index"
@@ -53,19 +62,73 @@
      });
    }
    const functionList = common_vendor.ref([
      { text: "余额记录", icon: "../../static/images/index/icon31.png", url: "/pages/balanceRecord/index" },
      { text: "消费记录", icon: "../../static/images/index/icon32.png", url: "" },
      { text: "充值记录", icon: "../../static/images/index/icon33.png", url: "" },
      { text: "账户共享", icon: "../../static/images/index/icon34.png", url: "" },
      { text: "优惠卷", icon: "../../static/images/index/icon35.png", url: "" },
      { text: "电子发票", icon: "../../static/images/index/icon36.png", url: "" },
      { text: "联系客服", icon: "../../static/images/index/icon37.png", url: "" },
      { text: "推广分佣", icon: "../../static/images/index/icon38.png", url: "" }
      { 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) {
      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");
            }
          }
        });
      }
    }
@@ -76,39 +139,56 @@
      await getInfo();
    });
    return (_ctx, _cache) => {
      return {
      return common_vendor.e({
        a: common_assets._imports_0$1,
        b: common_vendor.t(cardInfo.value.userName),
        c: common_assets._imports_1,
        d: common_vendor.o(($event) => navTo("/pages/userInfo/index")),
        e: common_assets._imports_2,
        f: common_vendor.t(cardInfo.value.waterCardNumber),
        g: common_vendor.t(cardInfo.value.userPhone),
        h: common_assets._imports_3,
        i: common_vendor.o(($event) => navTo("/pages/addCard/index")),
        j: common_vendor.t(cardInfo.value.balance),
        k: common_vendor.o(($event) => navTo("/pages/recharge/index")),
        l: topHeight.value + "rpx",
        m: common_assets._imports_4,
        n: common_vendor.o(($event) => navTo("/pages/sendWater/index")),
        o: common_assets._imports_1$1,
        p: common_vendor.o(($event) => navTo("/pages/facilityList/index")),
        q: common_assets._imports_6,
        r: common_vendor.o(($event) => toScan()),
        s: common_vendor.f(functionList.value, (item, index, i0) => {
        c: common_assets._imports_1$1,
        d: common_assets._imports_2,
        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
          };
        }),
        t: common_assets._imports_7,
        v: common_assets._imports_8,
        w: common_assets._imports_9,
        x: common_assets._imports_10,
        y: common_assets._imports_9
      };
        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
      });
    };
  }
};