index.js 4.0 KB

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