Liuyi
2024-10-19 42e5ea86f7edc9361227edd979a8ae1952713161
unpackage/dist/dev/mp-weixin/pages/index/index.js
@@ -11,7 +11,6 @@
        topHeight.value = common_vendor.index.getMenuButtonBoundingClientRect().top * 2;
      }
    }
    const isLoss = common_vendor.ref(false);
    const cardInfo = common_vendor.ref({
      id: "",
      userName: "微信用户",
@@ -20,39 +19,41 @@
      waterCardNumber: "",
      balance: "",
      count: "",
      state: ""
      state: "",
      //state:true:挂失,false:正常
      userCardType: ""
      //userCardType:true:共享卡,false:正常卡
    });
    const isLoss = common_vendor.ref(false);
    const isVip = common_vendor.ref(false);
    function getVipInfo() {
      return new Promise((resolve, reject) => {
        api_index.getVipInfoApi().then((res) => {
          if (res.code == 200) {
            cardInfo.value.waterCardNumber = res.data.cardNumber;
            cardInfo.value.state = res.data.state;
            isLoss.value = cardInfo.value.state == 2 ? true : false;
            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;
    const isShareCard = common_vendor.ref(false);
    async function getVipInfo() {
      await api_index.getVipInfoApi().then((res) => {
        if (res.code == 200 && res.data.id) {
          cardInfo.value.waterCardNumber = res.data.cardNumber;
          cardInfo.value.state = res.data.state == 2 ? true : false;
          cardInfo.value.userCardType = res.data.userCardType == 2 ? true : false;
          isLoss.value = cardInfo.value.state;
          isShareCard.value = cardInfo.value.userCardType;
          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;
          console.log("cardInfo", cardInfo.value, "isShareCard.value", isShareCard.value);
        }
      });
    }
    function getInfo() {
      api_index.getUserInfo().then((res) => {
    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) {
            getVipInfo();
            console.log("00000");
          } else {
            isVip.value = false;
          }
          await getVipInfo();
          console.log("00000", cardInfo.value);
          common_vendor.index.setStorageSync("userInfo", JSON.stringify(cardInfo.value));
        }
      });
@@ -69,10 +70,10 @@
      });
    }
    const functionList = common_vendor.ref([
      { text: "余额记录", icon: "../../static/images/index/icon31.png", bgColor: "#16b387", bgColor: "", url: "/pages/functionList/balanceRecord/index", isUrl: 1 },
      { text: "余额记录", icon: "../../static/images/index/icon31.png", bgColor: "#16b387", url: "/pages/functionList/balanceRecord/index", isUrl: 1 },
      { text: "消费记录", icon: "../../static/images/index/icon32.png", bgColor: "#329ae8", url: "/pages/functionList/paymentRecord/index", isUrl: 1 },
      { text: "充值记录", icon: "../../static/images/index/icon33.png", bgColor: "#faaf0f", url: "/pages/functionList/rechargeRecord/index", isUrl: 1 },
      { text: "账户共享", icon: "../../static/images/index/icon34.png", bgColor: "#faaf0f", url: "", isUrl: 4 },
      { text: "充值记录", icon: "../../static/images/index/icon33.png", bgColor: "#f0a50e", url: "/pages/functionList/rechargeRecord/index", isUrl: 1 },
      { text: "水卡共享", icon: "../../static/images/index/icon34.png", bgColor: "#55ca8c", url: "/pages/functionList/share/cardShare/index", isUrl: 1 },
      { text: "故障上报", icon: "../../static/images/index/icon35.png", bgColor: "#a88ff1", url: "/pages/infoBreakdown/index", isUrl: 1 },
      { text: "优惠卷", icon: "../../static/images/index/icon36.png", bgColor: "#18bfc4", url: "", isUrl: 4 },
      { text: "会员卡挂失", icon: "../../static/images/index/icon37.png", bgColor: "#4875f0", url: "", isUrl: 2 },
@@ -89,62 +90,74 @@
      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(async (res2) => {
                if (res2.code == 200) {
                  common_vendor.index.showToast({
                    title: "已挂失",
                    duration: 2e3
                  });
                  await api_index.getVipInfoApi().then((res3) => {
                    if (res3.code == 200) {
                      if (res3.data.state == 2) {
                        isLoss.value = true;
        if (cardInfo.value.waterCardNumber) {
          common_vendor.index.showModal({
            title: "会员卡挂失",
            content: "确认挂失会员卡?",
            success: async function(res) {
              if (res.confirm) {
                await api_index.reportLossApi(cardInfo.value.waterCardNumber).then(async (res2) => {
                  if (res2.code == 200) {
                    common_vendor.index.showToast({
                      title: "已挂失",
                      duration: 2e3
                    });
                    await api_index.getVipInfoApi().then((res3) => {
                      if (res3.code == 200) {
                        if (res3.data.state == 2) {
                          isLoss.value = true;
                        }
                      }
                    }
                  });
                }
              });
            } else {
              console.log("点击了取消7");
                    });
                  }
                });
              }
            }
          }
        });
          });
        } else {
          common_vendor.index.showToast({
            title: "未绑定会员卡!",
            icon: "none"
          });
        }
      } 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,
                    icon: "none"
                  });
                  await api_index.getVipInfoApi().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));
        if (cardInfo.value.waterCardNumber) {
          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,
                      icon: "none"
                    });
                    await api_index.getVipInfoApi().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");
                    });
                  }
                });
              } else {
                console.log("点击了取消8");
              }
            }
          }
        });
          });
        } else {
          common_vendor.index.showToast({
            title: "未绑定会员卡!",
            icon: "none"
          });
        }
      } else {
        common_vendor.index.showToast({
          title: "该功能正在升级中!",
@@ -185,37 +198,43 @@
        e: common_assets._imports_1$1,
        f: common_assets._imports_2,
        g: common_vendor.o(($event) => navTo("/pages/addCard/index")),
        h: common_assets._imports_3,
        i: isVip.value
      }, isVip.value ? {
        j: common_assets._imports_4
        h: common_assets._imports_0$2,
        i: isShareCard.value
      }, isShareCard.value ? {
        j: common_vendor.t(cardInfo.value.waterCardNumber)
      } : {}, {
        k: isLoss.value && isVip.value
      }, isLoss.value && isVip.value ? {} : {}, {
        k: !isShareCard.value
      }, !isShareCard.value ? common_vendor.e({
        l: isVip.value
      }, isVip.value ? {
        m: common_vendor.t(cardInfo.value.waterCardNumber)
        m: common_assets._imports_4
      } : {}, {
        n: isVip.value
        n: isLoss.value && isVip.value
      }, isLoss.value && isVip.value ? {} : {}, {
        o: isVip.value
      }, isVip.value ? {
        p: common_vendor.t(cardInfo.value.waterCardNumber)
      } : {}, {
        q: isVip.value
      }, isVip.value ? {} : {}, {
        o: !isVip.value
        r: !isVip.value
      }, !isVip.value ? {} : {}, {
        p: isVip.value
        s: isVip.value
      }, isVip.value ? {
        q: common_vendor.t(cardInfo.value.balance)
        t: common_vendor.t(cardInfo.value.balance)
      } : {}, {
        r: isVip.value
        v: isVip.value
      }, isVip.value ? {
        s: common_vendor.o(($event) => navTo("/pages/recharge/index"))
      } : {}, {
        t: topHeight.value + "rpx",
        v: common_assets._imports_5,
        w: common_vendor.o(($event) => upGrade()),
        x: common_assets._imports_1,
        y: common_vendor.o(($event) => navTo("/pages/facilityList/index")),
        z: common_assets._imports_7,
        A: common_vendor.o(($event) => toScan()),
        B: common_vendor.f(functionList.value, (item, index, i0) => {
        w: common_vendor.o(($event) => navTo("/pages/recharge/index"))
      } : {}) : {}, {
        x: topHeight.value + "rpx",
        y: common_assets._imports_5,
        z: common_vendor.o(($event) => upGrade()),
        A: common_assets._imports_1,
        B: common_vendor.o(($event) => navTo("/pages/facilityList/index")),
        C: common_assets._imports_7,
        D: common_vendor.o(($event) => toScan()),
        E: common_vendor.f(functionList.value, (item, index, i0) => {
          return {
            a: item.icon,
            b: item.bgColor,
@@ -224,14 +243,14 @@
            e: index
          };
        }),
        C: common_assets._imports_8,
        D: common_vendor.o(upGrade),
        E: common_assets._imports_9,
        F: common_assets._imports_10,
        G: common_vendor.o(($event) => navTo("/pages/station/index")),
        H: common_assets._imports_11,
        F: common_assets._imports_8,
        G: common_vendor.o(upGrade),
        H: common_assets._imports_9,
        I: common_assets._imports_10,
        J: common_vendor.o(upGrade)
        J: common_vendor.o(($event) => navTo("/pages/station/index")),
        K: common_assets._imports_11,
        L: common_assets._imports_10,
        M: common_vendor.o(upGrade)
      });
    };
  }