usercenter.js 11 KB
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_api = require("../../common/api.js");
const common_match = require("../../common/match.js");
require("../../common/login.js");
require("../../common/request.js");
require("../../config.js");
if (!Array) {
  const _easycom_uni_list_item2 = common_vendor.resolveComponent("uni-list-item");
  const _easycom_uni_list2 = common_vendor.resolveComponent("uni-list");
  const _easycom_uni_countdown2 = common_vendor.resolveComponent("uni-countdown");
  const _easycom_uni_popup_dialog2 = common_vendor.resolveComponent("uni-popup-dialog");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_uni_list_item2 + _easycom_uni_list2 + _easycom_uni_countdown2 + _easycom_uni_popup_dialog2 + _easycom_uni_popup2)();
}
const _easycom_uni_list_item = () => "../../uni_modules/uni-list/components/uni-list-item/uni-list-item.js";
const _easycom_uni_list = () => "../../uni_modules/uni-list/components/uni-list/uni-list.js";
const _easycom_uni_countdown = () => "../../uni_modules/uni-countdown/components/uni-countdown/uni-countdown.js";
const _easycom_uni_popup_dialog = () => "../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_uni_list_item + _easycom_uni_list + _easycom_uni_countdown + _easycom_uni_popup_dialog + _easycom_uni_popup)();
}
const _sfc_main = {
  __name: "usercenter",
  setup(__props) {
    const vTypeImg = common_vendor.ref("/static/v1.png");
    const card = common_vendor.ref({});
    const reportData = common_vendor.ref({});
    const user = common_vendor.ref({});
    common_vendor.ref("");
    const avatarUrl = common_vendor.ref("");
    const captchaPhonenumber = common_vendor.ref("");
    const captcha = common_vendor.ref("");
    const inputDialog = common_vendor.ref(null);
    const start = common_vendor.ref(false);
    const canSend = common_vendor.ref(true);
    const app = getApp();
    const isMaster = common_vendor.ref(false);
    common_vendor.onPullDownRefresh(() => {
      getVip();
    });
    common_vendor.onShow(() => {
      if (app.globalData.isLogin) {
        init();
        getVip();
      } else {
        app.firstLoadCallback = () => {
          init();
          getVip();
        };
      }
    });
    function init() {
      const currUser = common_vendor.index.getStorageSync("currUser");
      user.value = currUser;
      if (user.value.manageFlag == "1" && app.globalData.venue.id == user.value.venueId) {
        isMaster.value = true;
      }
      avatarUrl.value = user.value.avatar;
    }
    function getVip() {
      getMemberInfo();
      if (isMaster.value) {
        common_api.getMaInfo().then((res) => {
          reportData.value = res.data;
        });
      }
    }
    function onChooseavatar(e) {
      common_match.uploadFile(e).then((data) => {
        avatarUrl.value = data.data;
        common_match.updateAvatar({ avatarUrl: avatarUrl.value }).then((res) => {
          common_vendor.index.showToast({
            title: "头像保存成功",
            icon: "none",
            duration: 2e3
          });
          common_vendor.index.setStorageSync("currUser", res.data);
        });
      });
    }
    function changePhoneNumber() {
      inputDialog.value.open();
    }
    function dialogInputConfirm() {
      common_vendor.index.getStorageSync("currUser");
      common_api.maRebindMemberCard(captchaPhonenumber.value, captcha.value).then((res) => {
        common_vendor.index.showToast({
          title: res.msg,
          icon: "none",
          duration: 2e3
        });
        captcha.value = "";
        getMemberInfo();
      });
    }
    function getMemberInfo() {
      common_vendor.index.getStorageSync("currUser");
      common_api.getOwnMemberInfo().then((res) => {
        card.value = res.data;
        app.globalData.isVip = card.value.isVip;
        app.globalData.relateProjectIdList = card.value.info.relateProjectIdList;
        app.globalData.relateVenueProjectIdList = card.value.info.relateVenueProjectIdList;
        if (card.value.isVip) {
          user.value.nickName = card.value.info.memberName;
          captchaPhonenumber.value = card.value.info.memberTelno;
        }
      });
    }
    function goRenew() {
      let path = "/pages/usercenter/mycard/renew";
      common_vendor.index.navigateTo({
        url: path
      });
    }
    function goCard() {
      let path = "/pages/usercenter/mycard/mycard";
      common_vendor.index.navigateTo({
        url: path
      });
    }
    function goBills() {
      let path = "/pages/usercenter/bills";
      common_vendor.index.navigateTo({
        url: path
      });
    }
    function goVip() {
      let path = "/pages/usercenter/mycard/mycard";
      common_vendor.index.navigateTo({
        url: path
      });
    }
    function goQcode() {
      common_vendor.index.scanCode({
        onlyFromCamera: true,
        success: function(res) {
          console.log("条码类型:" + res.scanType);
          console.log("条码内容:" + res.result);
          common_api.scanQrCode(res.result).then((res2) => {
            common_vendor.index.showModal({
              title: "提示",
              content: res2.msg,
              success: function(res3) {
                if (res3.confirm) {
                  console.log("确定");
                } else if (res3.cancel) {
                  console.log("取消");
                }
              }
            });
          });
        }
      });
    }
    function myTrain() {
      let path = "/pages/usercenter/myTrain/index/index";
      common_vendor.index.navigateTo({
        url: path
      });
    }
    function timeup() {
      canSend.value = true;
    }
    function sendsms() {
      if (captchaPhonenumber.value) {
        let strTemp = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
        if (strTemp.test(captchaPhonenumber.value)) {
          common_api.getCaptchaSms({
            phonenumber: captchaPhonenumber.value
          }).then((res) => {
            common_vendor.index.showToast({
              title: res.msg,
              icon: "none",
              duration: 2e3
            });
            start.value = true;
            canSend.value = false;
          });
        } else {
          common_vendor.index.showToast({
            title: "请输入正确的手机号",
            icon: "none",
            duration: 2e3
          });
        }
      } else {
        common_vendor.index.showToast({
          title: "请输入手机号",
          icon: "none",
          duration: 2e3
        });
      }
    }
    return (_ctx, _cache) => {
      var _a, _b;
      return common_vendor.e({
        a: avatarUrl.value,
        b: common_vendor.o(onChooseavatar),
        c: common_vendor.t(user.value.nickName),
        d: common_vendor.t(user.value.phonenumber),
        e: common_vendor.o(changePhoneNumber),
        f: !isMaster.value && card.value.isVip
      }, !isMaster.value && card.value.isVip ? {
        g: vTypeImg.value,
        h: common_vendor.t(card.value.info.cardTypeStr),
        i: common_vendor.t(card.value.info.cardCode),
        j: common_vendor.t(card.value.info.balance),
        k: common_vendor.t((100 - card.value.info.discountPercent) / 10),
        l: common_vendor.o(goCard),
        m: common_vendor.t((_a = card.value.info) == null ? void 0 : _a.expirationTime),
        n: common_vendor.o(goRenew)
      } : {}, {
        o: !isMaster.value
      }, !isMaster.value ? {
        p: common_vendor.p({
          border: false,
          title: "个人信息",
          showArrow: true,
          to: `./myInfo`
        }),
        q: common_vendor.p({
          border: false,
          title: "参赛队信息",
          showArrow: true,
          to: `./teamList`
        }),
        r: common_vendor.p({
          border: false,
          title: "会员充值",
          showArrow: true,
          to: `./mycard/renew`
        }),
        s: common_vendor.p({
          border: false,
          title: "场地订单",
          showArrow: true,
          to: `./bills`
        }),
        t: common_vendor.o(myTrain),
        v: common_vendor.p({
          border: false,
          title: "我的培训",
          showArrow: true,
          clickable: true
        }),
        w: common_vendor.p({
          border: false,
          title: "我的赛事",
          showArrow: true,
          to: `./match`
        }),
        x: common_vendor.p({
          border: false
        })
      } : {}, {
        y: isMaster.value
      }, isMaster.value ? {
        z: common_vendor.t((_b = card.value.info) == null ? void 0 : _b.expirationTime),
        A: common_vendor.o(goRenew),
        B: common_vendor.o(goBills),
        C: common_vendor.o(goVip),
        D: common_vendor.o(goQcode),
        E: common_vendor.p({
          border: false,
          title: "个人信息",
          showArrow: true,
          to: `./myInfo`
        }),
        F: common_vendor.p({
          border: false,
          title: "团体信息",
          showArrow: true,
          to: `./teamList`
        }),
        G: common_vendor.o(myTrain),
        H: common_vendor.p({
          border: false,
          title: "培训报名",
          showArrow: true,
          clickable: true
        }),
        I: common_vendor.p({
          border: false,
          title: "我的赛事",
          showArrow: true,
          to: `./match`
        }),
        J: common_vendor.p({
          border: false
        }),
        K: common_vendor.t(reportData.value.bookCount),
        L: common_vendor.t(reportData.value.bookAmount),
        M: common_vendor.t(reportData.value.memberCount),
        N: common_vendor.t(reportData.value.memberAmout)
      } : {}, {
        O: captchaPhonenumber.value,
        P: common_vendor.o(($event) => captchaPhonenumber.value = $event.detail.value),
        Q: captcha.value,
        R: common_vendor.o(($event) => captcha.value = $event.detail.value),
        S: canSend.value
      }, canSend.value ? {
        T: common_vendor.o(sendsms)
      } : {
        U: common_vendor.o(timeup),
        V: common_vendor.p({
          start: start.value,
          ["font-size"]: 14,
          ["show-day"]: false,
          ["show-hour"]: false,
          ["show-min"]: false,
          color: "#FFFFFF",
          splitorColor: "#fff",
          minute: 1,
          second: 0
        })
      }, {
        W: common_vendor.sr("inputClose", "a03cfe55-13,a03cfe55-12"),
        X: common_vendor.o(dialogInputConfirm),
        Y: common_vendor.p({
          mode: "input",
          title: "修改会员卡绑定手机号"
        }),
        Z: common_vendor.sr(inputDialog, "a03cfe55-12", {
          "k": "inputDialog"
        }),
        aa: common_vendor.p({
          type: "dialog"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a03cfe55"], ["__file", "/Users/yangyang/project/j-mini/Venue/pages/usercenter/usercenter.vue"]]);
wx.createPage(MiniProgramPage);