index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. common_vendor.index.showToast({ title: e || "加载客服电话失败", icon: "none" });
  48. }
  49. },
  50. async loadCustomerInfo() {
  51. try {
  52. const res = await api_system_customer.getMyInfo();
  53. this.customerInfo = res.data;
  54. } catch (e) {
  55. common_vendor.index.__f__("error", "at pages/mine/index.vue:143", "[mine] 加载客户信息失败", e);
  56. common_vendor.index.showToast({ title: e || "加载客户信息失败", icon: "none" });
  57. }
  58. },
  59. goToLogin() {
  60. common_vendor.index.reLaunch({ url: "/pages/login/index" });
  61. },
  62. // 跳转至设置页面
  63. goToSettings() {
  64. if (this.isLogin) {
  65. common_vendor.index.navigateTo({
  66. url: "/pages/mine/settings/index"
  67. });
  68. }
  69. },
  70. // 新增:跳转至订单列表
  71. goToOrderList(status) {
  72. if (!this.isLogin) {
  73. return this.goToLogin();
  74. }
  75. common_vendor.index.navigateTo({
  76. url: `/pages/order/list/index?tab=${status}`
  77. });
  78. },
  79. handleLogout() {
  80. common_vendor.index.showModal({
  81. title: "退出提示",
  82. content: "确认退出当前账号吗?",
  83. confirmColor: "#C1001C",
  84. success: async (res) => {
  85. if (res.confirm) {
  86. try {
  87. await api_auth_index.logout();
  88. } catch (e) {
  89. common_vendor.index.__f__("error", "at pages/mine/index.vue:177", "[mine] 退出登录接口失败", e);
  90. common_vendor.index.showToast({ title: e || "退出失败", icon: "none" });
  91. }
  92. common_vendor.index.removeStorageSync("token");
  93. common_vendor.index.removeStorageSync("isLogin");
  94. this.isLogin = false;
  95. common_vendor.index.reLaunch({ url: "/pages/login/index" });
  96. }
  97. }
  98. });
  99. },
  100. // 新增:菜单点击处理
  101. handleMenuClick(menu) {
  102. if (menu.id === "agreement") {
  103. common_vendor.index.navigateTo({ url: "/pages/mine/agreement/index" });
  104. } else if (menu.id === "privacy") {
  105. common_vendor.index.navigateTo({ url: "/pages/mine/privacy/index" });
  106. } else if (menu.id === "complaint") {
  107. common_vendor.index.navigateTo({ url: "/pages/mine/complaint/index" });
  108. } else if (menu.id === "service") {
  109. common_vendor.index.showModal({
  110. title: "联系客服",
  111. content: "客服电话:" + this.servicePhone,
  112. confirmText: "立即拨打",
  113. confirmColor: "#C1001C",
  114. cancelColor: "#999999",
  115. success: (res) => {
  116. if (res.confirm) {
  117. common_vendor.index.makePhoneCall({
  118. phoneNumber: this.servicePhone
  119. });
  120. }
  121. }
  122. });
  123. }
  124. }
  125. }
  126. };
  127. if (!Array) {
  128. const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar");
  129. const _component_erp_tab_bar = common_vendor.resolveComponent("erp-tab-bar");
  130. (_component_erp_nav_bar + _component_erp_tab_bar)();
  131. }
  132. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  133. return common_vendor.e({
  134. a: common_vendor.p({
  135. title: "个人中心",
  136. ["show-back"]: false,
  137. ["bg-color"]: "#C1001C",
  138. ["title-color"]: "#ffffff"
  139. }),
  140. b: $data.isLogin
  141. }, $data.isLogin ? common_vendor.e({
  142. c: $data.customerInfo && $data.customerInfo.avatarUrl ? $data.customerInfo.avatarUrl : "https://img.icons8.com/color/144/user.png",
  143. d: common_vendor.t($data.customerInfo ? $data.customerInfo.userName : ""),
  144. e: $data.customerInfo
  145. }, $data.customerInfo ? {
  146. f: common_vendor.t($data.customerInfo.authClientName || "无")
  147. } : {}, {
  148. g: common_vendor.t($data.customerInfo ? $data.customerInfo.phone : ""),
  149. h: $data.assets.mineSettings,
  150. i: common_vendor.o((...args) => $options.goToSettings && $options.goToSettings(...args), "d5")
  151. }) : {
  152. j: $data.assets.mineArrow,
  153. k: common_vendor.o((...args) => $options.goToLogin && $options.goToLogin(...args), "f2")
  154. }, {
  155. l: $data.assets.mineArrow,
  156. m: common_vendor.o(($event) => $options.goToOrderList(0), "96"),
  157. n: common_vendor.f($data.orderStates, (item, index, i0) => {
  158. return {
  159. a: item.icon,
  160. b: common_vendor.t(item.label),
  161. c: index,
  162. d: common_vendor.o(($event) => $options.goToOrderList(item.tabIndex), index)
  163. };
  164. }),
  165. o: common_vendor.f($data.menuList, (menu, index, i0) => {
  166. return {
  167. a: menu.icon,
  168. b: common_vendor.t(menu.label),
  169. c: index,
  170. d: common_vendor.o(($event) => $options.handleMenuClick(menu), index)
  171. };
  172. }),
  173. p: $data.assets.mineArrow,
  174. q: $data.isLogin
  175. }, $data.isLogin ? {
  176. r: common_vendor.o((...args) => $options.handleLogout && $options.handleLogout(...args), "b3")
  177. } : {}, {
  178. s: common_vendor.p({
  179. active: "mine"
  180. })
  181. });
  182. }
  183. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-569e925a"]]);
  184. wx.createPage(MiniProgramPage);
  185. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/index.js.map