From 15a55f79a84e5dab670d54a9dc0c6b9133a18441 Mon Sep 17 00:00:00 2001 From: Liuyi <candymxq888@outlook.com> Date: 星期一, 21 十月 2024 17:29:37 +0800 Subject: [PATCH] 添加更改用户头像,添加故障上报校验 --- unpackage/dist/dev/mp-weixin/pages/index/index.js | 229 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 132 insertions(+), 97 deletions(-) diff --git a/unpackage/dist/dev/mp-weixin/pages/index/index.js b/unpackage/dist/dev/mp-weixin/pages/index/index.js index 28f253b..104ed16 100644 --- a/unpackage/dist/dev/mp-weixin/pages/index/index.js +++ b/unpackage/dist/dev/mp-weixin/pages/index/index.js @@ -31,6 +31,7 @@ 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; @@ -61,10 +62,24 @@ function toScan() { common_vendor.index.scanCode({ scanType: ["qrCode"], - success: function(res) { + success: async function(res) { console.log("条码内容:" + res.result); - common_vendor.index.navigateTo({ - url: "/pages/scanWater/index" + 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" + }); + } }); } }); @@ -91,29 +106,41 @@ navTo(url); } else if (isUrl == 2) { 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; + 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: "未绑定会员卡!", @@ -122,36 +149,41 @@ } } else if (isUrl == 3) { 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)); + 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 { - console.log("点击了取消8"); + }); + } + }); + } } - } - }); + }); + } else { + common_vendor.index.showToast({ + title: "共享卡无权限", + icon: "none" + }); + } } else { common_vendor.index.showToast({ title: "未绑定会员卡!", @@ -159,11 +191,7 @@ }); } } else { - common_vendor.index.showToast({ - title: "该功能正在升级中!", - duration: 2e3, - icon: "none" - }); + upGrade(); } } function upGrade() { @@ -175,8 +203,10 @@ } common_vendor.onMounted(async () => { getTopHeight(); + await getInfo(); }); common_vendor.onShow(async () => { + getTopHeight(); await getInfo(); }); common_vendor.index.showShareMenu({ @@ -191,50 +221,55 @@ }); return (_ctx, _cache) => { return common_vendor.e({ - a: common_assets._imports_0$1, - b: common_vendor.t(cardInfo.value.userName), - c: common_vendor.o(($event) => navTo("/pages/userInfo/index")), - d: common_vendor.o(($event) => navTo("/pages/userInfo/index")), - e: common_assets._imports_1$1, - f: common_assets._imports_2, - g: common_vendor.o(($event) => navTo("/pages/addCard/index")), - h: common_assets._imports_0$2, - i: isShareCard.value + a: cardInfo.value.headImg + }, cardInfo.value.headImg ? { + b: cardInfo.value.headImg + } : { + c: common_assets._imports_0$2 + }, { + 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 ? { - j: common_vendor.t(cardInfo.value.waterCardNumber) + l: common_vendor.t(cardInfo.value.waterCardNumber) } : {}, { - k: !isShareCard.value + m: !isShareCard.value }, !isShareCard.value ? common_vendor.e({ - l: isVip.value + n: isVip.value }, isVip.value ? { - m: common_assets._imports_4 + o: common_assets._imports_4 } : {}, { - n: isLoss.value && isVip.value + p: 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 ? {} : {}, { - r: !isVip.value - }, !isVip.value ? {} : {}, { - s: isVip.value }, isVip.value ? { - t: common_vendor.t(cardInfo.value.balance) + 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.o(($event) => navTo("/pages/recharge/index")) + w: common_vendor.t(cardInfo.value.balance) + } : {}, { + x: isVip.value + }, isVip.value ? { + y: 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) => { + 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: item.bgColor, @@ -243,14 +278,14 @@ e: index }; }), - F: common_assets._imports_8, - G: common_vendor.o(upGrade), - H: common_assets._imports_9, - I: common_assets._imports_10, - J: common_vendor.o(($event) => navTo("/pages/station/index")), - K: common_assets._imports_11, - L: common_assets._imports_10, - M: common_vendor.o(upGrade) + 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) }); }; } -- Gitblit v1.9.3