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

367 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 _sfc_main = {
  5. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  6. data() {
  7. return {
  8. orderId: "",
  9. currentStep: 1,
  10. // 当前进行到第几步
  11. processSteps: [],
  12. address: "",
  13. appointmentTime: "",
  14. estimatePrice: "",
  15. finalPrice: "",
  16. clothesList: [],
  17. currentStatus: {
  18. text: "",
  19. time: "",
  20. icon: ""
  21. },
  22. phone: "",
  23. hasReport: false,
  24. reportTime: "",
  25. showEditButton: true,
  26. expressCompany: "",
  27. expressNo: "",
  28. showCancelModal: false,
  29. statusBarHeight: 0,
  30. orderDetail: null
  31. };
  32. },
  33. computed: {
  34. timeLabel() {
  35. if (this.currentStep === 4) {
  36. return "回收到账时间";
  37. } else if (this.currentStep === 3) {
  38. return "质检完成时间";
  39. } else {
  40. return "上门时间";
  41. }
  42. },
  43. showEstimate() {
  44. return this.currentStep < 3;
  45. }
  46. },
  47. methods: {
  48. async onRefresh() {
  49. await new Promise((resolve) => setTimeout(resolve, 1e3));
  50. common_vendor.index.stopPullRefresh();
  51. },
  52. goBack() {
  53. getApp().globalData.shouldClearRecycle = true;
  54. common_vendor.index.navigateBack();
  55. },
  56. showMore() {
  57. },
  58. onShare() {
  59. },
  60. viewAddress() {
  61. },
  62. viewReport() {
  63. if (this.currentStatus.text.includes("已结款")) {
  64. common_vendor.index.navigateTo({
  65. url: "/pages/component/inspection?status=qualified"
  66. });
  67. } else {
  68. common_vendor.index.navigateTo({
  69. url: "/pages/component/inspection?status=unqualified"
  70. });
  71. }
  72. },
  73. editOrder() {
  74. },
  75. // 更新订单状态
  76. updateOrderStatus(status) {
  77. switch (status) {
  78. case "cancelled":
  79. this.currentStep = 0;
  80. this.currentStatus = {
  81. text: "已取消",
  82. time: "",
  83. icon: "/static/my/【待取件】快递员正在赶来.png"
  84. };
  85. this.showEditButton = false;
  86. break;
  87. case "processing":
  88. this.currentStep = 2;
  89. this.currentStatus = {
  90. text: "【待取件】快递员正在赶来",
  91. time: "2025-04-20 11:00~13:00",
  92. icon: "/static/my/【待取件】快递员正在赶来.png"
  93. };
  94. break;
  95. case "collected":
  96. this.currentStep = 2;
  97. this.currentStatus = {
  98. text: "【已取件】快递员正在送至质检",
  99. time: "2025-04-30 11:42",
  100. icon: "/static/my/【上门中】快递员正在赶来.png"
  101. };
  102. this.showEditButton = false;
  103. break;
  104. case "inspecting":
  105. this.currentStep = 3;
  106. this.currentStatus = {
  107. text: "【质检中】质检员正在质检",
  108. time: "2025-04-20 11:00",
  109. icon: "/static/my/逐件验-配图.png"
  110. };
  111. this.showEditButton = false;
  112. break;
  113. case "pending_payment":
  114. this.currentStep = 4;
  115. this.currentStatus = {
  116. text: "【待结款】待平台确认结款项",
  117. time: "2025-04-20 12:00",
  118. icon: "/static/my/【已结款】平台已结款至账户.png"
  119. };
  120. this.hasReport = true;
  121. this.reportTime = "2025-03-20 11:40";
  122. this.showEditButton = false;
  123. break;
  124. case "completed":
  125. this.currentStep = 4;
  126. this.currentStatus = {
  127. text: "【已结款】平台已结款至账户",
  128. time: "2025-04-20 12:01",
  129. icon: "/static/my/【已结款】平台已结款至账户.png"
  130. };
  131. this.hasReport = true;
  132. this.reportTime = "2025-03-20 11:40";
  133. this.showEditButton = false;
  134. break;
  135. }
  136. },
  137. copyExpressNo() {
  138. common_vendor.index.setClipboardData({
  139. data: this.expressCompany + this.expressNo,
  140. success: () => {
  141. common_vendor.index.showToast({ title: "已复制", icon: "none" });
  142. }
  143. });
  144. },
  145. confirmCancelOrder() {
  146. this.showCancelModal = false;
  147. this.currentStep = 0;
  148. this.currentStatus = {
  149. text: "已取消",
  150. time: this.getNowTime(),
  151. icon: "/static/【待取件】快递员正在赶来.png"
  152. };
  153. },
  154. getNowTime() {
  155. const now = /* @__PURE__ */ new Date();
  156. const y = now.getFullYear();
  157. const m = (now.getMonth() + 1).toString().padStart(2, "0");
  158. const d = now.getDate().toString().padStart(2, "0");
  159. const h = now.getHours().toString().padStart(2, "0");
  160. const min = now.getMinutes().toString().padStart(2, "0");
  161. return `${y}-${m}-${d} ${h}:${min}`;
  162. },
  163. contactCourier() {
  164. if (this.phone) {
  165. common_vendor.index.makePhoneCall({
  166. phoneNumber: this.phone
  167. //仅为示例
  168. });
  169. } else {
  170. common_vendor.index.showToast({ title: "暂无快递员电话", icon: "none" });
  171. }
  172. },
  173. fetchOrderDetail(orderId) {
  174. this.$api && this.$api("getOrderDetail", { orderId }, (res) => {
  175. if (res && res.code === 200 && res.result) {
  176. this.orderDetail = res.result;
  177. this.address = res.result.address + (res.result.addressDetail || "");
  178. this.appointmentTime = res.result.goTime || "";
  179. this.estimatePrice = res.result.price || "";
  180. this.finalPrice = res.result.price || "";
  181. this.clothesList = res.result.commonOrderList || [];
  182. this.expressCompany = res.result.wliu || "";
  183. this.expressNo = res.result.expressNo || "";
  184. this.phone = res.result.phone || "";
  185. this.setOrderStatus(res.result.status, res.result.state, res.result);
  186. }
  187. });
  188. },
  189. setOrderStatus(status, state, data) {
  190. if (state == 3) {
  191. this.currentStep = 0;
  192. this.currentStatus = {
  193. text: "已取消",
  194. time: "",
  195. icon: "/static/【待取件】快递员正在赶来.png"
  196. };
  197. this.showEditButton = false;
  198. return;
  199. }
  200. if (status == 0) {
  201. this.currentStep = 1;
  202. this.currentStatus = {
  203. text: "【在线预约】",
  204. time: data.goTime || "",
  205. icon: "/static/home/① 在线预约.png"
  206. };
  207. } else if (status == 1 && state == 0) {
  208. this.currentStep = 2;
  209. this.currentStatus = {
  210. text: "【待取件】快递员正在赶来",
  211. time: data.goTime || "",
  212. icon: "/static/my/【待取件】快递员正在赶来.png"
  213. };
  214. } else if (status == 1 && state == 1) {
  215. this.currentStep = 2;
  216. this.currentStatus = {
  217. text: "【已取件】快递员正在送至质检",
  218. time: data.goTime || "",
  219. icon: "/static/my/【上门中】快递员正在赶来.png"
  220. };
  221. } else if (status == 2 && state == 1) {
  222. this.currentStep = 3;
  223. this.currentStatus = {
  224. text: "【质检中】质检员正在质检",
  225. time: data.goTime || "",
  226. icon: "/static/my/逐件验-配图.png"
  227. };
  228. } else if (status == 3 && state == 1) {
  229. this.currentStep = 4;
  230. this.currentStatus = {
  231. text: "【待结款】待平台确认结款项",
  232. time: data.goTime || "",
  233. icon: "/static/my/【已结款】平台已结款至账户.png"
  234. };
  235. this.hasReport = true;
  236. this.reportTime = data.updateTime || "";
  237. } else if (status == 3 && state == 2) {
  238. this.currentStep = 4;
  239. this.currentStatus = {
  240. text: "【已结款】平台已结款至账户",
  241. time: data.goTime || "",
  242. icon: "/static/my/【已结款】平台已结款至账户.png"
  243. };
  244. this.hasReport = true;
  245. this.reportTime = data.updateTime || "";
  246. }
  247. },
  248. getAreaList() {
  249. this.$api("getAreaList", {}, (res) => {
  250. common_vendor.index.__f__("log", "at pages/subcomponent/detail.vue:435", res, "getAreaList");
  251. if (res.code == 200 && Array.isArray(res.result)) {
  252. const sorted = res.result.slice().sort((a, b) => a.sort - b.sort);
  253. this.processSteps = sorted.map((item) => ({
  254. // id: item.id,
  255. icon: item.image,
  256. text: item.title
  257. }));
  258. }
  259. });
  260. }
  261. },
  262. onLoad(options) {
  263. if (options.id) {
  264. this.orderId = options.id;
  265. this.fetchOrderDetail(options.id);
  266. }
  267. this.statusBarHeight = common_vendor.index.getSystemInfoSync().statusBarHeight;
  268. this.getAreaList();
  269. },
  270. onShow() {
  271. this.getAreaList();
  272. }
  273. };
  274. if (!Array) {
  275. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  276. _easycom_uni_icons2();
  277. }
  278. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  279. if (!Math) {
  280. _easycom_uni_icons();
  281. }
  282. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  283. return common_vendor.e({
  284. a: common_vendor.p({
  285. type: "left",
  286. size: "20"
  287. }),
  288. b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
  289. c: common_vendor.t($data.orderDetail && $data.orderDetail.ordeNo ? $data.orderDetail.ordeNo : $data.orderId),
  290. d: common_vendor.f($data.processSteps, (step, index, i0) => {
  291. return {
  292. a: step.icon,
  293. b: common_vendor.t(step.text),
  294. c: $data.currentStep === index + 1 ? 1 : "",
  295. d: $data.currentStep === 0 && index === 1 ? 1 : "",
  296. e: index,
  297. f: $data.currentStep === 0 && index === 1 ? 1 : ""
  298. };
  299. }),
  300. e: $data.currentStatus
  301. }, $data.currentStatus ? common_vendor.e({
  302. f: $data.currentStatus.icon,
  303. g: $data.currentStep === 0
  304. }, $data.currentStep === 0 ? {} : {
  305. h: common_vendor.t($data.currentStatus.text)
  306. }, {
  307. i: common_vendor.t($data.currentStatus.time)
  308. }) : {}, {
  309. j: $data.currentStep === 0
  310. }, $data.currentStep === 0 ? {} : {}, {
  311. k: $data.currentStep !== 0 && $data.currentStep < 3
  312. }, $data.currentStep !== 0 && $data.currentStep < 3 ? {
  313. l: common_vendor.t($data.expressCompany),
  314. m: common_vendor.t($data.expressNo),
  315. n: common_vendor.o((...args) => $options.copyExpressNo && $options.copyExpressNo(...args))
  316. } : {}, {
  317. o: $data.currentStep !== 0 && $data.currentStep < 4
  318. }, $data.currentStep !== 0 && $data.currentStep < 4 ? {} : {}, {
  319. p: $data.currentStep !== 0 && $data.currentStep < 4
  320. }, $data.currentStep !== 0 && $data.currentStep < 4 ? {
  321. q: common_vendor.t($data.address),
  322. r: common_vendor.o((...args) => $options.viewAddress && $options.viewAddress(...args)),
  323. s: common_vendor.t($options.timeLabel),
  324. t: common_vendor.t($data.appointmentTime)
  325. } : {}, {
  326. v: common_vendor.t($data.orderDetail && $data.orderDetail.ordeNo ? $data.orderDetail.ordeNo : $data.orderId),
  327. w: $data.currentStep < 3
  328. }, $data.currentStep < 3 ? {
  329. x: common_vendor.t($data.estimatePrice)
  330. } : $data.currentStep === 4 ? {
  331. z: common_vendor.t($data.finalPrice),
  332. A: common_vendor.t($data.finalPrice)
  333. } : {}, {
  334. y: $data.currentStep === 4,
  335. B: common_vendor.f($data.clothesList, (item, index, i0) => {
  336. return {
  337. a: item.image,
  338. b: common_vendor.t(item.name),
  339. c: common_vendor.t(item.details),
  340. d: common_vendor.t(item.onePrice),
  341. e: common_vendor.t(item.num),
  342. f: common_vendor.t(item.price),
  343. g: index
  344. };
  345. }),
  346. C: $data.currentStep === 4
  347. }, $data.currentStep === 4 ? {
  348. D: common_vendor.o((...args) => $options.viewReport && $options.viewReport(...args))
  349. } : {}, {
  350. E: $data.currentStep === 4
  351. }, $data.currentStep === 4 ? {
  352. F: common_vendor.t($data.address)
  353. } : {}, {
  354. G: $data.currentStatus.text === "【待取件】快递员正在赶来"
  355. }, $data.currentStatus.text === "【待取件】快递员正在赶来" ? {
  356. H: common_vendor.o(($event) => $data.showCancelModal = true),
  357. I: common_vendor.o((...args) => $options.contactCourier && $options.contactCourier(...args))
  358. } : {}, {
  359. J: $data.showCancelModal
  360. }, $data.showCancelModal ? {
  361. K: common_vendor.o(($event) => $data.showCancelModal = false),
  362. L: common_vendor.o((...args) => $options.confirmCancelOrder && $options.confirmCancelOrder(...args))
  363. } : {});
  364. }
  365. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3c6ff866"]]);
  366. wx.createPage(MiniProgramPage);
  367. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/detail.js.map