"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const utils_api = require("../../utils/api.js");
const utils_tabParams = require("../../utils/tabParams.js");
if (!Math) {
  AuthorizePopup();
}
const AuthorizePopup = () => "../../components/AuthorizePopup.js";
const _sfc_main = {
  __name: "mine",
  setup(__props) {
    const tabParamStore = utils_tabParams.useTabParamStore();
    const userInfo1 = common_vendor.index.getStorageSync("carUserInfo");
    const paddingTop = common_vendor.ref(0);
    const userInfo = common_vendor.ref({});
    const show = common_vendor.ref(false);
    const typeList = [
      {
        text: "待支付",
        imgUrl: "/static/images/mine/nopay.png",
        path: "/pages/order/order",
        type: 6,
        isChcek: true
      },
      {
        text: "未乘车",
        imgUrl: "/static/images/mine/noriding.png",
        path: "/pages/order/order",
        type: 3,
        isChcek: true
      },
      {
        text: "已乘车",
        imgUrl: "/static/images/mine/riding.png",
        path: "/pages/order/order",
        type: 2,
        isChcek: true
      },
      {
        text: "已取消",
        imgUrl: "/static/images/mine/cancel.png",
        path: "/pages/order/order",
        type: 4,
        isChcek: true
      }
    ];
    const commonList = [
      {
        text: "常用旅客",
        imgUrl: "/static/images/mine/people.png",
        path: "/pages/commonPeople/commonPeople",
        isChcek: true
      },
      {
        text: "优惠券",
        imgUrl: "/static/images/mine/coupon.png",
        path: "/pages/coupon/coupon",
        isChcek: true
      },
      {
        text: "联系客服",
        imgUrl: "/static/images/mine/service.png",
        path: "",
        isChcek: false
      },
      {
        text: "客服电话",
        imgUrl: "/static/images/mine/phone.png",
        path: "",
        isChcek: false
      },
      {
        text: "电子交通卡",
        imgUrl: "/static/images/mine/card.png",
        path: "/pages/transportation/transportation",
        isChcek: true
      }
    ];
    const worktime = common_vendor.ref("");
    const workTele = common_vendor.ref("");
    const roleType = common_vendor.ref("");
    const saoNum = common_vendor.ref("");
    common_vendor.onMounted(() => {
      paddingTop.value = common_vendor.index.getMenuButtonBoundingClientRect().top;
      userInfo.value = common_vendor.index.getStorageSync("carUserInfo");
      getTuigai();
      getShen();
    });
    function clickItem(item) {
      if (item.isChcek) {
        if (userInfo.value) {
          if (item.type) {
            tabParamStore.setType(item.type);
            common_vendor.index.switchTab({
              url: item.path
            });
          } else {
            common_vendor.index.navigateTo({
              url: item.path
            });
          }
        } else {
          common_vendor.index.showModal({
            title: "提示",
            content: "请先登录",
            success: (res) => {
              if (res.confirm) {
                show.value = true;
              }
            }
          });
        }
      } else {
        if (item.text === "联系客服" || item.text === "客服电话") {
          common_vendor.index.showModal({
            title: "拨打客服电话:" + workTele.value,
            content: "工作时间:" + worktime.value,
            cancelText: "关闭",
            confirmText: "拨打",
            confirmColor: "#FF8205",
            success: (res) => {
              if (res.confirm) {
                common_vendor.index.makePhoneCall({
                  phoneNumber: workTele.value,
                  // 仅支持数字，固定号码需加引号
                  success: () => console.log("拨号功能调用成功"),
                  fail: (err) => console.error("拨号失败：", err)
                });
              }
            }
          });
        }
      }
    }
    async function getTuigai() {
      const res = await utils_api.myRequest({
        url: "/carBook/cnqueryHb.action",
        data: {}
      });
      if (res.code == 200) {
        worktime.value = res.data.workTime;
        workTele.value = res.data.workMobile;
      } else {
        common_vendor.index.showToast({
          title: res.message,
          icon: "none"
        });
      }
    }
    const handleClose = (val) => {
      show.value = false;
      if (val) {
        userInfo.value = common_vendor.index.getStorageSync("carUserInfo");
      }
    };
    const handleLogin = () => {
      show.value = true;
    };
    async function getShen() {
      const res = await utils_api.myRequest({
        url: "/tAppgetUserByMobile.action",
        data: {
          mobile: userInfo1.mobile
        }
      });
      if (res.code == 200) {
        roleType.value = res.data.roler;
      } else {
        common_vendor.index.showToast({
          title: res.message,
          icon: "none"
        });
      }
    }
    const saomaH = (val) => {
      common_vendor.index.showLoading({
        title: "扫码中...",
        mask: true
        // 是否显示透明蒙层，防止触摸穿透
      });
      common_vendor.wx$1.scanCode({
        onlyFromCamera: false,
        // 只允许从相机扫码
        success(res) {
          console.log("扫码成功：" + JSON.stringify(res) + res.result);
          saoNum.value = res.result;
          setTimeout(function() {
            saomaCha();
          }, 700);
        }
      });
      common_vendor.index.hideLoading();
    };
    async function saomaCha() {
      console.log("oo");
      const res = await utils_api.myRequest({
        url: "/tAppvertifyTicket.action",
        data: {
          id: saoNum.value,
          vertifyManMobile: userInfo1.mobile
        }
      });
      if (res.code == 200) {
        common_vendor.index.showToast({
          title: "扫码成功",
          icon: "none"
        });
      } else {
        common_vendor.index.showToast({
          title: res.message,
          icon: "none"
        });
      }
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_assets._imports_0$1,
        b: `${paddingTop.value * 2}rpx`,
        c: common_assets._imports_1$1,
        d: userInfo.value.username
      }, userInfo.value.username ? {
        e: common_vendor.t(userInfo.value.username)
      } : {
        f: common_vendor.o(handleLogin)
      }, {
        g: userInfo.value.mobile
      }, userInfo.value.mobile ? {
        h: common_vendor.t(userInfo.value.mobile)
      } : {}, {
        i: roleType.value == "超级管理员"
      }, roleType.value == "超级管理员" ? {
        j: common_vendor.o(saomaH)
      } : {}, {
        k: common_vendor.f(typeList, (item, index, i0) => {
          return {
            a: item.imgUrl,
            b: common_vendor.t(item.text),
            c: index,
            d: common_vendor.o(($event) => clickItem(item), index)
          };
        }),
        l: common_vendor.f(commonList, (item, index, i0) => {
          return {
            a: item.imgUrl,
            b: common_vendor.t(item.text),
            c: index,
            d: common_vendor.o(($event) => clickItem(item), index)
          };
        }),
        m: common_vendor.o(handleClose),
        n: common_vendor.p({
          show: show.value
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7c2ebfa5"], ["__file", "D:/创海项目/CH2025/约车小程序/yueche_app/pages/mine/mine.vue"]]);
_sfc_main.__runtimeHooks = 2;
wx.createPage(MiniProgramPage);
