爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

360 lines
12 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
  4. const common_assets = require("../../common/assets.js");
  5. const _sfc_main = {
  6. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  7. data() {
  8. return {
  9. value: 2,
  10. currentTab: 1,
  11. login_status: false,
  12. userInfo: {},
  13. orderTabs: [
  14. { name: "全部" },
  15. { name: "进行中", badge: "2" },
  16. { name: "已完成" }
  17. ],
  18. functionList: [
  19. // { name: '推广官', icon: '/static/my/promote.png' },
  20. { name: "我的地址", icon: "/static/my/地址.png" },
  21. { name: "联系客服", icon: "/static/my/客服.png" },
  22. { name: "修改信息", icon: "/static/my/修改信息.png" },
  23. { name: "退出登录", icon: "/static/my/退出登录.png" }
  24. ],
  25. orderList: [],
  26. totalOrders: 0
  27. // 添加累计回收单数字段
  28. };
  29. },
  30. methods: {
  31. async onRefresh() {
  32. common_vendor.index.__f__("log", "at pages/component/my.vue:249", "开始刷新");
  33. try {
  34. await this.fetchUserInfo();
  35. common_vendor.index.__f__("log", "at pages/component/my.vue:252", "刷新完成");
  36. return true;
  37. } catch (error) {
  38. common_vendor.index.__f__("error", "at pages/component/my.vue:255", "刷新失败", error);
  39. throw error;
  40. }
  41. },
  42. changeTo(e) {
  43. this.value = e;
  44. common_vendor.index.__f__("log", "at pages/component/my.vue:261", e, "111");
  45. if (e == 0) {
  46. common_vendor.index.reLaunch({
  47. url: "/pages/component/home"
  48. });
  49. } else if (e == 1) {
  50. common_vendor.index.reLaunch({
  51. url: "/pages/component/recycle"
  52. });
  53. }
  54. },
  55. goWithdraw() {
  56. common_vendor.index.navigateTo({
  57. url: "/pages/subcomponent/wallet"
  58. });
  59. },
  60. viewAllOrders() {
  61. common_vendor.index.navigateTo({
  62. url: "/pages/subcomponent/order"
  63. });
  64. },
  65. switchTab(index) {
  66. this.currentTab = index;
  67. this.fetchOrderList();
  68. },
  69. handleFunction(index) {
  70. const pages = [
  71. // '/pages/subcomponent/promotion',
  72. "/pages/subcomponent/select",
  73. "/pages/subcomponent/admin_faq",
  74. "/pages/subcomponent/edit_profile",
  75. "logout"
  76. ];
  77. if (pages[index] === "logout") {
  78. common_vendor.index.showModal({
  79. title: "提示",
  80. content: "确定要退出登录吗?",
  81. success: (res) => {
  82. if (res.confirm) {
  83. getApp().globalData.login_status = false;
  84. common_vendor.index.__f__("log", "at pages/component/my.vue:302", getApp().globalData.login_status);
  85. this.login_status = false;
  86. common_vendor.index.removeStorageSync("token");
  87. }
  88. }
  89. });
  90. return;
  91. }
  92. common_vendor.index.navigateTo({
  93. url: pages[index]
  94. });
  95. },
  96. logout() {
  97. common_vendor.index.reLaunch({
  98. url: "/pages/index/index"
  99. });
  100. },
  101. onShareCommission() {
  102. common_vendor.index.showToast({ title: "分享赚佣金", icon: "none" });
  103. common_vendor.index.navigateTo({ url: "/pages/subcomponent/promotion" });
  104. },
  105. goOrderManage() {
  106. common_vendor.index.navigateTo({ url: "/pages/manager/order" });
  107. },
  108. goAppletUserManage() {
  109. common_vendor.index.navigateTo({ url: "/pages/manager/user" });
  110. },
  111. goStaffManage() {
  112. common_vendor.index.navigateTo({ url: "/pages/manager/staff" });
  113. },
  114. goTuiManage() {
  115. common_vendor.index.navigateTo({ url: "/pages/manager/tui" });
  116. },
  117. fetchUserInfo() {
  118. if (common_vendor.index.getStorageSync("token")) {
  119. this.login_status = getApp().globalData.login_status;
  120. this.$api("getUserByToken", {}, (res) => {
  121. if (res.code == 200) {
  122. this.userInfo = res.result;
  123. }
  124. });
  125. } else {
  126. this.login_status = false;
  127. }
  128. },
  129. fetchOrderList() {
  130. let status = "";
  131. if (this.currentTab === 1)
  132. status = 1;
  133. if (this.currentTab === 2)
  134. status = 3;
  135. const params = { pageSize: 1, current: 1 };
  136. if (status !== "")
  137. params.status = status;
  138. this.$api && this.$api("getOrderListPage", params, (res) => {
  139. if (res && res.code === 200 && res.result && Array.isArray(res.result.records)) {
  140. this.orderList = res.result.records;
  141. } else {
  142. this.orderList = [];
  143. }
  144. });
  145. },
  146. getTotalOrders() {
  147. this.$api && this.$api("getOrderListPage", {}, (res) => {
  148. if (res && res.code === 200 && res.result && Array.isArray(res.result.records)) {
  149. this.totalOrders = res.result.total || 0;
  150. } else {
  151. this.totalOrders = 0;
  152. }
  153. });
  154. }
  155. },
  156. computed: {
  157. customStyle() {
  158. return {
  159. // height: '80rpx',
  160. width: "70%"
  161. };
  162. },
  163. bannerList() {
  164. return getApp().globalData.bannerList || [];
  165. }
  166. },
  167. onLoad() {
  168. common_vendor.index.$on("refreshUserInfo", () => {
  169. this.fetchUserInfo();
  170. });
  171. this.fetchUserInfo();
  172. this.fetchOrderList();
  173. this.getTotalOrders();
  174. common_vendor.index.$on("bannerListUpdated", () => {
  175. this.$forceUpdate && this.$forceUpdate();
  176. });
  177. if (getApp().globalData.bannerList && getApp().globalData.bannerList.length > 0) {
  178. this.$forceUpdate && this.$forceUpdate();
  179. }
  180. },
  181. onShow() {
  182. this.fetchUserInfo();
  183. this.getTotalOrders();
  184. },
  185. onPullDownRefresh() {
  186. this.fetchUserInfo();
  187. this.getTotalOrders();
  188. setTimeout(() => {
  189. common_vendor.index.stopPullDownRefresh();
  190. common_vendor.index.showToast({
  191. title: "刷新成功",
  192. icon: "success",
  193. duration: 2e3
  194. });
  195. }, 1e3);
  196. },
  197. onUnload() {
  198. common_vendor.index.$off("bannerListUpdated");
  199. }
  200. };
  201. if (!Array) {
  202. const _easycom_uv_button2 = common_vendor.resolveComponent("uv-button");
  203. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  204. const _easycom_uv_tabbar_item2 = common_vendor.resolveComponent("uv-tabbar-item");
  205. const _easycom_uv_tabbar2 = common_vendor.resolveComponent("uv-tabbar");
  206. (_easycom_uv_button2 + _easycom_uni_icons2 + _easycom_uv_tabbar_item2 + _easycom_uv_tabbar2)();
  207. }
  208. const _easycom_uv_button = () => "../../uni_modules/uv-button/components/uv-button/uv-button.js";
  209. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  210. const _easycom_uv_tabbar_item = () => "../../uni_modules/uv-tabbar/components/uv-tabbar-item/uv-tabbar-item.js";
  211. const _easycom_uv_tabbar = () => "../../uni_modules/uv-tabbar/components/uv-tabbar/uv-tabbar.js";
  212. if (!Math) {
  213. (_easycom_uv_button + _easycom_uni_icons + _easycom_uv_tabbar_item + _easycom_uv_tabbar)();
  214. }
  215. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  216. return common_vendor.e({
  217. a: common_vendor.f($options.bannerList, (item, index, i0) => {
  218. return {
  219. a: item.image,
  220. b: item.id || index
  221. };
  222. }),
  223. b: !$data.login_status
  224. }, !$data.login_status ? {
  225. c: common_assets._imports_0$2
  226. } : {}, {
  227. d: !$data.login_status
  228. }, !$data.login_status ? {
  229. e: common_vendor.o($options.logout),
  230. f: common_vendor.p({
  231. type: "primary",
  232. text: "立即登录",
  233. ["custom-style"]: $options.customStyle,
  234. color: "linear-gradient(to right, rgb(255, 190, 61), rgb(255, 171, 2))",
  235. shape: "circle"
  236. })
  237. } : {}, {
  238. g: $data.login_status
  239. }, $data.login_status ? {
  240. h: $data.userInfo.headImage,
  241. i: common_vendor.t($data.userInfo.nickName),
  242. j: common_vendor.t($data.userInfo.intentioCode),
  243. k: common_vendor.t($data.userInfo.money),
  244. l: common_vendor.p({
  245. type: "right",
  246. size: "10",
  247. color: "#df8155"
  248. }),
  249. m: common_vendor.o((...args) => $options.goWithdraw && $options.goWithdraw(...args)),
  250. n: common_vendor.t($data.totalOrders)
  251. } : {}, {
  252. o: $data.login_status
  253. }, $data.login_status ? {
  254. p: common_vendor.o((...args) => $options.onShareCommission && $options.onShareCommission(...args))
  255. } : {}, {
  256. q: $data.login_status
  257. }, $data.login_status ? {
  258. r: common_vendor.f($data.orderTabs, (tab, index, i0) => {
  259. return {
  260. a: common_vendor.t(tab.name),
  261. b: index,
  262. c: $data.currentTab === index ? 1 : "",
  263. d: common_vendor.o(($event) => $options.switchTab(index), index)
  264. };
  265. }),
  266. s: common_vendor.o(() => {
  267. }),
  268. t: common_vendor.f($data.orderList, (order, k0, i0) => {
  269. return {
  270. a: common_vendor.t(order.ordeNo),
  271. b: order.image || "/static/回收/衣物.png",
  272. c: common_vendor.t(order.num || 1),
  273. d: common_vendor.t(order.onePrice || 0),
  274. e: common_vendor.t(order.price),
  275. f: common_vendor.t(order.status === 0 ? "【在线预约】" : order.status === 1 ? "【快递上门】" : order.status === 2 ? "【透明质检】" : order.status === 3 ? "【现金打款】" : ""),
  276. g: common_vendor.t(order.goTime),
  277. h: order.id
  278. };
  279. }),
  280. v: common_vendor.o((...args) => $options.viewAllOrders && $options.viewAllOrders(...args))
  281. } : {}, {
  282. w: $data.login_status && ($data.userInfo.isOrderRole === "Y" || $data.userInfo.isAppletUserRole === "Y" || $data.userInfo.isUserRole === "Y" || $data.userInfo.isTuiRole === "Y")
  283. }, $data.login_status && ($data.userInfo.isOrderRole === "Y" || $data.userInfo.isAppletUserRole === "Y" || $data.userInfo.isUserRole === "Y" || $data.userInfo.isTuiRole === "Y") ? common_vendor.e({
  284. x: $data.userInfo.isOrderRole === "Y"
  285. }, $data.userInfo.isOrderRole === "Y" ? {
  286. y: common_assets._imports_1$1,
  287. z: common_vendor.p({
  288. type: "right",
  289. size: "15"
  290. }),
  291. A: common_vendor.o((...args) => $options.goOrderManage && $options.goOrderManage(...args))
  292. } : {}, {
  293. B: $data.userInfo.isAppletUserRole === "Y"
  294. }, $data.userInfo.isAppletUserRole === "Y" ? {
  295. C: common_assets._imports_2$1,
  296. D: common_vendor.p({
  297. type: "right",
  298. size: "15"
  299. }),
  300. E: common_vendor.o((...args) => $options.goAppletUserManage && $options.goAppletUserManage(...args))
  301. } : {}, {
  302. F: $data.userInfo.isUserRole === "Y"
  303. }, $data.userInfo.isUserRole === "Y" ? {
  304. G: common_assets._imports_3,
  305. H: common_vendor.p({
  306. type: "right",
  307. size: "15"
  308. }),
  309. I: common_vendor.o((...args) => $options.goStaffManage && $options.goStaffManage(...args))
  310. } : {}, {
  311. J: $data.userInfo.isTuiRole === "Y"
  312. }, $data.userInfo.isTuiRole === "Y" ? {
  313. K: common_assets._imports_4,
  314. L: common_vendor.p({
  315. type: "right",
  316. size: "15"
  317. }),
  318. M: common_vendor.o((...args) => $options.goTuiManage && $options.goTuiManage(...args))
  319. } : {}) : {}, {
  320. N: $data.login_status
  321. }, $data.login_status ? {
  322. O: common_vendor.f($data.functionList, (item, index, i0) => {
  323. return {
  324. a: item.icon,
  325. b: common_vendor.t(item.name),
  326. c: "6cb840e8-6-" + i0,
  327. d: index,
  328. e: common_vendor.o(($event) => $options.handleFunction(index), index)
  329. };
  330. }),
  331. P: common_vendor.p({
  332. type: "right",
  333. size: "15"
  334. })
  335. } : {}, {
  336. Q: common_assets._imports_5,
  337. R: common_assets._imports_6,
  338. S: common_vendor.p({
  339. text: "首页"
  340. }),
  341. T: common_assets._imports_7,
  342. U: common_assets._imports_8,
  343. V: common_vendor.p({
  344. text: "回收"
  345. }),
  346. W: common_assets._imports_9,
  347. X: common_assets._imports_10,
  348. Y: common_vendor.p({
  349. text: "我的"
  350. }),
  351. Z: common_vendor.o($options.changeTo),
  352. aa: common_vendor.p({
  353. value: $data.value,
  354. fixed: true
  355. })
  356. });
  357. }
  358. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6cb840e8"]]);
  359. wx.createPage(MiniProgramPage);
  360. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/component/my.js.map