爱简收旧衣按件回收前端代码仓库
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.

336 lines
11 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
  4. const _sfc_main = {
  5. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  6. data() {
  7. return {
  8. statusBarHeight: 0,
  9. navBarContentHeight: 44,
  10. tabBarHeight: 48,
  11. navBarHeight: 44,
  12. navBarRealHeight: 44,
  13. tabs: [
  14. { label: "全部", value: -1 },
  15. { label: "已预约", value: 0 },
  16. { label: "待质检", value: 1 },
  17. { label: "已结款", value: 2 },
  18. { label: "已驳回", value: 3 }
  19. ],
  20. currentTab: 0,
  21. orderList: [],
  22. searchMode: false,
  23. searchText: "",
  24. historyOrderMode: false,
  25. pageNum: 1,
  26. pageSize: 10,
  27. hasMore: true,
  28. isLoading: false,
  29. userId: ""
  30. };
  31. },
  32. onLoad(options) {
  33. const sys = common_vendor.index.getSystemInfoSync();
  34. this.statusBarHeight = sys.statusBarHeight;
  35. this.$nextTick(() => {
  36. common_vendor.index.createSelectorQuery().select(".nav-bar").boundingClientRect((rect) => {
  37. if (rect) {
  38. this.navBarRealHeight = rect.height;
  39. }
  40. }).exec();
  41. });
  42. if (options && options.historyOrder) {
  43. this.historyOrderMode = true;
  44. }
  45. if (options && options.userId) {
  46. this.userId = options.userId;
  47. }
  48. this.fetchOrderList();
  49. },
  50. computed: {
  51. filteredOrders() {
  52. if (this.searchText) {
  53. const text = this.searchText.toLowerCase();
  54. return this.orderList.filter(
  55. (order) => order.orderNo && order.orderNo.toLowerCase().includes(text) || order.userName && order.userName.toLowerCase().includes(text) || order.phone && order.phone.toLowerCase().includes(text)
  56. );
  57. }
  58. const tabValue = this.tabs[this.currentTab].value;
  59. if (tabValue === -1)
  60. return this.orderList;
  61. if (tabValue === 0) {
  62. return this.orderList.filter((order) => order.status == 1);
  63. } else if (tabValue === 1) {
  64. return this.orderList.filter((order) => order.status == 2);
  65. } else if (tabValue === 2) {
  66. return this.orderList.filter((order) => order.status == 3);
  67. } else if (tabValue === 3) {
  68. return this.orderList.filter((order) => order.status == 4);
  69. }
  70. return this.orderList;
  71. }
  72. },
  73. methods: {
  74. goBack() {
  75. common_vendor.index.navigateBack();
  76. },
  77. onTabChange(idx) {
  78. this.currentTab = idx;
  79. this.pageNum = 1;
  80. this.hasMore = true;
  81. this.orderList = [];
  82. this.fetchOrderList();
  83. },
  84. onSearchIconClick() {
  85. this.searchMode = true;
  86. this.$nextTick(() => {
  87. this.$refs.searchInput && this.$refs.searchInput.focus();
  88. });
  89. },
  90. onClearSearch() {
  91. this.searchText = "";
  92. },
  93. onCancelSearch() {
  94. this.searchText = "";
  95. this.searchMode = false;
  96. },
  97. goToOrderDetail(order) {
  98. common_vendor.index.navigateTo({
  99. url: "/pages/manager/order-detail?id=" + order.id
  100. });
  101. },
  102. refreshData() {
  103. },
  104. async onRefresh() {
  105. await this.refreshData && this.refreshData();
  106. },
  107. fetchOrderList(isLoadMore = false) {
  108. if (this.isLoading || !isLoadMore && !this.hasMore)
  109. return;
  110. this.isLoading = true;
  111. const params = {
  112. pageNum: this.pageNum,
  113. pageSize: this.pageSize
  114. };
  115. if (this.userId) {
  116. params.userId = this.userId;
  117. }
  118. this.$api && this.$api("getOrderList", params, (res) => {
  119. if (res && res.code === 200 && res.result && res.result.records) {
  120. const newOrders = res.result.records.map((order) => {
  121. const statusInfo = this.getOrderStatusInfo(order.status, order.state);
  122. return {
  123. id: order.id,
  124. orderNo: order.ordeNo,
  125. userName: order.name,
  126. phone: order.phone,
  127. appointTime: order.goTime,
  128. cancelTime: order.state === 3 ? order.updateTime : "",
  129. qualityTime: order.status === 2 && order.state === 1 ? order.updateTime : "",
  130. statusText: order.isBy === "Y" ? statusInfo.label : "不包邮",
  131. statusClass: statusInfo.class,
  132. statusLabel: statusInfo.label,
  133. actions: this.getOrderActions(order.status, order.state),
  134. status: this.getOrderStatus(order.status, order.state)
  135. };
  136. });
  137. if (isLoadMore) {
  138. this.orderList = [...this.orderList, ...newOrders];
  139. } else {
  140. this.orderList = newOrders;
  141. }
  142. this.hasMore = newOrders.length === this.pageSize;
  143. this.pageNum = isLoadMore ? this.pageNum + 1 : 1;
  144. }
  145. this.isLoading = false;
  146. });
  147. },
  148. getOrderStatusInfo(status, state) {
  149. if (status === 1) {
  150. return { label: "已预约", class: "green" };
  151. } else if (state === 1) {
  152. return { label: "待质检", class: "orange" };
  153. } else if (status === 3) {
  154. return { label: "已结款", class: "blue" };
  155. } else if (status === 1 && state === 3) {
  156. return { label: "已驳回", class: "red" };
  157. }
  158. return { label: "未知状态", class: "gray" };
  159. },
  160. getOrderStatus(status, state) {
  161. if (status === 1)
  162. return 1;
  163. if (state === 1)
  164. return 2;
  165. if (status === 3)
  166. return 3;
  167. if (status === 1 && state === 3)
  168. return 4;
  169. return -1;
  170. },
  171. getOrderActions(status, state) {
  172. const actions = [];
  173. if (status === 2 && state === 1) {
  174. actions.push({ icon: "undo", text: "驳回" });
  175. actions.push({ icon: "person", text: "审批" });
  176. }
  177. return actions;
  178. },
  179. onLoadMore() {
  180. if (this.hasMore && !this.isLoading) {
  181. this.fetchOrderList(true);
  182. }
  183. },
  184. scanCode() {
  185. common_vendor.index.scanCode({
  186. scanType: ["qrCode"],
  187. success: (res) => {
  188. common_vendor.index.__f__("log", "at pages/manager/order.vue:330", "扫码结果:", res);
  189. if (res.result) {
  190. common_vendor.index.navigateTo({
  191. url: "/pages/manager/order-detail?id=" + res.result
  192. });
  193. }
  194. },
  195. fail: (err) => {
  196. common_vendor.index.__f__("error", "at pages/manager/order.vue:340", "扫码失败:", err);
  197. common_vendor.index.showToast({
  198. title: "扫码失败",
  199. icon: "none"
  200. });
  201. }
  202. });
  203. }
  204. },
  205. onPullDownRefresh() {
  206. this.pageNum = 1;
  207. this.hasMore = true;
  208. this.orderList = [];
  209. this.fetchOrderList();
  210. common_vendor.index.stopPullDownRefresh();
  211. },
  212. onReachBottom() {
  213. this.onLoadMore();
  214. }
  215. };
  216. if (!Array) {
  217. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  218. _easycom_uni_icons2();
  219. }
  220. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  221. if (!Math) {
  222. _easycom_uni_icons();
  223. }
  224. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  225. return common_vendor.e({
  226. a: common_vendor.o($options.goBack),
  227. b: common_vendor.p({
  228. type: "left",
  229. size: "24",
  230. color: "#222"
  231. }),
  232. c: common_vendor.t($data.historyOrderMode ? "历史订单" : "订单管理"),
  233. d: $data.statusBarHeight + "px",
  234. e: $data.statusBarHeight + $data.navBarContentHeight + "px",
  235. f: !$data.historyOrderMode
  236. }, !$data.historyOrderMode ? {
  237. g: common_vendor.f($data.tabs, (tab, idx, i0) => {
  238. return {
  239. a: common_vendor.t(tab.label),
  240. b: tab.value,
  241. c: common_vendor.n({
  242. active: $data.currentTab === idx
  243. }),
  244. d: common_vendor.o(($event) => $options.onTabChange(idx), tab.value)
  245. };
  246. }),
  247. h: $data.tabs.length * 20 + "%",
  248. i: $data.navBarRealHeight + "px",
  249. j: $data.tabBarHeight + "px"
  250. } : {}, {
  251. k: !$data.historyOrderMode
  252. }, !$data.historyOrderMode ? common_vendor.e({
  253. l: !$data.searchMode
  254. }, !$data.searchMode ? {
  255. m: common_vendor.o($options.onSearchIconClick),
  256. n: common_vendor.p({
  257. type: "search",
  258. size: "22",
  259. color: "#999"
  260. }),
  261. o: common_vendor.o($options.scanCode),
  262. p: common_vendor.p({
  263. type: "scan",
  264. size: "22",
  265. color: "#999"
  266. })
  267. } : common_vendor.e({
  268. q: common_vendor.p({
  269. type: "search",
  270. size: "22",
  271. color: "#999"
  272. }),
  273. r: $data.searchText,
  274. s: common_vendor.o(($event) => $data.searchText = $event.detail.value),
  275. t: $data.searchText
  276. }, $data.searchText ? {
  277. v: common_vendor.o($options.onClearSearch),
  278. w: common_vendor.p({
  279. type: "close",
  280. size: "22",
  281. color: "#ccc"
  282. })
  283. } : {}, {
  284. x: common_vendor.o((...args) => $options.onCancelSearch && $options.onCancelSearch(...args))
  285. }), {
  286. y: $data.navBarRealHeight + $data.tabBarHeight + "px"
  287. }) : {}, {
  288. z: common_vendor.f($options.filteredOrders, (order, k0, i0) => {
  289. return common_vendor.e({
  290. a: common_vendor.t(order.orderNo),
  291. b: order.statusText === "不包邮"
  292. }, order.statusText === "不包邮" ? {
  293. c: common_vendor.t(order.statusText)
  294. } : {}, {
  295. d: common_vendor.t(order.userName),
  296. e: common_vendor.t(order.phone),
  297. f: order.appointTime
  298. }, order.appointTime ? {
  299. g: common_vendor.t(order.appointTime)
  300. } : {}, {
  301. h: order.cancelTime
  302. }, order.cancelTime ? {
  303. i: common_vendor.t(order.cancelTime)
  304. } : {}, {
  305. j: order.qualityTime
  306. }, order.qualityTime ? {
  307. k: common_vendor.t(order.qualityTime)
  308. } : {}, {
  309. l: common_vendor.t(order.statusLabel),
  310. m: common_vendor.n(order.statusClass),
  311. n: order.actions && order.actions.length && !$data.historyOrderMode
  312. }, order.actions && order.actions.length && !$data.historyOrderMode ? {
  313. o: common_vendor.f(order.actions, (action, k1, i1) => {
  314. return {
  315. a: "33a4a1f0-5-" + i0 + "-" + i1,
  316. b: common_vendor.p({
  317. type: action.icon,
  318. size: "28",
  319. color: "#666"
  320. }),
  321. c: common_vendor.t(action.text),
  322. d: action.text,
  323. e: common_vendor.o(($event) => action.text === "审批" ? $options.goToOrderDetail(order) : null, action.text)
  324. };
  325. })
  326. } : {}, {
  327. p: order.id,
  328. q: common_vendor.o(($event) => $options.goToOrderDetail(order), order.id)
  329. });
  330. }),
  331. A: $data.navBarRealHeight + ($data.historyOrderMode ? 0 : $data.tabBarHeight + 16 + 40) + "px"
  332. });
  333. }
  334. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-33a4a1f0"]]);
  335. wx.createPage(MiniProgramPage);
  336. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/manager/order.js.map