| | |
| | | const topHeight = common_vendor.ref(0); |
| | | function getTopHeight() { |
| | | if (common_vendor.index.getMenuButtonBoundingClientRect) { |
| | | topHeight.value = (common_vendor.index.getMenuButtonBoundingClientRect().top + common_vendor.index.getMenuButtonBoundingClientRect().height) * 2; |
| | | topHeight.value = common_vendor.index.getMenuButtonBoundingClientRect().top * 2; |
| | | } |
| | | } |
| | | const vipInfo = common_vendor.ref(); |
| | | const cardInfo = common_vendor.ref({ |
| | | id: "", |
| | | userName: "微信用户", |
| | | headImg: "", |
| | | userPhone: "", |
| | | waterCardNumber: "", |
| | | balance: "", |
| | | count: "", |
| | | state: "", |
| | | //state:true:挂失,false:正常 |
| | | userCardType: "" |
| | | //userCardType:true:共享卡,false:正常卡 |
| | | }); |
| | | const isLoss = common_vendor.ref(false); |
| | | const isVip = common_vendor.ref(false); |
| | | const isShareCard = common_vendor.ref(false); |
| | | async function getVipInfo() { |
| | | let res = await api_index.getUserInfo(); |
| | | if (res.data.userInfo.waterCardNumber) { |
| | | let res1 = await api_index.getVipInfoApi(); |
| | | vipInfo.value = res1.data; |
| | | isVip.value = true; |
| | | } else { |
| | | isVip.value = false; |
| | | } |
| | | await api_index.getVipInfoApi().then((res) => { |
| | | if (res.code == 200 && res.data.id) { |
| | | cardInfo.value.waterCardNumber = res.data.cardNumber; |
| | | cardInfo.value.cardType = res.data.cardType; |
| | | 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); |
| | | } |
| | | }); |
| | | } |
| | | 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; |
| | | await getVipInfo(); |
| | | console.log("00000", cardInfo.value); |
| | | common_vendor.index.setStorageSync("userInfo", JSON.stringify(cardInfo.value)); |
| | | } |
| | | }); |
| | | } |
| | | function toScan() { |
| | | common_vendor.index.scanCode({ |
| | | scanType: ["qrCode"], |
| | | success: async function(res) { |
| | | console.log("条码内容:" + res.result); |
| | | let data = { |
| | | cardType: cardInfo.value.cardType, |
| | | card: cardInfo.value.waterCardNumber, |
| | | sn: res.result |
| | | }; |
| | | await api_index.buyWaterApi(data).then((res2) => { |
| | | if (res2.code == 200) { |
| | | common_vendor.index.navigateTo({ |
| | | url: "/pages/scanWater/index" |
| | | }); |
| | | } else { |
| | | common_vendor.index.showToast({ |
| | | title: "扫码失败!", |
| | | icon: "none" |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | 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", 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: "#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 }, |
| | | { text: "会员卡注销", icon: "../../static/images/index/icon38.png", bgColor: "#f45088", url: "", isUrl: 3 } |
| | | ]); |
| | | function navTo(itemUrl) { |
| | | if (itemUrl) { |
| | |
| | | }); |
| | | } |
| | | } |
| | | async function setEvent(isUrl, url) { |
| | | if (isUrl == 1) { |
| | | navTo(url); |
| | | } else if (isUrl == 2) { |
| | | if (cardInfo.value.waterCardNumber) { |
| | | if (!isShareCard.value && !cardInfo.value.state) { |
| | | 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 if (isShareCard.value) { |
| | | common_vendor.index.showToast({ |
| | | title: "共享卡无权限", |
| | | icon: "none" |
| | | }); |
| | | } else if (cardInfo.value.state) { |
| | | common_vendor.index.showToast({ |
| | | title: "已挂失", |
| | | icon: "none" |
| | | }); |
| | | } |
| | | } else { |
| | | common_vendor.index.showToast({ |
| | | title: "未绑定会员卡!", |
| | | icon: "none" |
| | | }); |
| | | } |
| | | } else if (isUrl == 3) { |
| | | if (cardInfo.value.waterCardNumber) { |
| | | if (!isShareCard.value) { |
| | | 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 { |
| | | common_vendor.index.showToast({ |
| | | title: "共享卡无权限", |
| | | icon: "none" |
| | | }); |
| | | } |
| | | } else { |
| | | common_vendor.index.showToast({ |
| | | title: "未绑定会员卡!", |
| | | icon: "none" |
| | | }); |
| | | } |
| | | } else { |
| | | upGrade(); |
| | | } |
| | | } |
| | | function upGrade() { |
| | | common_vendor.index.showToast({ |
| | | title: "该功能正在升级中!", |
| | | duration: 2e3, |
| | | icon: "none" |
| | | }); |
| | | } |
| | | common_vendor.onMounted(async () => { |
| | | getTopHeight(); |
| | | await getVipInfo(); |
| | | await getInfo(); |
| | | }); |
| | | common_vendor.onShow(async () => { |
| | | getTopHeight(); |
| | | await getInfo(); |
| | | }); |
| | | common_vendor.index.showShareMenu({ |
| | | withShareTicket: true, |
| | | menus: ["shareAppMessage", "shareTimeline"], |
| | | success: function() { |
| | | console.log("分享菜单显示成功"); |
| | | }, |
| | | fail: function(err) { |
| | | console.error("分享菜单显示失败", err); |
| | | } |
| | | }); |
| | | return (_ctx, _cache) => { |
| | | return common_vendor.e({ |
| | | a: isVip.value |
| | | }, isVip.value ? { |
| | | b: common_assets._imports_0$1 |
| | | a: cardInfo.value.headImg |
| | | }, cardInfo.value.headImg ? { |
| | | b: cardInfo.value.headImg |
| | | } : { |
| | | c: common_assets._imports_1, |
| | | d: common_vendor.o(($event) => navTo("/pages/addCard/index")) |
| | | c: common_assets._imports_0$2 |
| | | }, { |
| | | e: common_assets._imports_2, |
| | | f: common_assets._imports_3, |
| | | g: topHeight.value + "rpx", |
| | | h: common_assets._imports_4, |
| | | i: common_vendor.o(($event) => navTo("/pages/sendWater/index")), |
| | | j: common_vendor.o(($event) => navTo("/pages/recharge/index")), |
| | | k: common_assets._imports_5, |
| | | l: common_vendor.f(functionList.value, (item, index, i0) => { |
| | | d: common_vendor.t(cardInfo.value.userName), |
| | | e: common_vendor.o(($event) => navTo("/pages/userInfo/index")), |
| | | f: common_vendor.o(($event) => navTo("/pages/userInfo/index")), |
| | | g: common_assets._imports_1$1, |
| | | h: common_assets._imports_2, |
| | | i: common_vendor.o(($event) => navTo("/pages/addCard/index")), |
| | | j: common_assets._imports_0$1, |
| | | k: isShareCard.value |
| | | }, isShareCard.value ? { |
| | | l: common_vendor.t(cardInfo.value.waterCardNumber) |
| | | } : {}, { |
| | | m: !isShareCard.value |
| | | }, !isShareCard.value ? common_vendor.e({ |
| | | n: isVip.value |
| | | }, isVip.value ? { |
| | | o: common_assets._imports_4 |
| | | } : {}, { |
| | | p: isLoss.value && isVip.value |
| | | }, isLoss.value && isVip.value ? {} : {}, { |
| | | q: isVip.value |
| | | }, isVip.value ? { |
| | | r: common_vendor.t(cardInfo.value.waterCardNumber) |
| | | } : {}, { |
| | | s: isVip.value |
| | | }, isVip.value ? {} : {}, { |
| | | t: !isVip.value |
| | | }, !isVip.value ? {} : {}, { |
| | | v: isVip.value |
| | | }, isVip.value ? { |
| | | w: common_vendor.t(cardInfo.value.balance) |
| | | } : {}, { |
| | | x: isVip.value |
| | | }, isVip.value ? { |
| | | y: common_vendor.o(($event) => navTo("/pages/recharge/index")) |
| | | } : {}) : {}, { |
| | | z: topHeight.value + "rpx", |
| | | A: common_assets._imports_5, |
| | | B: common_vendor.o(($event) => upGrade()), |
| | | C: common_assets._imports_1, |
| | | D: common_vendor.o(($event) => navTo("/pages/facilityList/index")), |
| | | E: common_assets._imports_7, |
| | | F: common_vendor.o(($event) => toScan()), |
| | | G: 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), |
| | | d: index |
| | | b: item.bgColor, |
| | | c: common_vendor.t(item.text), |
| | | d: common_vendor.o(($event) => setEvent(item.isUrl, item.url), index), |
| | | e: index |
| | | }; |
| | | }), |
| | | m: common_assets._imports_6, |
| | | n: common_assets._imports_7, |
| | | o: common_assets._imports_8, |
| | | p: common_assets._imports_9, |
| | | q: common_assets._imports_8 |
| | | H: common_assets._imports_8, |
| | | I: common_vendor.o(upGrade), |
| | | J: common_assets._imports_9, |
| | | K: common_assets._imports_10, |
| | | L: common_vendor.o(($event) => navTo("/pages/station/index")), |
| | | M: common_assets._imports_11, |
| | | N: common_assets._imports_10, |
| | | O: common_vendor.o(upGrade) |
| | | }); |
| | | }; |
| | | } |