feat: 代客下单更新
This commit is contained in:
@@ -74,13 +74,14 @@
|
||||
:key="index"
|
||||
size="large"
|
||||
:type="index == payTypes.sel ? 'primary' : ''"
|
||||
:disabled="canUsePayType(item)"
|
||||
@click="changePayType(index)"
|
||||
>
|
||||
{{ item.payName }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
<el-button type="primary" size="large" @click="nowPayClick">立即支付</el-button>
|
||||
<el-button type="primary" size="large" @click="nowPayClick()">立即支付</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -172,6 +173,8 @@ function discountConfirm(e) {
|
||||
if (e.discount) {
|
||||
checkOrderPay.discountAmount =
|
||||
carts.payMoney - (carts.payMoney * (e.discount / 100).toFixed(2)).toFixed(2);
|
||||
} else {
|
||||
checkOrderPay.discount = 0;
|
||||
}
|
||||
}
|
||||
function discountShow(e) {
|
||||
@@ -246,19 +249,33 @@ const payTypes = reactive({
|
||||
list: [],
|
||||
sel: 0,
|
||||
});
|
||||
function canUsePayType(item) {
|
||||
if (currentpayMoney.value * 1 == 0) {
|
||||
return item.payType == "cash" ? false : true;
|
||||
}
|
||||
// if (item.payType == "virtual" && item.payName == "会员支付") {
|
||||
// return props.user.id ? false : true;
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
const refScanPay = ref();
|
||||
function changePayType(i) {
|
||||
const payType = payTypes.list[i].payType;
|
||||
refScanPayOpen(payType);
|
||||
payTypes.sel = i;
|
||||
if (payType == "member-account") {
|
||||
return chooseUser();
|
||||
}
|
||||
refScanPayOpen(payType);
|
||||
}
|
||||
|
||||
function returnPayParams() {
|
||||
return {
|
||||
money: currentpayMoney.value * 1,
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
authCode: "",
|
||||
authCode: authCode,
|
||||
checkOrderPay: {
|
||||
vipPrice: props.user.id && props.user.isVip ? 1 : 0,
|
||||
orderId: props.orderInfo.id,
|
||||
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
|
||||
discountRatio: 0,
|
||||
@@ -276,6 +293,10 @@ function returnPayParams() {
|
||||
}
|
||||
|
||||
function refScanPayOpen(payType) {
|
||||
if (payType == "member-account") {
|
||||
chooseUser();
|
||||
return;
|
||||
}
|
||||
if (payType == "deposit") {
|
||||
return refScanPay.value.open(returnPayParams(), "deposit");
|
||||
}
|
||||
@@ -288,8 +309,8 @@ async function getPaytype() {
|
||||
const res = await payTypeApi.getList();
|
||||
payTypes.list = res;
|
||||
}
|
||||
function nowPayClick() {
|
||||
const payType = payTypes.list[payTypes.sel].payType;
|
||||
function nowPayClick(payType) {
|
||||
payType = payType || payTypes.list[payTypes.sel].payType;
|
||||
if (payType === "cash") {
|
||||
ElMessageBox.confirm("是否确认已现金收款:" + currentpayMoney.value + "元", "快捷支付", {
|
||||
confirmButtonText: "确定",
|
||||
@@ -302,12 +323,20 @@ function nowPayClick() {
|
||||
.catch(() => {});
|
||||
return;
|
||||
}
|
||||
if (payType == "member-account") {
|
||||
if (!props.user.id) {
|
||||
return ElMessage.error("请先选择会员");
|
||||
}
|
||||
payOrder(payType);
|
||||
return;
|
||||
}
|
||||
refScanPayOpen(payType);
|
||||
}
|
||||
|
||||
function refScanPayConfirm(authCode, isScan) {
|
||||
let authCode = "";
|
||||
function refScanPayConfirm($authCode, isScan) {
|
||||
const payType = payTypes.list[payTypes.sel].payType;
|
||||
payParams.authCode = authCode;
|
||||
authCode = $authCode;
|
||||
payOrder(payType, isScan);
|
||||
}
|
||||
|
||||
@@ -325,6 +354,7 @@ async function payOrder(payType, isScan) {
|
||||
loading.close();
|
||||
}, 1000 * 20);
|
||||
let res = undefined;
|
||||
console.log(payType);
|
||||
try {
|
||||
if (payType == "scanCode") {
|
||||
res = isScan
|
||||
@@ -337,7 +367,15 @@ async function payOrder(payType, isScan) {
|
||||
if (payType == "deposit") {
|
||||
res = await payApi.vipPay({ ...returnPayParams(), payType: "scanCode" });
|
||||
}
|
||||
if (payType == "member-account") {
|
||||
res = await payApi.vipPay({
|
||||
...returnPayParams(),
|
||||
payType: "userPay",
|
||||
shopUserId: props.user.id,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
clearTimeout(payTimer);
|
||||
loading.close();
|
||||
}
|
||||
@@ -357,11 +395,21 @@ const currentpayMoney = computed(() => {
|
||||
}
|
||||
return (carts.payMoney - checkOrderPay.discountAmount).toFixed(2);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => currentpayMoney.value,
|
||||
(newval) => {
|
||||
if (newval * 1 <= 0) {
|
||||
payTypes.sel = payTypes.list.findIndex((v) => v.payType == "cash");
|
||||
}
|
||||
}
|
||||
);
|
||||
onMounted(() => {
|
||||
getPaytype();
|
||||
pointsInit();
|
||||
});
|
||||
defineExpose({
|
||||
nowPayClick,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user