"use strict"; const common_vendor = require("../../common/vendor.js"); const api_services_connect = require("../../api/services/connect.js"); const utils_storage = require("../../utils/storage.js"); const _sfc_main = { data() { return { plotInfo: { total: 3, active: 2, idle: 1 }, serviceList: [ { name: "农资商城", iconText: "商", path: "/pages/service/mall" }, { name: "农产品销售", iconText: "售", path: "/pages/service/sales" }, { name: "在线专家问诊", iconText: "诊", path: "/pages/service/expert" }, { name: "绿色认证申请", iconText: "证", path: "/pages/service/certification" }, { name: "保险接入", iconText: "保", path: "/pages/service/insurance" } ], userInfo: { nickName: "游客", id: "", avatar: "/static/images/icon.png" }, isLogin: false }; }, onShow() { this.checkLoginStatus(); }, methods: { refresh() { api_services_connect.refresh().then((res) => { console.log("请求成功。未执行属性token", res); }); }, // 检查登录状态 checkLoginStatus() { console.log("执行Show"); if (utils_storage.storage.getHasLogin()) { this.isLogin = true; const userInfo = utils_storage.storage.getUserInfo(); console.log("执行Show", userInfo); if (userInfo) { this.userInfo = userInfo; } } else { this.isLogin = false; } }, navigateToLogin() { common_vendor.index.navigateTo({ url: "/pages/login/index" }); }, navigateToPlots() { common_vendor.index.navigateTo({ url: "/pages/plots/list" }); }, navigateToService(item) { common_vendor.index.navigateTo({ url: item.path }); }, handleContact() { common_vendor.index.makePhoneCall({ phoneNumber: "400-xxx-xxxx" // 替换为实际的客服电话 }); }, navigateToAbout() { common_vendor.index.navigateTo({ url: "/pages/about/index" }); }, navigateToSettings() { common_vendor.index.navigateTo({ url: "/pages/settings/index" }); }, // 使用授权服务处理登出 handleLogout() { common_vendor.index.showModal({ title: "提示", content: "确认退出登录?", success: (res) => { if (res.confirm) { api_services_connect.logout().then(() => { this.isLogin = false; this.userInfo = { nickname: "游客", id: "", avatar: "/static/images/icon.png" }; }); } } }); } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: $data.userInfo.avatar || "/static/images/default-avatar.png", b: $data.isLogin }, $data.isLogin ? { c: common_vendor.t($data.userInfo.nickName), d: common_vendor.t($data.userInfo.sex == "0" ? "男" : "女") } : { e: common_vendor.o((...args) => $options.navigateToLogin && $options.navigateToLogin(...args)) }, { f: common_vendor.o((...args) => $options.navigateToPlots && $options.navigateToPlots(...args)), g: common_vendor.o((...args) => $options.refresh && $options.refresh(...args)), h: common_vendor.t($data.plotInfo.total), i: common_vendor.t($data.plotInfo.active), j: common_vendor.t($data.plotInfo.idle), k: common_vendor.f($data.serviceList, (item, index, i0) => { return { a: common_vendor.t(item.iconText), b: common_vendor.t(item.name), c: index, d: common_vendor.o(($event) => $options.navigateToService(item), index) }; }), l: common_vendor.o((...args) => $options.handleContact && $options.handleContact(...args)), m: common_vendor.o((...args) => $options.navigateToAbout && $options.navigateToAbout(...args)), n: common_vendor.o((...args) => $options.navigateToSettings && $options.navigateToSettings(...args)), o: this.isLogin }, this.isLogin ? { p: common_vendor.o((...args) => $options.handleLogout && $options.handleLogout(...args)) } : {}); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage);