合同小程序前端代码仓库
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.

99 lines
3.5 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = common_vendor.defineComponent({
  4. data() {
  5. return {
  6. searchKey: "",
  7. activeTab: "全部",
  8. tabs: ["全部", "已生效", "已失效"],
  9. orders: [
  10. /* 从接口获取的数据 */
  11. ]
  12. };
  13. },
  14. computed: {
  15. // 过滤后的订单列表
  16. filteredOrders() {
  17. return this.orders.filter((order) => {
  18. const matchStatus = this.activeTab === "全部" || order.status === this.activeTab;
  19. const matchSearch = order.customerName.includes(this.searchKey) || order.phone.includes(this.searchKey);
  20. return matchStatus && matchSearch;
  21. });
  22. }
  23. },
  24. methods: {
  25. // 搜索处理
  26. handleSearch() {
  27. common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:78", "搜索关键词:", this.searchKey);
  28. },
  29. // 复制订单号
  30. copyOrderNo(orderNo = null) {
  31. common_vendor.index.setClipboardData({
  32. data: orderNo,
  33. success: () => {
  34. common_vendor.index.showToast({ title: "复制成功" });
  35. }
  36. });
  37. },
  38. // PDF下载
  39. downloadPDF(order = null) {
  40. return common_vendor.__awaiter(this, void 0, void 0, function* () {
  41. common_vendor.index.showLoading({ title: "下载中..." });
  42. try {
  43. const tempFilePath = (yield common_vendor.index.downloadFile({
  44. url: "https://your-api.com/download",
  45. header: new UTSJSONObject({ "order-id": order.id })
  46. })).tempFilePath;
  47. yield common_vendor.index.saveFile({
  48. tempFilePath,
  49. success: (res) => {
  50. common_vendor.index.showToast({ title: "下载成功" });
  51. common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:107", "文件路径:", res.savedFilePath);
  52. }
  53. });
  54. common_vendor.index.openDocument({
  55. filePath: tempFilePath,
  56. showMenu: true
  57. });
  58. } catch (err) {
  59. common_vendor.index.showToast({ title: "下载失败", icon: "none" });
  60. } finally {
  61. common_vendor.index.hideLoading();
  62. }
  63. });
  64. }
  65. }
  66. });
  67. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  68. return {
  69. a: $data.searchKey,
  70. b: common_vendor.o(($event) => $data.searchKey = $event.detail.value),
  71. c: common_vendor.o((...args) => $options.handleSearch && $options.handleSearch(...args)),
  72. d: common_vendor.f($data.tabs, (tab, k0, i0) => {
  73. return {
  74. a: common_vendor.t(tab),
  75. b: tab,
  76. c: common_vendor.n($data.activeTab === tab ? "active" : ""),
  77. d: common_vendor.o(($event) => $data.activeTab = tab, tab)
  78. };
  79. }),
  80. e: common_vendor.f($options.filteredOrders, (order, index, i0) => {
  81. return {
  82. a: common_vendor.t(order.orderNo),
  83. b: common_vendor.o(($event) => $options.copyOrderNo(order.orderNo), index),
  84. c: common_vendor.t(order.customerName),
  85. d: common_vendor.t(order.phone),
  86. e: common_vendor.t(order.serviceName),
  87. f: common_vendor.t(order.orderTime),
  88. g: common_vendor.t(order.salesman),
  89. h: common_vendor.t(order.store),
  90. i: common_vendor.o(($event) => $options.downloadPDF(order), index),
  91. j: index
  92. };
  93. }),
  94. f: common_vendor.sei(_ctx.virtualHostId, "view")
  95. };
  96. }
  97. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6e742b06"]]);
  98. wx.createPage(MiniProgramPage);
  99. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/dingdan.js.map