index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const ErpTabBar = () => "../../components/erp-tab-bar.js";
  4. const ErpNavBar = () => "../../components/erp-nav-bar.js";
  5. const _sfc_main = {
  6. components: { ErpNavBar, ErpTabBar },
  7. data() {
  8. return {
  9. isAuthorized: false,
  10. selectedModels: []
  11. };
  12. },
  13. computed: {
  14. totalCount() {
  15. return this.selectedModels.reduce((sum, item) => sum + parseInt(item.count || 0), 0);
  16. }
  17. },
  18. onLoad() {
  19. common_vendor.index.$on("add_order_item", (data) => {
  20. this.selectedModels.push(data);
  21. common_vendor.index.showToast({ title: "添加成功", icon: "success" });
  22. });
  23. common_vendor.index.$on("update_order_item", (res) => {
  24. if (res.index > -1) {
  25. this.$set(this.selectedModels, res.index, res.data);
  26. common_vendor.index.showToast({ title: "修改成功", icon: "success" });
  27. }
  28. });
  29. },
  30. onUnload() {
  31. common_vendor.index.$off("add_order_item");
  32. common_vendor.index.$off("update_order_item");
  33. },
  34. methods: {
  35. contactAdmin() {
  36. common_vendor.index.showModal({ title: "联系管理员", content: "管理员电话:138-0000-0000", showCancel: false, confirmColor: "#C1001C" });
  37. },
  38. goToAddModel() {
  39. common_vendor.index.navigateTo({
  40. url: "/pages/order/add-model/index"
  41. });
  42. },
  43. editItem(index, item) {
  44. common_vendor.index.navigateTo({
  45. url: `/pages/order/edit-model/index?index=${index}&data=${encodeURIComponent(JSON.stringify(item))}`
  46. });
  47. },
  48. removeItem(index) {
  49. const self = this;
  50. common_vendor.index.showModal({
  51. title: "提示",
  52. content: "确定移除该型号吗?",
  53. success: (res) => {
  54. if (res.confirm) {
  55. self.selectedModels.splice(index, 1);
  56. }
  57. }
  58. });
  59. },
  60. submitFinalOrder() {
  61. if (this.selectedModels.length === 0)
  62. return;
  63. common_vendor.index.showLoading({ title: "正在提交结果", mask: true });
  64. setTimeout(() => {
  65. common_vendor.index.hideLoading();
  66. common_vendor.index.navigateTo({
  67. url: "/pages/order/success/index"
  68. });
  69. }, 1500);
  70. }
  71. }
  72. };
  73. if (!Array) {
  74. const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar");
  75. const _component_erp_tab_bar = common_vendor.resolveComponent("erp-tab-bar");
  76. (_component_erp_nav_bar + _component_erp_tab_bar)();
  77. }
  78. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  79. return common_vendor.e({
  80. a: common_vendor.p({
  81. title: "ERP 下单",
  82. ["show-back"]: false
  83. }),
  84. b: !$data.isAuthorized
  85. }, !$data.isAuthorized ? {
  86. c: common_vendor.o((...args) => $options.contactAdmin && $options.contactAdmin(...args), "1b"),
  87. d: common_vendor.o(($event) => $data.isAuthorized = true, "9e")
  88. } : common_vendor.e({
  89. e: $data.selectedModels.length > 0
  90. }, $data.selectedModels.length > 0 ? {} : {}, {
  91. f: $data.selectedModels.length > 0
  92. }, $data.selectedModels.length > 0 ? {
  93. g: common_vendor.f($data.selectedModels, (item, index, i0) => {
  94. return {
  95. a: common_vendor.o(($event) => $options.removeItem(index), index),
  96. b: common_vendor.t(item.type),
  97. c: common_vendor.t(item.count),
  98. d: common_vendor.t(item.surfaceName),
  99. e: index,
  100. f: common_vendor.o(($event) => $options.editItem(index, item), index)
  101. };
  102. })
  103. } : {
  104. h: common_vendor.o((...args) => $options.goToAddModel && $options.goToAddModel(...args), "57")
  105. }, {
  106. i: $data.selectedModels.length > 0
  107. }, $data.selectedModels.length > 0 ? {
  108. j: common_vendor.o((...args) => $options.goToAddModel && $options.goToAddModel(...args), "2d")
  109. } : {}, {
  110. k: $data.selectedModels.length > 0
  111. }, $data.selectedModels.length > 0 ? {
  112. l: common_vendor.t($data.selectedModels.length),
  113. m: common_vendor.t($options.totalCount),
  114. n: $data.selectedModels.length === 0,
  115. o: common_vendor.o((...args) => $options.submitFinalOrder && $options.submitFinalOrder(...args), "35")
  116. } : {}), {
  117. p: common_vendor.p({
  118. active: "order"
  119. })
  120. });
  121. }
  122. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-17a44f9d"]]);
  123. wx.createPage(MiniProgramPage);
  124. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/index.js.map