index.js 6.6 KB

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