| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const api_system_customer = require("../../api/system/customer.js");
- const api_erp_orderDetail = require("../../api/erp/orderDetail.js");
- const api_erp_order = require("../../api/erp/order.js");
- const ErpTabBar = () => "../../components/erp-tab-bar.js";
- const ErpNavBar = () => "../../components/erp-nav-bar.js";
- const _sfc_main = {
- components: { ErpNavBar, ErpTabBar },
- data() {
- return {
- isLoggedIn: false,
- isLoading: true,
- // 初始为加载中
- myInfo: {},
- selectedModels: []
- };
- },
- computed: {
- totalCount() {
- return this.selectedModels.reduce((sum, item) => sum + parseInt(item.count || 0), 0);
- }
- },
- onLoad() {
- common_vendor.index.$on("add_order_item", (data) => {
- this.loadOrderItems(false);
- });
- common_vendor.index.$on("update_order_item", (res) => {
- this.loadOrderItems(false);
- });
- },
- onShow() {
- this.checkLoginStatus();
- },
- onUnload() {
- common_vendor.index.$off("add_order_item");
- common_vendor.index.$off("update_order_item");
- },
- methods: {
- /**
- * 加载已选型号列表(OrderID 为空的草稿)
- * @Author: Antigravity
- */
- async loadOrderItems(showFullLoading = true) {
- if (showFullLoading)
- this.isLoading = true;
- try {
- const res = await api_erp_orderDetail.listOrderDetail({ fOrderId: "" });
- this.selectedModels = res.data || [];
- } catch (e) {
- common_vendor.index.__f__("error", "at pages/order/index.vue:156", "加载型号列表失败", e);
- } finally {
- this.isLoading = false;
- }
- },
- async checkLoginStatus() {
- const token = common_vendor.index.getStorageSync("token");
- if (!token) {
- this.isLoggedIn = false;
- this.myInfo = {};
- return;
- }
- try {
- const res = await api_system_customer.getMyInfo();
- this.isLoggedIn = true;
- this.myInfo = res.data || {};
- this.loadOrderItems();
- } catch (e) {
- common_vendor.index.removeStorageSync("token");
- common_vendor.index.removeStorageSync("isLogin");
- this.isLoggedIn = false;
- this.myInfo = {};
- }
- },
- goToLogin() {
- common_vendor.index.reLaunch({ url: "/pages/login/index" });
- },
- contactAdmin() {
- common_vendor.index.showModal({ title: "联系管理员", content: "管理员电话:138-0000-0000", showCancel: false, confirmColor: "#C1001C" });
- },
- goToAddModel() {
- common_vendor.index.navigateTo({
- url: "/pages/order/add-model/index"
- });
- },
- editItem(index, item) {
- common_vendor.index.navigateTo({
- url: `/pages/order/edit-model/index?index=${index}&data=${encodeURIComponent(JSON.stringify(item))}`
- });
- },
- removeItem(index) {
- const self = this;
- common_vendor.index.showModal({
- title: "提示",
- content: "确定移除该型号吗?",
- success: (res) => {
- if (res.confirm) {
- self.selectedModels.splice(index, 1);
- }
- }
- });
- },
- async submitFinalOrder() {
- if (this.selectedModels.length === 0)
- return;
- common_vendor.index.showLoading({ title: "正在提交订单", mask: true });
- try {
- const detailIds = this.selectedModels.map((item) => item.frowId);
- await api_erp_order.addOrder({ detailIds });
- common_vendor.index.hideLoading();
- common_vendor.index.showToast({ title: "下单成功", icon: "success" });
- setTimeout(() => {
- common_vendor.index.navigateTo({
- url: "/pages/order/success/index"
- });
- }, 1500);
- } catch (e) {
- common_vendor.index.hideLoading();
- }
- }
- }
- };
- if (!Array) {
- const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar");
- const _component_erp_tab_bar = common_vendor.resolveComponent("erp-tab-bar");
- (_component_erp_nav_bar + _component_erp_tab_bar)();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: common_vendor.p({
- title: "ERP 下单",
- ["show-back"]: false
- }),
- b: !$data.isLoggedIn
- }, !$data.isLoggedIn ? {
- c: common_vendor.o((...args) => $options.goToLogin && $options.goToLogin(...args), "93")
- } : !$data.myInfo.authClientFRowID ? {
- e: common_vendor.o((...args) => $options.contactAdmin && $options.contactAdmin(...args), "85")
- } : common_vendor.e({
- f: $data.isLoading
- }, $data.isLoading ? {} : common_vendor.e({
- g: $data.selectedModels.length > 0
- }, $data.selectedModels.length > 0 ? {} : {}, {
- h: $data.selectedModels.length > 0
- }, $data.selectedModels.length > 0 ? {
- i: common_vendor.f($data.selectedModels, (item, index, i0) => {
- return {
- a: common_vendor.o(($event) => $options.removeItem(index), index),
- b: common_vendor.t(item.modelNum),
- c: common_vendor.t(item.count),
- d: common_vendor.t(item.surfaceName),
- e: index,
- f: common_vendor.o(($event) => $options.editItem(index, item), index)
- };
- })
- } : {
- j: common_vendor.o((...args) => $options.goToAddModel && $options.goToAddModel(...args), "17")
- }), {
- k: $data.selectedModels.length > 0
- }, $data.selectedModels.length > 0 ? {
- l: common_vendor.o((...args) => $options.goToAddModel && $options.goToAddModel(...args), "4c")
- } : {}, {
- m: $data.selectedModels.length > 0
- }, $data.selectedModels.length > 0 ? {
- n: common_vendor.t($data.selectedModels.length),
- o: common_vendor.t($options.totalCount),
- p: $data.selectedModels.length === 0,
- q: common_vendor.o((...args) => $options.submitFinalOrder && $options.submitFinalOrder(...args), "63")
- } : {}), {
- d: !$data.myInfo.authClientFRowID,
- r: common_vendor.p({
- active: "order"
- })
- });
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-17a44f9d"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/index.js.map
|