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

402 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. // 状态标签配置
  9. statusTabs: [
  10. { label: "全部", value: "all" },
  11. { label: "已预约", value: "appointed" },
  12. { label: "待质检", value: "pending" },
  13. { label: "待结款", value: "waiting" },
  14. { label: "已驳回", value: "rejected" }
  15. ],
  16. currentStatus: "all",
  17. selectedTime: "",
  18. searchActive: false,
  19. searchKey: "",
  20. showTimePickerModal: false,
  21. timePickerStyle: {
  22. top: 0
  23. },
  24. activeTimeType: "start",
  25. startDate: {
  26. year: "",
  27. month: "",
  28. day: ""
  29. },
  30. endDate: {
  31. year: "",
  32. month: "",
  33. day: ""
  34. },
  35. orderList: [
  36. {
  37. orderId: "RE827381278615224",
  38. userName: "周小艺",
  39. phone: "138****1234",
  40. time: "周四 11:00~13:00",
  41. status: "appointed"
  42. },
  43. {
  44. orderId: "RE827381278615226",
  45. userName: "周小艺",
  46. phone: "138****1234",
  47. time: "2025-03-20 11:00",
  48. status: "pending"
  49. },
  50. {
  51. orderId: "RE827381278615225",
  52. userName: "周小艺",
  53. phone: "138****1234",
  54. time: "2025-03-20 12:00",
  55. status: "rejected"
  56. },
  57. {
  58. orderId: "RE827381278615226",
  59. userName: "周小艺",
  60. phone: "138****1234",
  61. time: "2025-03-20 12:00",
  62. status: "waiting"
  63. }
  64. ],
  65. currentDateIndexes: [0, 0, 0],
  66. // 当前选中的年月日索引
  67. // 添加时间范围
  68. timeRange: {
  69. start: "",
  70. end: ""
  71. }
  72. };
  73. },
  74. computed: {
  75. // 年份选项
  76. yearOptions() {
  77. const years = [];
  78. const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
  79. for (let i = 0; i < 6; i++) {
  80. years.push(currentYear + i);
  81. }
  82. return years;
  83. },
  84. // 月份选项
  85. monthOptions() {
  86. return Array.from({ length: 12 }, (_, i) => i + 1);
  87. },
  88. // 日期选项
  89. dayOptions() {
  90. return Array.from({ length: 31 }, (_, i) => i + 1);
  91. },
  92. // 过滤后的订单列表
  93. filteredOrders() {
  94. let result = this.orderList;
  95. if (this.searchKey) {
  96. const keyword = this.searchKey.toLowerCase();
  97. result = result.filter((order) => {
  98. return order.orderId.toLowerCase().includes(keyword) || order.userName.toLowerCase().includes(keyword);
  99. });
  100. }
  101. if (this.currentStatus !== "all") {
  102. result = result.filter((order) => order.status === this.currentStatus);
  103. }
  104. if (this.timeRange.start && this.timeRange.end) {
  105. const startTime = new Date(this.timeRange.start).getTime();
  106. const endTime = new Date(this.timeRange.end).getTime();
  107. result = result.filter((order) => {
  108. const orderTime = this.parseOrderTime(order.time);
  109. return orderTime >= startTime && orderTime <= endTime;
  110. });
  111. }
  112. return result;
  113. }
  114. },
  115. methods: {
  116. async onRefresh() {
  117. await new Promise((resolve) => setTimeout(resolve, 1e3));
  118. common_vendor.index.stopPullRefresh();
  119. },
  120. navigateBack() {
  121. common_vendor.index.navigateBack();
  122. },
  123. // 切换状态
  124. switchStatus(status) {
  125. this.currentStatus = status;
  126. },
  127. // 显示时间选择器
  128. showTimePicker() {
  129. const query = common_vendor.index.createSelectorQuery().in(this);
  130. query.select(".filter-item").boundingClientRect((rect) => {
  131. if (rect) {
  132. this.timePickerStyle = {
  133. top: rect.bottom
  134. };
  135. }
  136. this.showTimePickerModal = true;
  137. this.activeTimeType = "start";
  138. }).exec();
  139. },
  140. // 关闭时间选择器
  141. closeTimePicker() {
  142. this.showTimePickerModal = false;
  143. },
  144. // 切换时间类型
  145. switchTimeType(type) {
  146. this.activeTimeType = type;
  147. const target = type === "start" ? this.startDate : this.endDate;
  148. this.currentDateIndexes = [
  149. this.yearOptions.indexOf(target.year) || 0,
  150. this.monthOptions.indexOf(target.month) || 0,
  151. this.dayOptions.indexOf(target.day) || 0
  152. ];
  153. },
  154. // 处理选择器变化
  155. handlePickerChange(e) {
  156. const values = e.detail.value;
  157. const target = this.activeTimeType === "start" ? this.startDate : this.endDate;
  158. target.year = this.yearOptions[values[0]];
  159. target.month = this.monthOptions[values[1]];
  160. target.day = this.dayOptions[values[2]];
  161. this.currentDateIndexes = values;
  162. },
  163. // 重置时间选择
  164. resetTimePicker() {
  165. this.startDate = {
  166. year: "",
  167. month: "",
  168. day: ""
  169. };
  170. this.endDate = {
  171. year: "",
  172. month: "",
  173. day: ""
  174. };
  175. this.currentDateIndexes = [0, 0, 0];
  176. this.activeTimeType = "start";
  177. this.timeRange = {
  178. start: "",
  179. end: ""
  180. };
  181. this.selectedTime = "";
  182. },
  183. // 确认时间选择
  184. confirmTimePicker() {
  185. if (!this.startDate.year || !this.startDate.month || !this.startDate.day) {
  186. common_vendor.index.showToast({
  187. title: "请选择完整的开始时间",
  188. icon: "none"
  189. });
  190. return;
  191. }
  192. if (!this.endDate.year || !this.endDate.month || !this.endDate.day) {
  193. common_vendor.index.showToast({
  194. title: "请选择完整的结束时间",
  195. icon: "none"
  196. });
  197. return;
  198. }
  199. const startTime = new Date(this.startDate.year, this.startDate.month - 1, this.startDate.day);
  200. const endTime = new Date(this.endDate.year, this.endDate.month - 1, this.endDate.day);
  201. if (startTime > endTime) {
  202. common_vendor.index.showToast({
  203. title: "开始时间不能大于结束时间",
  204. icon: "none"
  205. });
  206. return;
  207. }
  208. const start = `${this.startDate.year}${this.startDate.month}${this.startDate.day}`;
  209. const end = `${this.endDate.year}${this.endDate.month}${this.endDate.day}`;
  210. this.selectedTime = `${start} - ${end}`;
  211. this.timeRange = {
  212. start: `${this.startDate.year}-${this.startDate.month}-${this.startDate.day}`,
  213. end: `${this.endDate.year}-${this.endDate.month}-${this.endDate.day}`
  214. };
  215. this.showTimePickerModal = false;
  216. },
  217. // 搜索处理
  218. handleSearch() {
  219. },
  220. // 加载更多
  221. loadMore() {
  222. },
  223. // 获取状态文本
  224. getStatusText(status) {
  225. const statusMap = {
  226. appointed: "已预约",
  227. pending: "待质检",
  228. waiting: "待结款",
  229. rejected: "已驳回"
  230. };
  231. return statusMap[status] || status;
  232. },
  233. // 处理驳回
  234. handleReject(order) {
  235. common_vendor.index.showModal({
  236. title: "提示",
  237. content: "确定要驳回该订单吗?",
  238. success: (res) => {
  239. if (res.confirm)
  240. ;
  241. }
  242. });
  243. },
  244. // 处理审批
  245. handleApprove(order) {
  246. common_vendor.index.showModal({
  247. title: "提示",
  248. content: "确定要审批通过该订单吗?",
  249. success: (res) => {
  250. if (res.confirm)
  251. ;
  252. }
  253. });
  254. },
  255. // 解析订单时间字符串为时间戳
  256. parseOrderTime(timeStr) {
  257. if (timeStr.includes("周")) {
  258. return (/* @__PURE__ */ new Date()).getTime();
  259. }
  260. return new Date(timeStr).getTime();
  261. }
  262. }
  263. };
  264. if (!Array) {
  265. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  266. _easycom_uni_icons2();
  267. }
  268. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  269. if (!Math) {
  270. _easycom_uni_icons();
  271. }
  272. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  273. return common_vendor.e({
  274. a: common_vendor.p({
  275. type: "left",
  276. size: "20"
  277. }),
  278. b: common_vendor.o((...args) => $options.navigateBack && $options.navigateBack(...args)),
  279. c: common_vendor.f($data.statusTabs, (tab, index, i0) => {
  280. return {
  281. a: common_vendor.t(tab.label),
  282. b: index,
  283. c: $data.currentStatus === tab.value ? 1 : "",
  284. d: common_vendor.o(($event) => $options.switchStatus(tab.value), index)
  285. };
  286. }),
  287. d: common_vendor.t($data.selectedTime || "处理时间"),
  288. e: $data.showTimePickerModal || $data.selectedTime ? 1 : "",
  289. f: common_vendor.p({
  290. type: $data.showTimePickerModal ? "up" : "down",
  291. size: "14",
  292. color: $data.showTimePickerModal || $data.selectedTime ? "#00C853" : "#666"
  293. }),
  294. g: common_vendor.o((...args) => $options.showTimePicker && $options.showTimePicker(...args)),
  295. h: $data.searchActive
  296. }, $data.searchActive ? common_vendor.e({
  297. i: common_vendor.p({
  298. type: "search",
  299. size: "16",
  300. color: "#999"
  301. }),
  302. j: $data.searchKey,
  303. k: common_vendor.o(($event) => $data.searchKey = $event.detail.value),
  304. l: $data.searchKey
  305. }, $data.searchKey ? {
  306. m: common_vendor.o(($event) => $data.searchKey = ""),
  307. n: common_vendor.p({
  308. type: "clear",
  309. size: "16",
  310. color: "#bbb"
  311. })
  312. } : {}, {
  313. o: common_vendor.o(($event) => {
  314. $data.searchActive = false;
  315. $data.searchKey = "";
  316. }),
  317. p: $data.searchActive ? 1 : ""
  318. }) : {
  319. q: common_vendor.p({
  320. type: "search",
  321. size: "20",
  322. color: "#999"
  323. }),
  324. r: common_vendor.o(($event) => $data.searchActive = true)
  325. }, {
  326. s: $data.showTimePickerModal
  327. }, $data.showTimePickerModal ? common_vendor.e({
  328. t: $data.activeTimeType === "start"
  329. }, $data.activeTimeType === "start" ? {} : {}, {
  330. v: $data.activeTimeType === "start" ? 1 : "",
  331. w: common_vendor.o(($event) => $options.switchTimeType("start")),
  332. x: $data.activeTimeType === "end"
  333. }, $data.activeTimeType === "end" ? {} : {}, {
  334. y: $data.activeTimeType === "end" ? 1 : "",
  335. z: common_vendor.o(($event) => $options.switchTimeType("end")),
  336. A: common_vendor.f($options.yearOptions, (year, k0, i0) => {
  337. return {
  338. a: common_vendor.t(year),
  339. b: year
  340. };
  341. }),
  342. B: common_vendor.f($options.monthOptions, (month, k0, i0) => {
  343. return {
  344. a: common_vendor.t(month),
  345. b: month
  346. };
  347. }),
  348. C: common_vendor.f($options.dayOptions, (day, k0, i0) => {
  349. return {
  350. a: common_vendor.t(day),
  351. b: day
  352. };
  353. }),
  354. D: $data.currentDateIndexes,
  355. E: common_vendor.o((...args) => $options.handlePickerChange && $options.handlePickerChange(...args)),
  356. F: common_vendor.o((...args) => $options.resetTimePicker && $options.resetTimePicker(...args)),
  357. G: common_vendor.o((...args) => $options.confirmTimePicker && $options.confirmTimePicker(...args)),
  358. H: $data.timePickerStyle.top + "px",
  359. I: common_vendor.o(() => {
  360. }),
  361. J: common_vendor.o((...args) => $options.closeTimePicker && $options.closeTimePicker(...args)),
  362. K: common_vendor.o(() => {
  363. })
  364. }) : {}, {
  365. L: common_vendor.f($options.filteredOrders, (order, index, i0) => {
  366. return common_vendor.e({
  367. a: common_vendor.t(order.orderId),
  368. b: common_vendor.t($options.getStatusText(order.status)),
  369. c: common_vendor.n(order.status),
  370. d: common_vendor.t(order.userName),
  371. e: common_vendor.t(order.phone),
  372. f: common_vendor.t(order.status === "appointed" ? "预约时间:" : "取件时间:"),
  373. g: common_vendor.t(order.time),
  374. h: order.status === "pending"
  375. }, order.status === "pending" ? {
  376. i: "b419a402-5-" + i0,
  377. j: common_vendor.p({
  378. type: "undo",
  379. size: "16",
  380. color: "#666"
  381. }),
  382. k: common_vendor.o(($event) => $options.handleReject(order), index)
  383. } : {}, {
  384. l: order.status === "pending"
  385. }, order.status === "pending" ? {
  386. m: "b419a402-6-" + i0,
  387. n: common_vendor.p({
  388. type: "checkmarkempty",
  389. size: "16",
  390. color: "#00C853"
  391. }),
  392. o: common_vendor.o(($event) => $options.handleApprove(order), index)
  393. } : {}, {
  394. p: index
  395. });
  396. }),
  397. M: common_vendor.o((...args) => $options.loadMore && $options.loadMore(...args))
  398. });
  399. }
  400. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-b419a402"]]);
  401. wx.createPage(MiniProgramPage);
  402. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/orders.js.map