点餐页面限时折扣回显问题修复
This commit is contained in:
@@ -91,6 +91,10 @@
|
||||
<script setup>
|
||||
import * as distributionApi from "@/common/api/market/distribution.js";
|
||||
import { productStore } from "@/stores/user.js";
|
||||
import {
|
||||
APIuserlogin,
|
||||
APIuser
|
||||
} from "@/common/api/api.js";
|
||||
const storeuser = productStore();
|
||||
import { ref, onMounted, reactive } from "vue";
|
||||
import { onLoad, onReachBottom, onShow } from "@dcloudio/uni-app";
|
||||
@@ -222,7 +226,7 @@ onLoad(() => {
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
storeuser.actionsAPIuser().then((res) => {
|
||||
APIuser.then((res) => {
|
||||
userinfo.value = res;
|
||||
});
|
||||
});
|
||||
|
||||
23
lib/goods.ts
23
lib/goods.ts
@@ -182,33 +182,15 @@ function returnLimitPrice(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (canuseLimit) {
|
||||
//可以使用限时折扣
|
||||
if (limitTimeDiscount.discountPriority == "limit-time") {
|
||||
//限时价优先
|
||||
const result = BigNumber(goods.salePrice)
|
||||
.times(discountRate)
|
||||
.decimalPlaces(2, BigNumber.ROUND_UP)
|
||||
.toNumber();
|
||||
return result;
|
||||
}
|
||||
if (limitTimeDiscount.discountPriority == "vip-price") {
|
||||
|
||||
//会员价优先
|
||||
if (useVipPrice && goods.memberPrice && goods.memberPrice * 1 > 0) {
|
||||
//使用会员价
|
||||
return returnMemberPrice(useVipPrice, goods);
|
||||
} else {
|
||||
//不使用会员价
|
||||
const result = BigNumber(goods.salePrice)
|
||||
.times(discountRate)
|
||||
.decimalPlaces(2, BigNumber.ROUND_UP)
|
||||
.toNumber();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//不可以使用限时折扣
|
||||
//会员价优先
|
||||
if (useVipPrice) {
|
||||
//使用会员价
|
||||
@@ -217,7 +199,6 @@ function returnLimitPrice(
|
||||
return goods.salePrice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算商品计算门槛时的金额
|
||||
@@ -302,6 +283,8 @@ export function calcFullReductionActivityFullAmount(
|
||||
useVipPrice,
|
||||
"product_id"
|
||||
);
|
||||
console.log('calcPrice', calcPrice);
|
||||
console.log('goods', goods);
|
||||
if (calcPrice !== undefined) {
|
||||
amount += calcPrice * availableNum;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,8 @@
|
||||
<view class="relative">
|
||||
<image @click.stop="getImgs(item)" class="panelfiveitemimage" :src="item.coverImg"
|
||||
mode="aspectFill"></image>
|
||||
<view class="limitDiscount" v-if="showLimitDiscount(item)"
|
||||
>限时折扣{{ limitDiscountCountdown }}</view
|
||||
>
|
||||
<view class="limitDiscount" v-if="showLimitDiscount(item)">
|
||||
限时折扣{{ limitDiscountCountdown }}</view>
|
||||
<!-- <view class="limitDiscount" v-if="item.is_time_discount">
|
||||
限时折扣{{ limitDiscountCountdown }}</view> -->
|
||||
<view class="stock_warning" v-if="item.isStock&&item.stockNumber<=10">
|
||||
@@ -204,9 +203,8 @@
|
||||
<image class="goodsImg"
|
||||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/1.gif" mode=""
|
||||
v-else :lazy-load="true"></image>
|
||||
<view class="limitDiscount" v-if="showLimitDiscount(item1)"
|
||||
>限时折扣{{ limitDiscountCountdown }}</view
|
||||
>
|
||||
<view class="limitDiscount" v-if="showLimitDiscount(item1)">
|
||||
限时折扣{{ limitDiscountCountdown }}</view>
|
||||
|
||||
<!-- <view class="limitDiscount" v-if="item1.is_time_discount">
|
||||
限时折扣{{ limitDiscountCountdown }}</view> -->
|
||||
@@ -327,9 +325,9 @@
|
||||
<shopindex ref="showShopInfoRef"></shopindex>
|
||||
<!-- 购物车 -->
|
||||
<shoppingCartes :cartLists_count="cartLists_count" :cartList="matchedProducts" :showCart="showCart"
|
||||
:limitDiscount="cartStore.limitTimeDiscount" @customevent="websocketsendMessage" @close="showCart = !showCart"
|
||||
:orderinfo="orderinfo" @clickcancelOrder="clickcancelOrder" v-if="cartLists_count > 0"
|
||||
:nextFullAmountActivty="nextFullAmountActivty"></shoppingCartes>
|
||||
:limitDiscount="cartStore.limitTimeDiscount" @customevent="websocketsendMessage"
|
||||
@close="showCart = !showCart" :orderinfo="orderinfo" @clickcancelOrder="clickcancelOrder"
|
||||
v-if="cartLists_count > 0" :nextFullAmountActivty="nextFullAmountActivty"></shoppingCartes>
|
||||
|
||||
<!-- 显示购物车栏 -->
|
||||
<view class="cart-wrap" v-if="cartLists_count > 0 && !confirmordershow && isBusinessTime">
|
||||
@@ -446,8 +444,9 @@
|
||||
v-if="specifications.item.type != 'package' && specifications.item.result">
|
||||
<text class="i">¥</text>
|
||||
<view class="num">
|
||||
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="specifications.item.result"
|
||||
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
|
||||
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount"
|
||||
:cart="specifications.item.result" :shopUserInfo="shopUserInfo"
|
||||
:shopInfo="shopInfo"></GoodsPrice>
|
||||
</view>
|
||||
|
||||
<text class="num" v-if="false">
|
||||
@@ -481,7 +480,8 @@
|
||||
v-if="specifications.item.suitNum > 1">「{{ specifications.item.suitNum }}{{ specifications.item.unitName }}起点」</text>
|
||||
</view>
|
||||
|
||||
<view class="operation-wrap" v-if="specifications.item.type != 'package'&&stockNumberIsFull(specifications.item)">
|
||||
<view class="operation-wrap"
|
||||
v-if="specifications.item.type != 'package'&&stockNumberIsFull(specifications.item)">
|
||||
<view class="btn">
|
||||
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
|
||||
v-if="shopCartNumber > 0"></up-icon>
|
||||
@@ -1669,7 +1669,7 @@
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
time_dis_info: cartStore.limitTimeDiscount
|
||||
};
|
||||
|
||||
console.log('cartStore.limitTimeDiscount', cartStore.limitTimeDiscount)
|
||||
useSocket.sendMessage({
|
||||
type: 'shopping',
|
||||
operate_type: 'time_discount_save',
|
||||
@@ -1891,7 +1891,8 @@
|
||||
});
|
||||
}
|
||||
console.log('limitTimeDiscountRes', item)
|
||||
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo.is_time_discount ==
|
||||
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo
|
||||
.is_time_discount ==
|
||||
1) {
|
||||
//限时折扣
|
||||
const price = limitUtils.returnPrice({
|
||||
@@ -2302,9 +2303,12 @@
|
||||
extraInitPar.user_id = uni.cache.get('userInfo').id || ''
|
||||
}
|
||||
|
||||
const time_dis_info= await getLimitDiscount()
|
||||
|
||||
useSocket.connect({
|
||||
...options.initMessage,
|
||||
...extraInitPar
|
||||
...extraInitPar,
|
||||
time_dis_info
|
||||
}, onMessage);
|
||||
|
||||
|
||||
@@ -2351,9 +2355,9 @@
|
||||
|
||||
function showLimitDiscount(item) {
|
||||
if (!cartStore.limitTimeDiscount || !cartStore.limitTimeDiscount.id) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
return limitUtils.canUseLimitTimeDiscount(item, cartStore.limitTimeDiscount, shopInfo, shopUserInfo.value, 'id');
|
||||
return limitUtils.canUseLimitTimeDiscount(item, cartStore.limitTimeDiscount, shopInfo, shopUserInfo.value, 'id')?1:0;
|
||||
}
|
||||
|
||||
function returnLimitPrice(item) {
|
||||
@@ -2471,6 +2475,29 @@
|
||||
return 0
|
||||
})
|
||||
const oldOrder = ref(null);
|
||||
|
||||
// 限时折扣
|
||||
async function getLimitDiscount(){
|
||||
|
||||
const limitRes = await limitTimeDiscountapi.getConfig({
|
||||
shopId: uni.cache.get('shopId')
|
||||
});
|
||||
if (limitRes && typeof limitRes == 'object') {
|
||||
cartStore.limitTimeDiscount = limitRes;
|
||||
} else {
|
||||
cartStore.limitTimeDiscount = null;
|
||||
}
|
||||
return cartStore.limitTimeDiscount
|
||||
websocketsendMessage({
|
||||
type: 'shopping',
|
||||
operate_type: 'time_discount_save',
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: 'time_discount_save',
|
||||
data: cartStore.limitTimeDiscount
|
||||
});
|
||||
console.log('onMounted:限时折扣', cartStore.limitTimeDiscount);
|
||||
}
|
||||
onMounted(async () => {
|
||||
await proxy.$onLaunched;
|
||||
// 获取当前页面栈
|
||||
@@ -2484,37 +2511,11 @@
|
||||
getNewUserDiscount();
|
||||
// 满减活动
|
||||
getDiscountActivity();
|
||||
|
||||
let res = await APIhistoryOrder({
|
||||
tableCode: uni.cache.get('tableCode')
|
||||
});
|
||||
oldOrder.value = res;
|
||||
const limitRes = await limitTimeDiscountapi.getConfig({
|
||||
shopId: uni.cache.get('shopId')
|
||||
});
|
||||
if (limitRes && typeof limitRes == 'object') {
|
||||
cartStore.limitTimeDiscount = limitRes;
|
||||
console.log('onMounted:限时折扣',cartStore.limitTimeDiscount );
|
||||
websocketsendMessage({
|
||||
type: 'shopping',
|
||||
operate_type: 'time_discount_save',
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: 'time_discount_save',
|
||||
data: limitRes
|
||||
});
|
||||
} else {
|
||||
cartStore.limitTimeDiscount = null;
|
||||
console.log('onMounted:限时折扣',cartStore.limitTimeDiscount );
|
||||
websocketsendMessage({
|
||||
type: 'shopping',
|
||||
operate_type: 'time_discount_save',
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: 'time_discount_save',
|
||||
data: null
|
||||
});
|
||||
}
|
||||
|
||||
await productqueryProduct();
|
||||
if (res && res.id && shopInfo.registerType == 'after') {
|
||||
toHistory();
|
||||
|
||||
@@ -319,6 +319,9 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
//购物车商品信息补全初始化
|
||||
function cartsGoodsInfoInit(arr) {
|
||||
console.log('cartsGoodsInfoInit', arr)
|
||||
if(oldOrder.value&&oldOrder.value.status=='done'){
|
||||
return ''
|
||||
}
|
||||
carts.value = arr
|
||||
.map((v) => {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user