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