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

206 lines
7.2 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const api = require("../../api.js");
  4. const common_assets = require("../../common/assets.js");
  5. const _sfc_main = common_vendor.defineComponent({
  6. data() {
  7. return {
  8. params: new UTSJSONObject({
  9. pageNo: 1,
  10. pageSize: 10,
  11. status: ""
  12. }),
  13. firstFocus: false,
  14. searchKey: "",
  15. activeTab: "全部",
  16. tabs: ["全部", "已生效", "已失效"],
  17. orders: [
  18. /* 从接口获取的数据 */
  19. ]
  20. };
  21. },
  22. mounted() {
  23. api.isToken();
  24. api.list(new UTSJSONObject({ pageNo: 1, pageSize: 10 })).then((res = null) => {
  25. for (var index = 0; index < res.result.records.length; index++) {
  26. this.orders.push(res.result.records[index]);
  27. }
  28. });
  29. },
  30. computed: {
  31. filteredOrders() {
  32. return this.orders.filter((item) => {
  33. return item.custName.includes(this.searchKey) || item.custPhone.includes(this.searchKey);
  34. });
  35. }
  36. },
  37. methods: {
  38. scrolltolower() {
  39. this.params.pageNo++;
  40. common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:97", "pageNo", this.params.pageNo);
  41. common_vendor.index.showLoading({
  42. title: "刷新中.."
  43. });
  44. api.list(this.params).then((res = null) => {
  45. let orders = res.result.records;
  46. for (var index = 0; index < orders.length; index++) {
  47. this.orders.push(orders[index]);
  48. }
  49. common_vendor.index.hideLoading();
  50. });
  51. },
  52. changeStatus(status = null) {
  53. common_vendor.index.showLoading();
  54. this.activeTab = status;
  55. if (status == "已生效") {
  56. this.orders.splice(0);
  57. this.params.status = 0;
  58. this.params.pageNo = 1;
  59. api.list(this.params).then((res = null) => {
  60. let orders = res.result.records;
  61. for (var index = 0; index < orders.length; index++) {
  62. this.orders.push(orders[index]);
  63. }
  64. common_vendor.index.hideLoading();
  65. });
  66. } else if (status == "已失效") {
  67. this.orders.splice(0);
  68. this.params.status = 1;
  69. this.params.pageNo = 1;
  70. api.list(this.params).then((res = null) => {
  71. for (var index = 0; index < res.result.records.length; index++) {
  72. this.orders.push(res.result.records[index]);
  73. }
  74. });
  75. common_vendor.index.hideLoading();
  76. } else {
  77. this.params.status = "";
  78. this.params.pageNo = 1;
  79. api.list(this.params).then((res = null) => {
  80. common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:138", res.result);
  81. this.orders.splice(0);
  82. for (var index = 0; index < res.result.records.length; index++) {
  83. this.orders.push(res.result.records[index]);
  84. }
  85. common_vendor.index.hideLoading();
  86. });
  87. }
  88. },
  89. // 回退
  90. toBack() {
  91. let canNavBack = getCurrentPages();
  92. if (canNavBack && canNavBack.length > 1) {
  93. common_vendor.index.navigateBack();
  94. } else {
  95. history.back();
  96. }
  97. },
  98. // 搜索处理
  99. handleSearch() {
  100. common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:159", "搜索关键词:", this.searchKey);
  101. },
  102. // 复制订单号
  103. copyorderNum(orderNum = null) {
  104. common_vendor.index.setClipboardData({
  105. data: orderNum,
  106. success: () => {
  107. common_vendor.index.showToast({ title: "复制成功" });
  108. }
  109. });
  110. },
  111. // PDF下载
  112. downloadPDF(order = null) {
  113. return common_vendor.__awaiter(this, void 0, void 0, function* () {
  114. common_vendor.index.showLoading({ title: "下载中..." });
  115. try {
  116. const tempFilePath = (yield common_vendor.index.downloadFile({
  117. url: "https://your-api.com/download",
  118. header: new UTSJSONObject({ "order-id": order.id })
  119. })).tempFilePath;
  120. yield common_vendor.index.saveFile({
  121. tempFilePath,
  122. success: (res) => {
  123. common_vendor.index.showToast({ title: "下载成功" });
  124. common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:188", "文件路径:", res.savedFilePath);
  125. }
  126. });
  127. common_vendor.index.openDocument({
  128. filePath: tempFilePath,
  129. showMenu: true
  130. });
  131. } catch (err) {
  132. common_vendor.index.showToast({ title: "下载失败", icon: "none" });
  133. } finally {
  134. common_vendor.index.hideLoading();
  135. }
  136. });
  137. }
  138. }
  139. });
  140. if (!Array) {
  141. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  142. const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  143. (_easycom_uni_icons2 + _easycom_uni_easyinput2)();
  144. }
  145. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  146. const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
  147. if (!Math) {
  148. (_easycom_uni_icons + _easycom_uni_easyinput)();
  149. }
  150. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  151. return {
  152. a: common_vendor.p({
  153. type: "left",
  154. size: "30",
  155. color: "#c2d4de"
  156. }),
  157. b: common_vendor.o((...args) => $options.toBack && $options.toBack(...args)),
  158. c: common_vendor.p({
  159. type: "search",
  160. size: 20
  161. }),
  162. d: common_vendor.o(($event) => $data.searchKey = $event),
  163. e: common_vendor.p({
  164. inputBorder: false,
  165. placeholder: "请输入客户姓名/客户手机号",
  166. focus: $data.firstFocus,
  167. modelValue: $data.searchKey
  168. }),
  169. f: common_vendor.o((...args) => $options.handleSearch && $options.handleSearch(...args)),
  170. g: common_vendor.f($data.tabs, (tab, k0, i0) => {
  171. return {
  172. a: common_vendor.t(tab),
  173. b: tab,
  174. c: common_vendor.n($data.activeTab === tab ? "active" : ""),
  175. d: common_vendor.o(($event) => $options.changeStatus(tab), tab)
  176. };
  177. }),
  178. h: common_vendor.f($options.filteredOrders, (order, index, i0) => {
  179. return common_vendor.e({
  180. a: common_vendor.t(order.orderNum),
  181. b: common_vendor.o(($event) => $options.copyorderNum(order.orderNum), index),
  182. c: common_vendor.t(order.custName),
  183. d: common_vendor.t(order.custPhone),
  184. e: common_vendor.t(order.productName),
  185. f: common_vendor.t(order.createTime),
  186. g: common_vendor.t(order.saleName),
  187. h: common_vendor.t(order.storeName),
  188. i: common_vendor.o(($event) => $options.downloadPDF(order), index),
  189. j: order.status == 0 ? true : false
  190. }, (order.status == 0 ? true : false) ? {
  191. k: common_assets._imports_0$3
  192. } : {}, {
  193. l: order.status == 0 ? false : true
  194. }, (order.status == 0 ? false : true) ? {
  195. m: common_assets._imports_1$2
  196. } : {}, {
  197. n: index
  198. });
  199. }),
  200. i: common_vendor.sei(_ctx.virtualHostId, "scroll-view"),
  201. j: common_vendor.o((...args) => $options.scrolltolower && $options.scrolltolower(...args))
  202. };
  203. }
  204. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6e742b06"]]);
  205. wx.createPage(MiniProgramPage);
  206. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/dingdan.js.map