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