优化代课下单优惠券选择
This commit is contained in:
@@ -5,7 +5,6 @@ import { useUserStoreHook } from "@/store/modules/user";
|
|||||||
import productApi from "@/api/product/index";
|
import productApi from "@/api/product/index";
|
||||||
import shopUserApi from '@/api/account/shopUser'
|
import shopUserApi from '@/api/account/shopUser'
|
||||||
import limitTimeDiscountApi from '@/api/market/limitTimeDiscount.js'
|
import limitTimeDiscountApi from '@/api/market/limitTimeDiscount.js'
|
||||||
import * as UTILS from "@/utils/coupon-utils.js";
|
|
||||||
import { BigNumber } from "bignumber.js";
|
import { BigNumber } from "bignumber.js";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
// 导入工具库及相关类型
|
// 导入工具库及相关类型
|
||||||
@@ -16,7 +15,8 @@ import {
|
|||||||
BackendCoupon,
|
BackendCoupon,
|
||||||
ActivityConfig,
|
ActivityConfig,
|
||||||
OrderExtraConfig, MerchantReductionConfig, MerchantReductionType,
|
OrderExtraConfig, MerchantReductionConfig, MerchantReductionType,
|
||||||
GoodsType, FullReductionActivity
|
GoodsType, FullReductionActivity,
|
||||||
|
couponUtils
|
||||||
} from "ysk-utils";
|
} from "ysk-utils";
|
||||||
|
|
||||||
// import {
|
// import {
|
||||||
@@ -253,10 +253,9 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 获取满减活动
|
// 获取满减活动
|
||||||
const fullReductionRes = await limitTimeDiscountApi.getDiscountActivity({
|
fullReductionActivities.value = await limitTimeDiscountApi.getDiscountActivity({
|
||||||
shopId: localStorage.getItem("shopId")
|
shopId: localStorage.getItem("shopId")
|
||||||
});
|
});
|
||||||
fullReductionActivities.value = fullReductionRes?.data || [];
|
|
||||||
|
|
||||||
if (limitDiscountRes.value !== null) {
|
if (limitDiscountRes.value !== null) {
|
||||||
checkLinkFinished().then(() => {
|
checkLinkFinished().then(() => {
|
||||||
@@ -431,13 +430,13 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
console.log('setCoupons', cps);
|
console.log('setCoupons', cps);
|
||||||
let goodsCoupon = cps.filter((v) => v.type == 2);
|
let goodsCoupon = cps.filter((v) => v.type == 2);
|
||||||
let otherCoupon = cps.filter((v) => v.type != 2);
|
let otherCoupon = cps.filter((v) => v.type != 2);
|
||||||
const canDikouGoodsArr = UTILS.returnCanDikouGoods(allGoods.value, [], vipUser.value);
|
const canDikouGoodsArr = couponUtils.returnCanDikouGoods(allGoods.value, [], vipUser.value);
|
||||||
//商品订单金额
|
//商品订单金额
|
||||||
const goodsOrderPrice = new BigNumber(orderCostSummary.value.goodsOriginalAmount)
|
const goodsOrderPrice = new BigNumber(orderCostSummary.value.goodsOriginalAmount)
|
||||||
.minus(orderCostSummary.value.goodsDiscountAmount)
|
.minus(orderCostSummary.value.goodsDiscountAmount)
|
||||||
.toFixed(2);
|
.toFixed(2);
|
||||||
goodsCoupon = goodsCoupon.map((v) => {
|
goodsCoupon = goodsCoupon.map((v) => {
|
||||||
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, [], shopUser.userInfo);
|
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, [], shopUser.userInfo);
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
discount,
|
discount,
|
||||||
@@ -445,7 +444,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
otherCoupon = otherCoupon.map((v) => {
|
otherCoupon = otherCoupon.map((v) => {
|
||||||
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, goodsCoupon, shopUser.userInfo);
|
const discount = couponUtils.returnCouponDiscount(canDikouGoodsArr, v, vipUser.value, goodsOrderPrice, goodsCoupon, shopUser.userInfo);
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
discount,
|
discount,
|
||||||
|
|||||||
@@ -387,10 +387,10 @@ export default {
|
|||||||
conName: v.conName,
|
conName: v.conName,
|
||||||
purchasePrice: v.price,
|
purchasePrice: v.price,
|
||||||
unitName: v.conUnit,
|
unitName: v.conUnit,
|
||||||
inOutNumber: v.number,
|
inOutNumber: inOutNumber,
|
||||||
subTotal: this.xiaoji(v),
|
subTotal: this.xiaoji(v),
|
||||||
imgUrls: v.imgUrls,
|
imgUrls: v.imgUrls,
|
||||||
number: inOutNumber,
|
number: v.number,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
if (this.type == "in") {
|
if (this.type == "in") {
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ async function freeDingGetAjax() {
|
|||||||
const res = await freeDingGet();
|
const res = await freeDingGet();
|
||||||
form.value = { ...res }
|
form.value = { ...res }
|
||||||
form.value.enable = res.enable ? 1 : 0
|
form.value.enable = res.enable ? 1 : 0
|
||||||
|
form.value.useShopType = res.useShopType || 'all'
|
||||||
|
|
||||||
if (res.enable == true) {
|
if (res.enable == true) {
|
||||||
if (shopInfo.value.shopType == 'only') {
|
if (shopInfo.value.shopType == 'only') {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<span class="sale_price">¥{{ item.time_discount_price }}</span>
|
<span class="sale_price">¥{{ item.time_discount_price }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="limit_wrap" v-else>
|
<div class="limit_wrap" v-else>
|
||||||
<template v-if="cartStore.useVipPrice">
|
<template v-if="cartStore.useVipPrice && item.lowPrice !== item.lowMemberPrice">
|
||||||
<span class="o_price">¥{{ item.lowPrice }}</span>
|
<span class="o_price">¥{{ item.lowPrice }}</span>
|
||||||
<span>¥{{ item.lowMemberPrice }}</span>
|
<span>¥{{ item.lowMemberPrice }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
<div class="order-box">
|
<div class="order-box">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="user bg-fff u-p-20">
|
<div class="user bg-fff u-p-20">
|
||||||
<div class="userinfo" v-if="user.id" @click="chooseUser">
|
<div class="userinfo" v-if="carts.vipUser.id" @click="chooseUser">
|
||||||
<el-avatar class="avatar" :size="50" />
|
<el-avatar :src="carts.vipUser.headImg" class="avatar" :size="50" />
|
||||||
<div class="u-m-l-12">
|
<div class="u-m-l-12">
|
||||||
<p>
|
<p>
|
||||||
<span class="name u-font-16">{{ user.nickName }}</span>
|
<span class="name u-font-16">{{ carts.vipUser.nickName }}</span>
|
||||||
<span class="vip" v-if="user.isVip">VIP{{ user.isVip }}</span>
|
<span class="vip" v-if="carts.vipUser.isVip">VIP{{ carts.vipUser.memberLevelName }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="u-font-14 color-666 u-m-t-10">
|
<p class="u-font-14 color-666 u-m-t-10">
|
||||||
<span class="money">余额:{{ user.amount }}</span>
|
<span class="money">余额:{{ carts.vipUser.amount }}</span>
|
||||||
<span class="score u-m-l-10">积分:{{ user.accountPoints }}</span>
|
<span class="score u-m-l-10">积分:{{ carts.vipUser.accountPoints }}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="user.id">
|
<template v-if="carts.vipUser.id">
|
||||||
<div class="score">
|
<div class="score">
|
||||||
<div class="u-flex u-col-center u-m-t-10">
|
<div class="u-flex u-col-center u-m-t-10">
|
||||||
<span class="u-font-14 font-bold u-m-r-20">积分抵扣</span>
|
<span class="u-font-14 font-bold u-m-r-20">积分抵扣</span>
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
<!-- 打折 -->
|
<!-- 打折 -->
|
||||||
<discount ref="refDiscount" @confirm="discountConfirm"></discount>
|
<discount ref="refDiscount" @confirm="discountConfirm"></discount>
|
||||||
<!-- 优惠券 -->
|
<!-- 优惠券 -->
|
||||||
<popup-coupon ref="refCoupon" :user="user" @confirm="refCouponConfirm"></popup-coupon>
|
<popup-coupon ref="refCoupon" :user="carts.vipUser" @confirm="refCouponConfirm"></popup-coupon>
|
||||||
<!-- 挂账 -->
|
<!-- 挂账 -->
|
||||||
<chooseGuaZahng ref="refGuaZhang" :payMoney="currentpayMoney" @confirm="refGuaZhangConfirm"></chooseGuaZahng>
|
<chooseGuaZahng ref="refGuaZhang" :payMoney="currentpayMoney" @confirm="refGuaZhangConfirm"></chooseGuaZahng>
|
||||||
</div>
|
</div>
|
||||||
@@ -413,11 +413,11 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
async function pointsInit() {
|
async function pointsInit() {
|
||||||
if (!props.user.id) {
|
if (!carts.vipUser.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await PointsApi.calcOrderUsablePoints({
|
const res = await PointsApi.calcOrderUsablePoints({
|
||||||
shopUserId: props.user.id,
|
shopUserId: carts.vipUser.id,
|
||||||
orderAmount: scoreMaxMoney.value,
|
orderAmount: scoreMaxMoney.value,
|
||||||
});
|
});
|
||||||
pointsRes.value = res;
|
pointsRes.value = res;
|
||||||
@@ -486,10 +486,10 @@ function changePayType(i) {
|
|||||||
const newCustomerDiscount = ref(null)
|
const newCustomerDiscount = ref(null)
|
||||||
async function getConsumeDiscountAjax() {
|
async function getConsumeDiscountAjax() {
|
||||||
try {
|
try {
|
||||||
if (props.user.id) {
|
if (carts.vipUser.id) {
|
||||||
newCustomerDiscount.value = await limitTimeDiscountApi.getConsumeDiscount({
|
newCustomerDiscount.value = await limitTimeDiscountApi.getConsumeDiscount({
|
||||||
shopId: localStorage.getItem("shopId"),
|
shopId: localStorage.getItem("shopId"),
|
||||||
shopUserId: props.user.id,
|
shopUserId: carts.vipUser.id,
|
||||||
orderId: props.orderInfo.id
|
orderId: props.orderInfo.id
|
||||||
})
|
})
|
||||||
console.log('根据用户id获取新客立减金额,返回null代表不可用', newCustomerDiscount.value);
|
console.log('根据用户id获取新客立减金额,返回null代表不可用', newCustomerDiscount.value);
|
||||||
@@ -509,7 +509,7 @@ function returnPayParams() {
|
|||||||
shopId: localStorage.getItem("shopId"),
|
shopId: localStorage.getItem("shopId"),
|
||||||
authCode: authCode,
|
authCode: authCode,
|
||||||
checkOrderPay: {
|
checkOrderPay: {
|
||||||
vipPrice: shopUser.userInfo.isMemberPrice && props.user.id && props.user.isVip ? 1 : 0,
|
vipPrice: shopUser.userInfo.isMemberPrice && carts.vipUser.id && carts.vipUser.isVip ? 1 : 0,
|
||||||
orderId: props.orderInfo.id,
|
orderId: props.orderInfo.id,
|
||||||
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
|
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
|
||||||
discountRatio: 0,
|
discountRatio: 0,
|
||||||
@@ -525,7 +525,7 @@ function returnPayParams() {
|
|||||||
discountActAmount: carts.orderCostSummary.fullReduction.actualAmount, // 满减活动金额
|
discountActAmount: carts.orderCostSummary.fullReduction.actualAmount, // 满减活动金额
|
||||||
discountActId: carts.orderCostSummary.fullReduction.usedThreshold !== undefined ? carts.orderCostSummary.fullReduction.usedThreshold.activityId : '', // 满减活动id
|
discountActId: carts.orderCostSummary.fullReduction.usedThreshold !== undefined ? carts.orderCostSummary.fullReduction.usedThreshold.activityId : '', // 满减活动id
|
||||||
couponList: carts.coupons.map((v) => v.id),
|
couponList: carts.coupons.map((v) => v.id),
|
||||||
userId: props.user.userId || "",
|
userId: carts.vipUser.userId || "",
|
||||||
allPack: carts.dinnerType == "take-out" ? 1 : 0,
|
allPack: carts.dinnerType == "take-out" ? 1 : 0,
|
||||||
limitRate: carts.limitDiscountRes,
|
limitRate: carts.limitDiscountRes,
|
||||||
newCustomerDiscountId: newCustomerDiscount.value !== null ? newCustomerDiscount.value.id : '', // 新客立减Id
|
newCustomerDiscountId: newCustomerDiscount.value !== null ? newCustomerDiscount.value.id : '', // 新客立减Id
|
||||||
@@ -574,7 +574,7 @@ function nowPayClick(payType) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (payType == "member-account") {
|
if (payType == "member-account") {
|
||||||
if (!props.user.id) {
|
if (!carts.vipUser.id) {
|
||||||
return ElMessage.error("请先选择会员");
|
return ElMessage.error("请先选择会员");
|
||||||
}
|
}
|
||||||
payOrder(payType);
|
payOrder(payType);
|
||||||
@@ -622,7 +622,7 @@ async function payOrder(payType, isScan, guazhangren) {
|
|||||||
res = await payApi.vipPay({
|
res = await payApi.vipPay({
|
||||||
...returnPayParams(),
|
...returnPayParams(),
|
||||||
payType: "userPay",
|
payType: "userPay",
|
||||||
shopUserId: props.user.id,
|
shopUserId: carts.vipUser.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (payType == "arrears") {
|
if (payType == "arrears") {
|
||||||
|
|||||||
@@ -136,7 +136,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<span class="row_t">成长值</span>
|
<span class="row_t">成长值</span>
|
||||||
<span class="row_b" style="margin-left: 6px;">{{ currentVipInfo.experience }}</span>
|
<span class="row_b" style="margin-left: 6px;">{{ currentVipInfo.experience }}</span>
|
||||||
<span class="tips">(距离{{ currentVipInfo.nextMemberLevelName }}还差{{ currentVipInfo.nextExperience }})</span>
|
<span class="tips" v-if="currentVipInfo.nextMemberLevelName">(距离{{ currentVipInfo.nextMemberLevelName }}还差{{
|
||||||
|
currentVipInfo.nextExperience }})</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user