index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_assets = require("../../utils/assets.js");
  4. const api_system_customer = require("../../api/system/customer.js");
  5. const api_auth_index = require("../../api/auth/index.js");
  6. const ErpTabBar = () => "../../components/erp-tab-bar.js";
  7. const ErpNavBar = () => "../../components/erp-nav-bar.js";
  8. const _sfc_main = {
  9. components: { ErpTabBar, ErpNavBar },
  10. data() {
  11. return {
  12. assets: utils_assets.assets,
  13. isLogin: false,
  14. customerInfo: null,
  15. orderStates: [
  16. { label: "待审核", icon: utils_assets.assets.minePendingReview },
  17. { label: "待签批", icon: utils_assets.assets.minePendingSign },
  18. { label: "生产中", icon: utils_assets.assets.mineProducing },
  19. { label: "已完成", icon: utils_assets.assets.mineCompleted }
  20. ],
  21. menuList: [
  22. { label: "用户协议", icon: utils_assets.assets.mineProtocol, id: "agreement" },
  23. { label: "隐私政策", icon: utils_assets.assets.minePrivacy, id: "privacy" },
  24. { label: "投诉与建议", icon: utils_assets.assets.mineComplaint, id: "complaint" },
  25. { label: "联系客服", icon: utils_assets.assets.mineService, id: "service" }
  26. ]
  27. };
  28. },
  29. onShow() {
  30. this.isLogin = !!common_vendor.index.getStorageSync("isLogin");
  31. if (this.isLogin) {
  32. this.loadCustomerInfo();
  33. }
  34. },
  35. methods: {
  36. async loadCustomerInfo() {
  37. try {
  38. const res = await api_system_customer.getMyInfo();
  39. this.customerInfo = res.data;
  40. } catch (e) {
  41. common_vendor.index.__f__("error", "at pages/mine/index.vue:129", "[mine] 加载客户信息失败", e);
  42. }
  43. },
  44. goToLogin() {
  45. common_vendor.index.reLaunch({ url: "/pages/login/index" });
  46. },
  47. // 跳转至设置页面
  48. goToSettings() {
  49. if (this.isLogin) {
  50. common_vendor.index.navigateTo({
  51. url: "/pages/mine/settings/index"
  52. });
  53. }
  54. },
  55. // 新增:跳转至订单列表
  56. goToOrderList(status) {
  57. if (!this.isLogin) {
  58. return this.goToLogin();
  59. }
  60. common_vendor.index.navigateTo({
  61. url: `/pages/order/list/index?tab=${status}`
  62. });
  63. },
  64. handleLogout() {
  65. common_vendor.index.showModal({
  66. title: "退出提示",
  67. content: "确认退出当前账号吗?",
  68. confirmColor: "#C1001C",
  69. success: async (res) => {
  70. if (res.confirm) {
  71. try {
  72. await api_auth_index.logout();
  73. } catch (e) {
  74. common_vendor.index.__f__("error", "at pages/mine/index.vue:162", "[mine] 退出登录接口失败", e);
  75. }
  76. common_vendor.index.removeStorageSync("token");
  77. common_vendor.index.removeStorageSync("isLogin");
  78. this.isLogin = false;
  79. common_vendor.index.reLaunch({ url: "/pages/login/index" });
  80. }
  81. }
  82. });
  83. },
  84. // 新增:菜单点击处理
  85. handleMenuClick(menu) {
  86. if (menu.id === "agreement") {
  87. common_vendor.index.navigateTo({ url: "/pages/mine/agreement/index" });
  88. } else if (menu.id === "privacy") {
  89. common_vendor.index.navigateTo({ url: "/pages/mine/privacy/index" });
  90. } else if (menu.id === "complaint") {
  91. common_vendor.index.navigateTo({ url: "/pages/mine/complaint/index" });
  92. } else if (menu.id === "service") {
  93. common_vendor.index.showModal({
  94. title: "联系客服",
  95. content: "客服电话:138-8888-8888",
  96. confirmText: "立即拨打",
  97. confirmColor: "#C1001C",
  98. cancelColor: "#999999",
  99. success: (res) => {
  100. if (res.confirm) {
  101. common_vendor.index.makePhoneCall({
  102. phoneNumber: "13888888888"
  103. });
  104. }
  105. }
  106. });
  107. }
  108. }
  109. }
  110. };
  111. if (!Array) {
  112. const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar");
  113. const _component_erp_tab_bar = common_vendor.resolveComponent("erp-tab-bar");
  114. (_component_erp_nav_bar + _component_erp_tab_bar)();
  115. }
  116. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  117. return common_vendor.e({
  118. a: common_vendor.p({
  119. title: "个人中心",
  120. ["show-back"]: false,
  121. ["bg-color"]: "#C1001C",
  122. ["title-color"]: "#ffffff"
  123. }),
  124. b: $data.isLogin
  125. }, $data.isLogin ? common_vendor.e({
  126. c: $data.customerInfo && $data.customerInfo.avatarUrl ? $data.customerInfo.avatarUrl : "https://img.icons8.com/color/144/user.png",
  127. d: common_vendor.t($data.customerInfo ? $data.customerInfo.userName : ""),
  128. e: $data.customerInfo
  129. }, $data.customerInfo ? {
  130. f: common_vendor.t($data.customerInfo.authClientName || "无")
  131. } : {}, {
  132. g: common_vendor.t($data.customerInfo ? $data.customerInfo.phone : ""),
  133. h: $data.assets.mineSettings,
  134. i: common_vendor.o((...args) => $options.goToSettings && $options.goToSettings(...args), "d5")
  135. }) : {
  136. j: $data.assets.mineArrow,
  137. k: common_vendor.o((...args) => $options.goToLogin && $options.goToLogin(...args), "f2")
  138. }, {
  139. l: $data.assets.mineArrow,
  140. m: common_vendor.o(($event) => $options.goToOrderList(0), "96"),
  141. n: common_vendor.f($data.orderStates, (item, index, i0) => {
  142. return {
  143. a: item.icon,
  144. b: common_vendor.t(item.label),
  145. c: index,
  146. d: common_vendor.o(($event) => $options.goToOrderList(index + 1), index)
  147. };
  148. }),
  149. o: common_vendor.f($data.menuList, (menu, index, i0) => {
  150. return {
  151. a: menu.icon,
  152. b: common_vendor.t(menu.label),
  153. c: index,
  154. d: common_vendor.o(($event) => $options.handleMenuClick(menu), index)
  155. };
  156. }),
  157. p: $data.assets.mineArrow,
  158. q: $data.isLogin
  159. }, $data.isLogin ? {
  160. r: common_vendor.o((...args) => $options.handleLogout && $options.handleLogout(...args), "0c")
  161. } : {}, {
  162. s: common_vendor.p({
  163. active: "mine"
  164. })
  165. });
  166. }
  167. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-569e925a"]]);
  168. wx.createPage(MiniProgramPage);
  169. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/index.js.map