优化结算选择优惠券
This commit is contained in:
@@ -92,7 +92,7 @@
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
import { findCoupon } from '@/api/account.js'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { couponUtils } from "ysk-utils";
|
||||
|
||||
@@ -202,48 +202,8 @@ function selectCoupon($event, e) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
updateSelCoupon()
|
||||
console.log('goodsStore.cartInfo===', goodsStore.cartInfo);
|
||||
|
||||
|
||||
|
||||
// if (query.value.type == 1) {
|
||||
// emits('success', { type: query.value.type, couponList: [{ ...row }] })
|
||||
// } else {
|
||||
|
||||
// let goods = [
|
||||
// ...goodsStore.cartList,
|
||||
// ...goodsStore.orderList.map(item => item.goods).flat()
|
||||
// ]
|
||||
|
||||
// let arr = tableRef2.value.getSelectionRows()
|
||||
|
||||
|
||||
// if (!arr.length) {
|
||||
// ElMessage.error('请选择优惠券')
|
||||
// return
|
||||
// }
|
||||
|
||||
// let obj = groupByPropertyAndCount(arr, 'proId')
|
||||
// let goodsObj = groupByPropertyAndCount(goods, 'product_id')
|
||||
|
||||
// console.log(obj);
|
||||
// console.log(goodsObj);
|
||||
|
||||
// for (let val of goodsObj) {
|
||||
// for (let item of obj) {
|
||||
// if (val.value == item.value) {
|
||||
// if (item.count > val.count) {
|
||||
// ElMessage.error('超出订单数量,请重新选择')
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// emits('success', { type: query.value.type, couponList: arr })
|
||||
// }
|
||||
// showDialog.value = false
|
||||
}
|
||||
|
||||
let orderPrice = ref(goodsStore.cartInfo.costSummary.goodsRealAmount);
|
||||
@@ -252,9 +212,14 @@ function updateSelCoupon() {
|
||||
|
||||
const user = goodsStore.vipUserInfo;
|
||||
let shopInfo = store.shopInfo;
|
||||
|
||||
if (!shopInfo.isMemberPrice) {
|
||||
shopInfo = {};
|
||||
}
|
||||
|
||||
console.log('updateSelCoupon.user', user);
|
||||
console.log('updateSelCoupon.shopInfo', shopInfo);
|
||||
|
||||
const canDikouGoodsArr = couponUtils.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
|
||||
|
||||
if (newval.length >= 2) {
|
||||
@@ -267,7 +232,8 @@ function updateSelCoupon() {
|
||||
user,
|
||||
orderPrice.value,
|
||||
[],
|
||||
shopInfo
|
||||
shopInfo,
|
||||
goodsStore.limitDiscountRes
|
||||
);
|
||||
return {
|
||||
...v,
|
||||
@@ -283,6 +249,7 @@ function updateSelCoupon() {
|
||||
user: user,
|
||||
selCoupon: goodsCoupon,
|
||||
shopInfo: shopInfo,
|
||||
limitTimeDiscount: goodsStore.limitDiscountRes
|
||||
});
|
||||
|
||||
const discount = couponUtils.returnCouponDiscount(
|
||||
@@ -291,7 +258,8 @@ function updateSelCoupon() {
|
||||
user,
|
||||
orderPrice.value,
|
||||
goodsCoupon,
|
||||
shopInfo
|
||||
shopInfo,
|
||||
goodsStore.limitDiscountRes
|
||||
);
|
||||
return {
|
||||
...v,
|
||||
@@ -382,7 +350,7 @@ function formatCoupon() {
|
||||
console.log('goodsOrderPrice==========', goodsOrderPrice);
|
||||
|
||||
|
||||
const canDikouGoodsArr = couponUtils.returnCanDikouGoods(goodsStore.cartInfo.allGoods, [], user);
|
||||
const canDikouGoodsArr = couponUtils.returnCanDikouGoods(goodsStore.cartInfo.allGoods, user, shopInfo);
|
||||
for (let i = 0; i < couponList.value.length; i++) {
|
||||
const coupon = couponList.value[i];
|
||||
const canuseResult = couponUtils.returnCouponCanUse({
|
||||
@@ -391,7 +359,8 @@ function formatCoupon() {
|
||||
goodsOrderPrice,
|
||||
user,
|
||||
selCoupon: quansSelArr.value,
|
||||
shopInfo
|
||||
shopInfo,
|
||||
limitTimeDiscount: goodsStore.limitDiscountRes
|
||||
});
|
||||
const { canUse, reason } = canuseResult;
|
||||
if (coupon.type == 2) {
|
||||
@@ -416,7 +385,7 @@ function formatCoupon() {
|
||||
}
|
||||
//商品券
|
||||
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
|
||||
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
|
||||
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo, goodsStore.limitDiscountRes);
|
||||
return {
|
||||
...v,
|
||||
discount,
|
||||
@@ -425,7 +394,7 @@ function formatCoupon() {
|
||||
});
|
||||
//非商品券
|
||||
canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
|
||||
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo);
|
||||
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo, goodsStore.limitDiscountRes);
|
||||
return {
|
||||
...v,
|
||||
discount,
|
||||
@@ -459,7 +428,6 @@ function formatCoupon() {
|
||||
console.log('noUseDiscountCoupon', noUseDiscountCoupon);
|
||||
|
||||
console.log('list===', list);
|
||||
|
||||
}
|
||||
|
||||
// 获取用户可用的优惠券
|
||||
@@ -515,11 +483,13 @@ async function findCouponAjax() {
|
||||
tableData.loading = false
|
||||
}
|
||||
|
||||
function show(userId) {
|
||||
async function show(userId) {
|
||||
showDialog.value = true
|
||||
query.value.userId = userId
|
||||
findCouponAjax()
|
||||
await findCouponAjax()
|
||||
console.log('couponModal.orderList===', props.orderList);
|
||||
// updateSelCoupon()
|
||||
// formatCoupon()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
||||
@@ -123,14 +123,14 @@
|
||||
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
||||
</el-dialog>
|
||||
<el-dialog v-model="showCoupon"
|
||||
:title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`" top="5vh" width="80%"
|
||||
:title="`添加优惠(商品原价:¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`" top="5vh" width="80%"
|
||||
@open="couponDialogOpen">
|
||||
<div class="coupom_dialog">
|
||||
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
||||
<el-form-item label="选择会员">
|
||||
<el-form-item label="选择用户">
|
||||
<div class="flex">
|
||||
<div class="select_wrap">
|
||||
<el-select placeholder="请选择会员" readonly v-model="couponFormUser.userId"
|
||||
<el-select placeholder="请选择用户" readonly v-model="couponFormUser.userId"
|
||||
@click="SelectVipUserRef.show()" style="width: 100%;">
|
||||
<el-option :label="item.nickName" :value="item.id" v-for="item in couponFormUserList"
|
||||
:key="item.id"></el-option>
|
||||
@@ -148,8 +148,12 @@
|
||||
<el-form-item label="优惠券">
|
||||
<div style="width: 100%;">
|
||||
<el-button type="primary"
|
||||
:disabled="!couponFormUser.id && (!couponResList1.length && !couponResList2.length)"
|
||||
@click="showCounponModalHandle">选择优惠券</el-button>
|
||||
v-if="(goodsStore.cartInfo.costSummary
|
||||
.fullReduction !== undefined && goodsStore.cartInfo.costSummary.fullReduction.actualAmount > 0)"
|
||||
disabled>参与满减活动不可用优惠券</el-button>
|
||||
<el-button type="primary"
|
||||
:disabled="(!couponFormUser.id && (!couponResList1.length && !couponResList2.length))"
|
||||
@click="showCounponModalHandle" v-else>选择优惠券</el-button>
|
||||
<div style="padding-top: 20px;">
|
||||
<el-table :data="couponResList1" border stripe>
|
||||
<el-table-column label="名称" prop="name"></el-table-column>
|
||||
@@ -231,7 +235,7 @@
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 选择会员 -->
|
||||
<SelectVipUser ref="SelectVipUserRef" :amount="0.01" @success="selectUserHandle" />
|
||||
<SelectVipUser ref="SelectVipUserRef" @success="selectUserHandle" />
|
||||
<!-- 选择优惠券 -->
|
||||
<CouponModal ref="CouponModalRef" :orderList="props.orderList" @success="CouponModalSuccess" />
|
||||
</template>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<el-dialog :title="`选择会员`" top="3vh" v-model="showDialog" width="80%">
|
||||
<el-dialog title="选择用户" top="3vh" v-model="showDialog" width="80%">
|
||||
<el-form inline>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入手机号搜索会员" v-model="tableData.phone" />
|
||||
<el-input placeholder="请输入手机号搜索用户" v-model="tableData.phone" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-select v-model="tableData.isVips" placeholder="是否为会员" style="width: 150px;" @change="changeIsVips">
|
||||
|
||||
Reference in New Issue
Block a user