处理商品订单
This commit is contained in:
274
unpackage/dist/dev/mp-weixin/pages/index/goodsOrderAdd.js
vendored
Normal file
274
unpackage/dist/dev/mp-weixin/pages/index/goodsOrderAdd.js
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const api_index = require("../../api/index.js");
|
||||
if (!Array) {
|
||||
const _easycom_nut_form_item2 = common_vendor.resolveComponent("nut-form-item");
|
||||
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
|
||||
const _easycom_nut_form2 = common_vendor.resolveComponent("nut-form");
|
||||
const _easycom_nut_input2 = common_vendor.resolveComponent("nut-input");
|
||||
const _easycom_nut_textarea2 = common_vendor.resolveComponent("nut-textarea");
|
||||
const _easycom_nut_cascader2 = common_vendor.resolveComponent("nut-cascader");
|
||||
const _easycom_nut_picker2 = common_vendor.resolveComponent("nut-picker");
|
||||
const _easycom_nut_popup2 = common_vendor.resolveComponent("nut-popup");
|
||||
(_easycom_nut_form_item2 + _easycom_nut_button2 + _easycom_nut_form2 + _easycom_nut_input2 + _easycom_nut_textarea2 + _easycom_nut_cascader2 + _easycom_nut_picker2 + _easycom_nut_popup2)();
|
||||
}
|
||||
const _easycom_nut_form_item = () => "../../uni_modules/nutui-uni/components/formitem/formitem.js";
|
||||
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
|
||||
const _easycom_nut_form = () => "../../uni_modules/nutui-uni/components/form/form.js";
|
||||
const _easycom_nut_input = () => "../../uni_modules/nutui-uni/components/input/input.js";
|
||||
const _easycom_nut_textarea = () => "../../uni_modules/nutui-uni/components/textarea/textarea.js";
|
||||
const _easycom_nut_cascader = () => "../../uni_modules/nutui-uni/components/cascader/cascader.js";
|
||||
const _easycom_nut_picker = () => "../../uni_modules/nutui-uni/components/picker/picker.js";
|
||||
const _easycom_nut_popup = () => "../../uni_modules/nutui-uni/components/popup/popup.js";
|
||||
if (!Math) {
|
||||
(_easycom_nut_form_item + _easycom_nut_button + _easycom_nut_form + _easycom_nut_input + _easycom_nut_textarea + _easycom_nut_cascader + _easycom_nut_picker + _easycom_nut_popup)();
|
||||
}
|
||||
const _sfc_main = {
|
||||
__name: "goodsOrderAdd",
|
||||
setup(__props) {
|
||||
common_vendor.onLoad((options) => {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:118", options);
|
||||
});
|
||||
const visiblePaymentStatusPopup = common_vendor.ref(false);
|
||||
const popupPaymentTypeVal = common_vendor.ref("");
|
||||
const paymentStatuses = [
|
||||
{
|
||||
value: 1,
|
||||
label: "已付"
|
||||
}
|
||||
];
|
||||
const openPayStatusPopup = (type, index = -1) => {
|
||||
popupPaymentTypeVal.value = type;
|
||||
goodsPayIndex.value = index;
|
||||
visiblePaymentStatusPopup.value = true;
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:141", type);
|
||||
};
|
||||
const onConfirmPaymentStatus = (selectedValue) => {
|
||||
if (popupPaymentTypeVal.value == "goods" && goodsPayIndex.value >= 0) {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:145", "处理商品支付状态", goodsPayIndex.value);
|
||||
orderGoods.value[goodsPayIndex.value].goods_pay_status_txt = selectedValue.selectedOptions[0].label;
|
||||
orderGoods.value[goodsPayIndex.value].goods_pay_status = selectedValue.selectedOptions[0].value;
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:149", form);
|
||||
visiblePaymentStatusPopup.value = false;
|
||||
popupPaymentTypeVal.value = "";
|
||||
goodsPayIndex.value = -1;
|
||||
};
|
||||
const orderGoods = common_vendor.ref([
|
||||
// {
|
||||
// goods_type_name: null,
|
||||
// goods_type_id: null,
|
||||
// goods_name: null,
|
||||
// goods_id: null,
|
||||
// goods_price: null,
|
||||
// goods_pay_status: 0,
|
||||
// goods_pay_status_txt: "请选择",
|
||||
// cascader_val: []
|
||||
// },
|
||||
]);
|
||||
const goodsPayIndex = common_vendor.ref(0);
|
||||
const goodsIndex = common_vendor.ref(0);
|
||||
const addGoods = () => {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:176", orderGoods.value);
|
||||
orderGoods.value.push({
|
||||
goods_type_name: null,
|
||||
goods_type_id: null,
|
||||
goods_name: null,
|
||||
goods_id: null,
|
||||
goods_price: null,
|
||||
goods_pay_status: 1,
|
||||
goods_pay_status_txt: "已付",
|
||||
cascader_val: []
|
||||
});
|
||||
};
|
||||
const removeGoods = (index) => {
|
||||
orderGoods.value.splice(index, 1);
|
||||
};
|
||||
const visibleGoodsCascader = common_vendor.ref(false);
|
||||
const cascaderGoodsValue = common_vendor.computed(() => {
|
||||
var _a;
|
||||
let cascader_val = [];
|
||||
if (goodsIndex.value >= 0) {
|
||||
return ((_a = orderGoods.value[goodsIndex.value]) == null ? void 0 : _a.cascader_val) ?? [];
|
||||
} else {
|
||||
return cascader_val;
|
||||
}
|
||||
});
|
||||
const onGoodsChange = (...args) => {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:204", "onGoodsChange", args);
|
||||
};
|
||||
const onGoodsPathChange = (args) => {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:208", "onGoodsPathChange", args);
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:209", "goodsIndex", goodsIndex.value);
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:210", "orderGoods.value[goodsIndex.value]", orderGoods.value[goodsIndex.value]);
|
||||
orderGoods.value[goodsIndex.value].goods_type_name = null;
|
||||
orderGoods.value[goodsIndex.value].goods_type_id = null;
|
||||
orderGoods.value[goodsIndex.value].goods_name = null;
|
||||
orderGoods.value[goodsIndex.value].goods_id = null;
|
||||
orderGoods.value[goodsIndex.value].goods_price = null;
|
||||
if (args.length >= 1 && args[0] !== null) {
|
||||
orderGoods.value[goodsIndex.value].goods_type_name = args[0].text;
|
||||
orderGoods.value[goodsIndex.value].goods_type_id = args[0].value;
|
||||
}
|
||||
if (args.length >= 2 && args[1] !== null) {
|
||||
orderGoods.value[goodsIndex.value].goods_name = args[1].text;
|
||||
orderGoods.value[goodsIndex.value].goods_id = args[1].value;
|
||||
orderGoods.value[goodsIndex.value].goods_price = args[1].goods_price;
|
||||
}
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:226", "orderGoods.value[goodsIndex.value]", orderGoods.value[goodsIndex.value]);
|
||||
};
|
||||
const onCloseGoodsCascader = () => {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:229", "onCloseGoodsCascader");
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:230", "goodsIndex.value", goodsIndex.value);
|
||||
if (orderGoods.value[goodsIndex.value].goods_type_id && orderGoods.value[goodsIndex.value].goods_id) {
|
||||
orderGoods.value[goodsIndex.value].cascader_val = [
|
||||
orderGoods.value[goodsIndex.value].goods_type_id,
|
||||
orderGoods.value[goodsIndex.value].goods_id
|
||||
];
|
||||
}
|
||||
goodsIndex.value = 0;
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:238", "goodsIndex.value", goodsIndex.value);
|
||||
};
|
||||
const onOpenGoodsCascader = () => {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:241", "onOpenGoodsCascader");
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:242", "goodsIndex.value", goodsIndex.value);
|
||||
};
|
||||
const form = common_vendor.reactive({
|
||||
order_type: 2,
|
||||
// 开台订单
|
||||
discount_amount: null,
|
||||
// 优惠金额
|
||||
remarks: null
|
||||
});
|
||||
const selectGoods = common_vendor.ref([]);
|
||||
common_vendor.onMounted(() => {
|
||||
api_index.fetchGoods().then((res) => {
|
||||
selectGoods.value = res;
|
||||
});
|
||||
});
|
||||
const submitForm = () => {
|
||||
let data = {
|
||||
order_goods: orderGoods.value,
|
||||
order: form
|
||||
};
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:269", "提交的订单数据:", data);
|
||||
api_index.fetchAddOrder(data).then((res) => {
|
||||
common_vendor.index.__f__("log", "at pages/index/goodsOrderAdd.vue:271", res);
|
||||
common_vendor.index.showToast({
|
||||
icon: "none",
|
||||
title: "商品订单记录成功"
|
||||
});
|
||||
setTimeout(() => {
|
||||
common_vendor.index.switchTab({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
}, 500);
|
||||
});
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.f(orderGoods.value, (item, index, i0) => {
|
||||
return common_vendor.e({
|
||||
a: item.goods_type_name && item.goods_name
|
||||
}, item.goods_type_name && item.goods_name ? {
|
||||
b: common_vendor.t(item.goods_type_name),
|
||||
c: common_vendor.t(item.goods_name)
|
||||
} : {}, {
|
||||
d: common_vendor.o(($event) => {
|
||||
visibleGoodsCascader.value = true;
|
||||
goodsIndex.value = index;
|
||||
}, index),
|
||||
e: "bd18e2e4-1-" + i0 + ",bd18e2e4-0",
|
||||
f: common_vendor.t(item.goods_price),
|
||||
g: "bd18e2e4-2-" + i0 + ",bd18e2e4-0",
|
||||
h: common_vendor.t(item.goods_pay_status_txt),
|
||||
i: common_vendor.o(($event) => openPayStatusPopup("goods", index), index),
|
||||
j: "bd18e2e4-3-" + i0 + ",bd18e2e4-0",
|
||||
k: common_vendor.o(($event) => removeGoods(index), index),
|
||||
l: "bd18e2e4-5-" + i0 + "," + ("bd18e2e4-4-" + i0),
|
||||
m: "bd18e2e4-4-" + i0 + ",bd18e2e4-0",
|
||||
n: index
|
||||
});
|
||||
}),
|
||||
b: common_vendor.p({
|
||||
["label-position"]: "top"
|
||||
}),
|
||||
c: common_vendor.p({
|
||||
["label-position"]: "top"
|
||||
}),
|
||||
d: common_vendor.p({
|
||||
["label-position"]: "top"
|
||||
}),
|
||||
e: common_vendor.p({
|
||||
type: "danger",
|
||||
size: "mini"
|
||||
}),
|
||||
f: common_vendor.p({
|
||||
["label-position"]: "top"
|
||||
}),
|
||||
g: common_vendor.o(addGoods),
|
||||
h: common_vendor.p({
|
||||
type: "primary",
|
||||
plain: true,
|
||||
size: "small"
|
||||
}),
|
||||
i: common_vendor.o(($event) => form.discount_amount = $event),
|
||||
j: common_vendor.p({
|
||||
placeholder: "请输入金额",
|
||||
type: "number",
|
||||
modelValue: form.discount_amount
|
||||
}),
|
||||
k: common_vendor.o(($event) => form.remarks = $event),
|
||||
l: common_vendor.p({
|
||||
rows: 3,
|
||||
["adjust-keyboard-to"]: "bottom",
|
||||
placeholder: "请输入备注",
|
||||
modelValue: form.remarks
|
||||
}),
|
||||
m: common_vendor.p({
|
||||
label: "备注"
|
||||
}),
|
||||
n: common_vendor.o(submitForm),
|
||||
o: common_vendor.p({
|
||||
type: "primary",
|
||||
block: true
|
||||
}),
|
||||
p: common_vendor.o(onGoodsChange),
|
||||
q: common_vendor.o(onGoodsPathChange),
|
||||
r: common_vendor.o(onOpenGoodsCascader),
|
||||
s: common_vendor.o(onCloseGoodsCascader),
|
||||
t: common_vendor.o(($event) => visibleGoodsCascader.value = $event),
|
||||
v: common_vendor.o(($event) => cascaderGoodsValue.value = $event),
|
||||
w: common_vendor.p({
|
||||
title: "商品选择",
|
||||
["text-key"]: "label",
|
||||
["value-key"]: "value",
|
||||
["children-key"]: "children",
|
||||
options: selectGoods.value,
|
||||
["title-ellipsis"]: false,
|
||||
visible: visibleGoodsCascader.value,
|
||||
modelValue: cascaderGoodsValue.value
|
||||
}),
|
||||
x: common_vendor.o(onConfirmPaymentStatus),
|
||||
y: common_vendor.o(($event) => visiblePaymentStatusPopup.value = false),
|
||||
z: common_vendor.p({
|
||||
columns: paymentStatuses,
|
||||
["field-names"]: {
|
||||
text: "label",
|
||||
value: "value"
|
||||
},
|
||||
title: "选择支付状态"
|
||||
}),
|
||||
A: common_vendor.o(($event) => visiblePaymentStatusPopup.value = $event),
|
||||
B: common_vendor.p({
|
||||
position: "bottom",
|
||||
["safe-area-inset-bottom"]: true,
|
||||
visible: visiblePaymentStatusPopup.value
|
||||
})
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bd18e2e4"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/goodsOrderAdd.js.map
|
||||
Reference in New Issue
Block a user