246 lines
10 KiB
JavaScript
246 lines
10 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const api_house_order = require("../../api/house_order.js");
|
|
const api_config = require("../../api/config.js");
|
|
if (!Array) {
|
|
const _easycom_nut_cell2 = common_vendor.resolveComponent("nut-cell");
|
|
const _easycom_nut_cell_group2 = common_vendor.resolveComponent("nut-cell-group");
|
|
const _easycom_nut_tag2 = common_vendor.resolveComponent("nut-tag");
|
|
const _easycom_nut_price2 = common_vendor.resolveComponent("nut-price");
|
|
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
|
|
(_easycom_nut_cell2 + _easycom_nut_cell_group2 + _easycom_nut_tag2 + _easycom_nut_price2 + _easycom_nut_button2)();
|
|
}
|
|
const _easycom_nut_cell = () => "../../uni_modules/nutui-uni/components/cell/cell.js";
|
|
const _easycom_nut_cell_group = () => "../../uni_modules/nutui-uni/components/cellgroup/cellgroup.js";
|
|
const _easycom_nut_tag = () => "../../uni_modules/nutui-uni/components/tag/tag.js";
|
|
const _easycom_nut_price = () => "../../uni_modules/nutui-uni/components/price/price.js";
|
|
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
|
|
if (!Math) {
|
|
(_easycom_nut_cell + _easycom_nut_cell_group + _easycom_nut_tag + _easycom_nut_price + _easycom_nut_button)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "housePreview",
|
|
setup(__props) {
|
|
const audit = common_vendor.ref(true);
|
|
const isWarehouse = common_vendor.ref(false);
|
|
const singleRule = common_vendor.ref([]);
|
|
const rangeRule = common_vendor.ref([]);
|
|
const warehouseRule = common_vendor.reactive({
|
|
val: 0,
|
|
val_type: 1
|
|
});
|
|
const GetPriceRules = () => {
|
|
api_config.fetchGetPriceRules().then((res) => {
|
|
var _a;
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:107", "res", res);
|
|
rangeRule.value = (res == null ? void 0 : res.range) ?? [];
|
|
singleRule.value = (res == null ? void 0 : res.single) ?? [];
|
|
Object.assign(warehouseRule, ((_a = res == null ? void 0 : res.warehouse) == null ? void 0 : _a[0]) ?? {
|
|
val: 0,
|
|
val_type: 1
|
|
});
|
|
});
|
|
};
|
|
const getPrice = (goods2) => {
|
|
if (isWarehouse.value) {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:125", "开启整仓调价");
|
|
const list = singleRule.value || singleRule;
|
|
const rule = list.find((item) => item.product_id === (goods2 == null ? void 0 : goods2.goods_id));
|
|
if (rule) {
|
|
const basePrice = Number(goods2 == null ? void 0 : goods2.goods_price);
|
|
const val = Number(rule.val);
|
|
let finalPrice = basePrice;
|
|
if (rule.val_type == 1) {
|
|
finalPrice = basePrice + val;
|
|
} else if (rule.val_type == 2) {
|
|
finalPrice = basePrice + basePrice * val / 100;
|
|
}
|
|
return finalPrice.toFixed(2);
|
|
} else {
|
|
const basePrice = Number(goods2 == null ? void 0 : goods2.goods_price);
|
|
const val = Number(warehouseRule.val);
|
|
let finalPrice = basePrice;
|
|
if (warehouseRule.val_type == 1) {
|
|
finalPrice = basePrice + val;
|
|
} else if (warehouseRule.val_type == 2) {
|
|
finalPrice = basePrice + basePrice * val / 100;
|
|
}
|
|
return finalPrice.toFixed(2);
|
|
}
|
|
} else {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:156", "未开启整仓调价");
|
|
const singleRuleList = singleRule.value || singleRule;
|
|
const oneRule = singleRuleList.find((item) => item.product_id === (goods2 == null ? void 0 : goods2.goods_id));
|
|
if (oneRule) {
|
|
const basePrice = Number(goods2 == null ? void 0 : goods2.goods_price);
|
|
const val = Number(oneRule.val);
|
|
let finalPrice = basePrice;
|
|
if (oneRule.val_type == 1) {
|
|
finalPrice = basePrice + val;
|
|
} else if (oneRule.val_type == 2) {
|
|
finalPrice = basePrice + basePrice * val / 100;
|
|
}
|
|
return finalPrice.toFixed(2);
|
|
} else {
|
|
const basePrice = Number(goods2 == null ? void 0 : goods2.goods_price);
|
|
const rangeRulelist = rangeRule.value || rangeRule;
|
|
const quRule = rangeRulelist.find((item) => {
|
|
const min = Number(item.min_price);
|
|
const max = Number(item.max_price);
|
|
return basePrice >= min && basePrice < max;
|
|
}) || null;
|
|
if (quRule) {
|
|
const val = Number(quRule.val);
|
|
let finalPrice = basePrice;
|
|
if (quRule.val_type == 1) {
|
|
finalPrice = basePrice + val;
|
|
} else if (quRule.val_type == 2) {
|
|
finalPrice = basePrice + basePrice * val / 100;
|
|
}
|
|
return finalPrice.toFixed(2);
|
|
} else {
|
|
return basePrice;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
const getConfig = () => {
|
|
api_config.fetchGetConfig().then((res) => {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:204", "getConfig=====>", res);
|
|
audit.value = res.appConfig.is_audit == 1;
|
|
isWarehouse.value = res.appConfig.is_warehouse == 1;
|
|
});
|
|
};
|
|
const chooseAddress = () => {
|
|
common_vendor.index.chooseAddress({
|
|
success(res) {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:226", res);
|
|
Object.assign(form, {
|
|
address_info: {
|
|
address_id: res.addressID || 1,
|
|
user_name: res.userName,
|
|
tel_number: res.telNumber,
|
|
city_name: res.cityName || "",
|
|
county_name: res.countyName || "",
|
|
detail_info: res.detailInfo || "",
|
|
detail_info_new: res.detailInfoNew || "",
|
|
national_code: res.nationalCode || "",
|
|
national_code_full: res.nationalCodeFull || "",
|
|
postal_code: res.postalCode || "",
|
|
province_name: res.provinceName || "",
|
|
street_name: res.streetName || ""
|
|
}
|
|
});
|
|
}
|
|
});
|
|
};
|
|
common_vendor.ref([]);
|
|
const goods = common_vendor.reactive({});
|
|
const order_total_price = common_vendor.ref(0);
|
|
const order_total_num = common_vendor.ref(0);
|
|
const form = common_vendor.reactive({
|
|
goods_id: 0,
|
|
address_info: {}
|
|
});
|
|
const fromStr = common_vendor.ref("");
|
|
common_vendor.onLoad((options) => {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:271", "init");
|
|
getConfig();
|
|
GetPriceRules();
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:277", "🚀 ~ from:", options.from);
|
|
fromStr.value = options.from;
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:279", "🚀 ~ ids:", options.ids);
|
|
form.goods_id = options.ids;
|
|
});
|
|
common_vendor.onShow(() => {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:287", "🚀 ~ onShowfrom:", fromStr.value);
|
|
if (fromStr.value === "list" || fromStr.value === "item") {
|
|
api_house_order.houseFetchGoodsPreview({
|
|
goods_id: form.goods_id
|
|
}).then((res) => {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:292", res);
|
|
Object.assign(goods, res.goods);
|
|
order_total_price.value = res.order_total_price;
|
|
order_total_num.value = res.order_total_num;
|
|
});
|
|
}
|
|
});
|
|
common_vendor.onHide(() => {
|
|
fromStr.value = "";
|
|
});
|
|
const onSubmitClick = () => {
|
|
var _a;
|
|
if (!((_a = form.address_info) == null ? void 0 : _a.address_id)) {
|
|
common_vendor.index.showToast({
|
|
title: "请选择收货地址",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
api_house_order.fetchOrderbuyNow(form).then((res) => {
|
|
common_vendor.index.__f__("log", "at pages/order/housePreview.vue:318", res);
|
|
common_vendor.index.redirectTo({
|
|
url: "/pages/order/detail?id=" + res.order_id,
|
|
success: (res2) => {
|
|
},
|
|
fail: () => {
|
|
},
|
|
complete: () => {
|
|
}
|
|
});
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
var _a, _b, _c, _d, _e, _f;
|
|
return common_vendor.e({
|
|
a: !((_a = form.address_info) == null ? void 0 : _a.address_id)
|
|
}, !((_b = form.address_info) == null ? void 0 : _b.address_id) ? {
|
|
b: common_vendor.o(chooseAddress),
|
|
c: common_vendor.p({
|
|
title: "添加地址",
|
|
["is-link"]: true
|
|
})
|
|
} : {
|
|
d: common_vendor.o(chooseAddress),
|
|
e: common_vendor.p({
|
|
title: form.address_info.user_name + " " + form.address_info.tel_number,
|
|
["is-link"]: true,
|
|
["sub-title"]: form.address_info.province_name + form.address_info.city_name + form.address_info.county_name + form.address_info.street_name + form.address_info.detail_info_new
|
|
})
|
|
}, {
|
|
f: common_vendor.t((_d = (_c = goods == null ? void 0 : goods.goods_house) == null ? void 0 : _c.degree) == null ? void 0 : _d.degree_name),
|
|
g: common_vendor.p({
|
|
["custom-color"]: "#1a1a1a"
|
|
}),
|
|
h: common_vendor.t((_e = goods == null ? void 0 : goods.goods_house) == null ? void 0 : _e.goods_name),
|
|
i: common_vendor.t((_f = goods == null ? void 0 : goods.goods_house) == null ? void 0 : _f.goods_no),
|
|
j: common_vendor.p({
|
|
price: getPrice(goods == null ? void 0 : goods.goods_house),
|
|
size: "small",
|
|
["need-symbol"]: true
|
|
}),
|
|
k: common_vendor.p({
|
|
center: true
|
|
}),
|
|
l: common_vendor.t(order_total_num.value),
|
|
m: common_vendor.p({
|
|
price: getPrice(goods == null ? void 0 : goods.goods_house),
|
|
["need-symbol"]: true
|
|
}),
|
|
n: common_vendor.p({
|
|
size: "large",
|
|
price: getPrice(goods == null ? void 0 : goods.goods_house),
|
|
["need-symbol"]: true
|
|
}),
|
|
o: common_vendor.o(onSubmitClick),
|
|
p: common_vendor.p({
|
|
type: "primary"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f68461ec"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/housePreview.js.map
|