first commit
This commit is contained in:
218
unpackage/dist/dev/mp-weixin/pages/order/confirm.js
vendored
Normal file
218
unpackage/dist/dev/mp-weixin/pages/order/confirm.js
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_assets = require("../../common/assets.js");
|
||||
const api_index = require("../../api/index.js");
|
||||
const store_index = require("../../store/index.js");
|
||||
if (!Array) {
|
||||
const _easycom_wd_navbar2 = common_vendor.resolveComponent("wd-navbar");
|
||||
const _easycom_wd_input_number2 = common_vendor.resolveComponent("wd-input-number");
|
||||
const _easycom_wd_textarea2 = common_vendor.resolveComponent("wd-textarea");
|
||||
(_easycom_wd_navbar2 + _easycom_wd_input_number2 + _easycom_wd_textarea2)();
|
||||
}
|
||||
const _easycom_wd_navbar = () => "../../uni_modules/wot-design-uni/components/wd-navbar/wd-navbar.js";
|
||||
const _easycom_wd_input_number = () => "../../uni_modules/wot-design-uni/components/wd-input-number/wd-input-number.js";
|
||||
const _easycom_wd_textarea = () => "../../uni_modules/wot-design-uni/components/wd-textarea/wd-textarea.js";
|
||||
if (!Math) {
|
||||
(_easycom_wd_navbar + _easycom_wd_input_number + _easycom_wd_textarea)();
|
||||
}
|
||||
const _sfc_main = {
|
||||
__name: "confirm",
|
||||
setup(__props) {
|
||||
const store = store_index.Store();
|
||||
const userInfo = common_vendor.computed(() => {
|
||||
if (!store.userInfo.userRights) {
|
||||
dataFrom.value.payType = 1;
|
||||
}
|
||||
return store.userInfo || {
|
||||
inviteCode: "",
|
||||
nickname: "",
|
||||
mobile: "",
|
||||
avatar: "",
|
||||
paywallet: { balance: 0 },
|
||||
userRights: null
|
||||
};
|
||||
});
|
||||
const goods = common_vendor.ref({});
|
||||
const address = common_vendor.ref(null);
|
||||
const dataFrom = common_vendor.ref({
|
||||
goodsId: null,
|
||||
goodsNum: 1,
|
||||
totalAmount: 0,
|
||||
payableAmount: 0,
|
||||
payAmount: 0,
|
||||
payType: 1,
|
||||
receiverId: null,
|
||||
note: "",
|
||||
orderType: 1
|
||||
});
|
||||
const totalAmount = common_vendor.computed(() => {
|
||||
return goods.value.currentPrice * dataFrom.value.goodsNum;
|
||||
});
|
||||
const paymentAmount = common_vendor.computed(() => {
|
||||
var _a, _b;
|
||||
if (dataFrom.value.payType === 1) {
|
||||
const discount = ((_b = (_a = userInfo.value.userRights) == null ? void 0 : _a.rights) == null ? void 0 : _b.rightsDiscount) || 100;
|
||||
return totalAmount.value * discount / 100;
|
||||
}
|
||||
return totalAmount.value;
|
||||
});
|
||||
const submitOrder = () => {
|
||||
var _a;
|
||||
let data = JSON.parse(JSON.stringify(dataFrom.value));
|
||||
if (!address.value) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请选择收货地址",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
common_vendor.index.showLoading({
|
||||
mask: true
|
||||
});
|
||||
data.receiverId = (_a = address.value) == null ? void 0 : _a.id;
|
||||
if (data.payType == 1) {
|
||||
data.payAmount = paymentAmount.value;
|
||||
data.totalAmount = totalAmount.value;
|
||||
data.payableAmount = paymentAmount.value;
|
||||
data.totalAmount = totalAmount.value;
|
||||
}
|
||||
if (data.payType == 2) {
|
||||
data.deductibleAmount = totalAmount.value;
|
||||
data.totalAmount = totalAmount.value;
|
||||
data.deductionAmount = totalAmount.value;
|
||||
data.totalAmount = totalAmount.value;
|
||||
}
|
||||
if (data.payType == 3) {
|
||||
if (userInfo.value.userRights.pice < totalAmount.value) {
|
||||
data.deductibleAmount = userInfo.value.userRights.pice;
|
||||
data.deductionAmount = userInfo.value.userRights.pice;
|
||||
data.payAmount = totalAmount.value - userInfo.value.userRights.pice;
|
||||
data.payableAmount = totalAmount.value - userInfo.value.userRights.pice;
|
||||
data.totalAmount = totalAmount.value;
|
||||
} else {
|
||||
data.deductibleAmount = totalAmount.value;
|
||||
data.totalAmount = totalAmount.value;
|
||||
data.deductionAmount = totalAmount.value;
|
||||
data.totalAmount = totalAmount.value;
|
||||
data.payType = 2;
|
||||
}
|
||||
}
|
||||
api_index.api.orderCreate(data).then((res) => {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/order/success?id=" + res
|
||||
});
|
||||
}).catch(() => {
|
||||
common_vendor.index.hideLoading();
|
||||
});
|
||||
};
|
||||
common_vendor.onLoad(async (options) => {
|
||||
dataFrom.value.goodsId = options.id;
|
||||
await store.usersGetInfo();
|
||||
api_index.api.goodsInfo({ id: options.id }).then((res) => {
|
||||
goods.value = res;
|
||||
});
|
||||
api_index.api.addressPage({ isDefault: 1 }).then((res) => {
|
||||
if (res.list.length) {
|
||||
address.value = res.list[0];
|
||||
dataFrom.value.receiverId = address.value.id;
|
||||
}
|
||||
});
|
||||
common_vendor.index.$on("address", (e) => {
|
||||
address.value = e;
|
||||
});
|
||||
});
|
||||
const min = (a, b) => Math.min(a, b);
|
||||
const max = (a, b) => Math.max(a, b);
|
||||
const formatPrice = (price) => `¥ ${parseFloat(price).toFixed(2)}`;
|
||||
const selectAddress = () => {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/address/list?type=1"
|
||||
});
|
||||
};
|
||||
const viewProduct = () => {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/goods/goods?id=" + goods.value.id
|
||||
});
|
||||
};
|
||||
const back = () => {
|
||||
common_vendor.index.navigateBack();
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.o(back),
|
||||
b: common_vendor.p({
|
||||
title: "下单",
|
||||
bordered: false,
|
||||
["left-arrow"]: true,
|
||||
["custom-style"]: "background-color: transparent !important;",
|
||||
safeAreaInsetTop: true
|
||||
}),
|
||||
c: address.value
|
||||
}, address.value ? {
|
||||
d: common_vendor.t(address.value.receiverArea),
|
||||
e: common_vendor.t(address.value.receiverAddress),
|
||||
f: common_vendor.t(address.value.receiverName),
|
||||
g: common_vendor.t(address.value.receiverPhone)
|
||||
} : {}, {
|
||||
h: common_assets._imports_0$1,
|
||||
i: common_vendor.o(selectAddress),
|
||||
j: goods.value.cover,
|
||||
k: common_vendor.t(goods.value.name),
|
||||
l: common_vendor.t(goods.value.specs),
|
||||
m: common_vendor.t(goods.value.currentPrice),
|
||||
n: common_vendor.o(viewProduct),
|
||||
o: common_assets._imports_0$1,
|
||||
p: common_vendor.o(($event) => dataFrom.value.goodsNum = $event),
|
||||
q: common_vendor.p({
|
||||
modelValue: dataFrom.value.goodsNum
|
||||
}),
|
||||
r: common_vendor.o(($event) => dataFrom.value.note = $event),
|
||||
s: common_vendor.p({
|
||||
placeholder: "请填写订单备注",
|
||||
modelValue: dataFrom.value.note
|
||||
}),
|
||||
t: common_vendor.t(userInfo.value.money || 0),
|
||||
v: dataFrom.value.payType === 1 ? 1 : "",
|
||||
w: common_vendor.o(($event) => dataFrom.value.payType = 1),
|
||||
x: dataFrom.value.payType === 1 && userInfo.value.userRights
|
||||
}, dataFrom.value.payType === 1 && userInfo.value.userRights ? {
|
||||
y: common_vendor.t(userInfo.value.userRights.rights.rightsName),
|
||||
z: common_vendor.t(userInfo.value.userRights.rights.rightsDiscount / 10)
|
||||
} : {}, {
|
||||
A: userInfo.value.userRights
|
||||
}, userInfo.value.userRights ? {
|
||||
B: common_vendor.t(userInfo.value.userRights.pice || 0),
|
||||
C: dataFrom.value.payType === 2 ? 1 : "",
|
||||
D: common_vendor.o(($event) => dataFrom.value.payType = 2)
|
||||
} : {}, {
|
||||
E: dataFrom.value.payType === 2
|
||||
}, dataFrom.value.payType === 2 ? {} : {}, {
|
||||
F: userInfo.value.userRights
|
||||
}, userInfo.value.userRights ? common_vendor.e({
|
||||
G: totalAmount.value > userInfo.value.userRights.pice + userInfo.value.money
|
||||
}, totalAmount.value > userInfo.value.userRights.pice + userInfo.value.money ? {
|
||||
H: common_vendor.t(min(userInfo.value.money, totalAmount.value - userInfo.value.userRights.pice)),
|
||||
I: common_vendor.t(min(userInfo.value.userRights.pice, totalAmount.value - userInfo.value.money))
|
||||
} : common_vendor.e({
|
||||
J: common_vendor.t(max(0, totalAmount.value - userInfo.value.userRights.pice)),
|
||||
K: min(totalAmount.value - (totalAmount.value - userInfo.value.userRights.pice), userInfo.value.userRights.pice) > totalAmount.value
|
||||
}, min(totalAmount.value - (totalAmount.value - userInfo.value.userRights.pice), userInfo.value.userRights.pice) > totalAmount.value ? {
|
||||
L: common_vendor.t(totalAmount.value)
|
||||
} : {
|
||||
M: common_vendor.t(min(totalAmount.value - (totalAmount.value - userInfo.value.userRights.pice), userInfo.value.userRights.pice))
|
||||
}), {
|
||||
N: dataFrom.value.payType === 3 ? 1 : "",
|
||||
O: common_vendor.o(($event) => dataFrom.value.payType = 3)
|
||||
}) : {}, {
|
||||
P: dataFrom.value.payType === 3
|
||||
}, dataFrom.value.payType === 3 ? {} : {}, {
|
||||
Q: common_vendor.t(formatPrice(paymentAmount.value)),
|
||||
R: common_vendor.o(submitOrder)
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-324e7894"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/confirm.js.map
|
||||
Reference in New Issue
Block a user