From 134c7e51d33dfd0cdb9e7d47b22d181ebc1bcdc8 Mon Sep 17 00:00:00 2001 From: Liuyi <candymxq888@outlook.com> Date: 星期一, 07 十月 2024 17:27:20 +0800 Subject: [PATCH] 添加用户详情页,修改主页用户及会员卡信息 --- unpackage/dist/dev/mp-weixin/pages/index/index.js | 102 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 82 insertions(+), 20 deletions(-) diff --git a/unpackage/dist/dev/mp-weixin/pages/index/index.js b/unpackage/dist/dev/mp-weixin/pages/index/index.js index a703d33..c1219ef 100644 --- a/unpackage/dist/dev/mp-weixin/pages/index/index.js +++ b/unpackage/dist/dev/mp-weixin/pages/index/index.js @@ -1,41 +1,103 @@ "use strict"; const common_vendor = require("../../common/vendor.js"); +const common_assets = require("../../common/assets.js"); +const api_index = require("../../api/index.js"); const _sfc_main = { __name: "index", setup(__props) { - const back = () => { - common_vendor.index.navigateTo({ - url: "/pages/login/index" - }); - }; - const capsuleHeight = common_vendor.ref(0); - common_vendor.onMounted(() => { + const topHeight = common_vendor.ref(0); + function getTopHeight() { if (common_vendor.index.getMenuButtonBoundingClientRect) { - capsuleHeight.value = (common_vendor.index.getMenuButtonBoundingClientRect().top + common_vendor.index.getMenuButtonBoundingClientRect().height) * 2; + topHeight.value = common_vendor.index.getMenuButtonBoundingClientRect().top * 2; } + } + const cardInfo = common_vendor.ref({ + userName: "", + headImg: "", + waterCardNumber: "", + balance: "", + count: "", + userPhone: "" }); + const isVip = common_vendor.ref(false); + async function getInfo() { + let res = await api_index.getUserInfo(); + console.log("res", res.data); + cardInfo.value.userName = res.data.userInfo.userName; + cardInfo.value.headImg = res.data.userInfo.headImg; + cardInfo.value.userPhone = res.data.userInfo.userPhone; + if (res.data.userInfo.waterCardNumber) { + let res1 = await api_index.getVipInfoApi(); + cardInfo.value.waterCardNumber = res1.data.cardNumber; + if (res1.data.cardType == 1) { + cardInfo.value.balance = res1.data.balance; + } else if (res1.data.cardType == 2) { + cardInfo.value.count = res1.data.count; + } + isVip.value = true; + } else { + isVip.value = false; + } + common_vendor.index.setStorageSync("userInfo", JSON.stringify(cardInfo.value)); + } + function toScan() { + common_vendor.index.navigateTo({ + url: "/pages/scanWater/index" + }); + } const functionList = common_vendor.ref([ - { text: "余额", icon: "../../static/images/index/icon31.png", url: "/pages/login/index" }, - { text: "余额", icon: "../../static/images/index/icon32.png", url: "/pages/login/index" }, - { text: "余额", icon: "../../static/images/index/icon33.png", url: "/pages/login/index" }, - { text: "余额", icon: "../../static/images/index/icon34.png", url: "/pages/login/index" }, - { text: "余额", icon: "../../static/images/index/icon35.png", url: "/pages/login/index" }, - { text: "余额", icon: "../../static/images/index/icon36.png", url: "/pages/login/index" }, - { text: "余额", icon: "../../static/images/index/icon37.png", url: "/pages/login/index" }, - { text: "余额", icon: "../../static/images/index/icon38.png", url: "/pages/login/index" } + { 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: "" } ]); + function navTo(itemUrl) { + if (itemUrl) { + common_vendor.index.navigateTo({ + url: itemUrl + }); + } + } + common_vendor.onMounted(async () => { + getTopHeight(); + await getInfo(); + }); + common_vendor.onShow(async () => { + await getInfo(); + }); return (_ctx, _cache) => { return { - a: capsuleHeight.value + "rpx", - b: common_vendor.f(functionList.value, (item, index, i0) => { + a: common_assets._imports_0$1, + b: common_vendor.t(cardInfo.value.userName), + c: common_assets._imports_1, + d: common_vendor.o(($event) => navTo("/pages/userInfo/index")), + e: common_assets._imports_2, + f: common_vendor.t(cardInfo.value.waterCardNumber), + g: common_vendor.t(cardInfo.value.userPhone), + h: common_vendor.t(cardInfo.value.balance), + i: topHeight.value + "rpx", + j: common_assets._imports_3, + k: common_vendor.o(($event) => navTo("/pages/sendWater/index")), + l: common_vendor.o(($event) => navTo("/pages/recharge/index")), + m: common_assets._imports_4, + n: common_vendor.o(($event) => toScan()), + o: common_vendor.f(functionList.value, (item, index, i0) => { return { a: item.icon, b: common_vendor.t(item.text), - c: common_vendor.o(($event) => _ctx.navTo(item.url), index), + c: common_vendor.o(($event) => navTo(item.url), index), d: index }; }), - c: common_vendor.o(($event) => back()) + p: common_assets._imports_5, + q: common_assets._imports_6, + r: common_assets._imports_7, + s: common_assets._imports_8, + t: common_assets._imports_7 }; }; } -- Gitblit v1.9.3