点餐页面限时折扣回显问题修复
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;
|
||||
});
|
||||
});
|
||||
|
||||
2009
lib/goods.ts
2009
lib/goods.ts
File diff suppressed because it is too large
Load Diff
@@ -49,14 +49,13 @@
|
||||
<view class="panelfive_list">
|
||||
<view class="panelfiveitem" @click="clickspecifications(item, index, index, '热销')"
|
||||
v-for="(item, index) in shopProductList.hots" :key="index">
|
||||
|
||||
|
||||
|
||||
<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,11 +203,10 @@
|
||||
<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="item1.is_time_discount">
|
||||
<view class="limitDiscount" v-if="showLimitDiscount(item1)">
|
||||
限时折扣{{ limitDiscountCountdown }}</view>
|
||||
|
||||
<!-- <view class="limitDiscount" v-if="item1.is_time_discount">
|
||||
限时折扣{{ limitDiscountCountdown }}</view> -->
|
||||
<view class="stock_warning" v-if="item1.isStock&&item1.stockNumber<=10">
|
||||
仅剩{{item1.stockNumber}}份</view>
|
||||
@@ -239,7 +237,7 @@
|
||||
<view class="name">{{ item1.name }}</view>
|
||||
<!-- <view class="lookBack" v-if="index=='0'">本店销量第{{index1+1}}名</view>-->
|
||||
<!-- <view class="lookBack" v-if="specifications.item.isHot == 1">热销</view> -->
|
||||
<view class="lookBack" v-if="returnIsHot(item1,item,index)">热销</view>
|
||||
<view class="lookBack" v-if="returnIsHot(item1,item,index)">热销</view>
|
||||
<view class="describe">{{ item1.shortTitle ? item1.shortTitle : '' }}</view>
|
||||
|
||||
<view class="describe" v-if="item1.suitNum > 1 && item1.type != 'sku'"
|
||||
@@ -272,10 +270,10 @@
|
||||
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
|
||||
</view>
|
||||
<text class="money_num" v-if="item1.unitName">/{{ item1.unitName }}</text>
|
||||
|
||||
|
||||
<text class="old-price"
|
||||
v-if="showLimitDiscount(item1)">¥{{ item1.salePrice }}</text>
|
||||
<!-- <text class="old-price"
|
||||
<!-- <text class="old-price"
|
||||
v-if="item1.is_time_discount">¥{{ item1.salePrice }}</text> -->
|
||||
<!-- <text v-if="item1.suitNum>1 && item1.type!= 'sku'"
|
||||
style="font-size: 14rpx;">
|
||||
@@ -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>
|
||||
@@ -521,8 +521,8 @@
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
@@ -1101,10 +1101,10 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//返回是否是热销商品
|
||||
function returnIsHot(item,category,index){
|
||||
return item.isHot&& category.name=='热销' &&index==0 && shopProductList.hots.find(v=>v.id==item.id)
|
||||
function returnIsHot(item, category, index) {
|
||||
return item.isHot && category.name == '热销' && index == 0 && shopProductList.hots.find(v => v.id == item.id)
|
||||
}
|
||||
|
||||
|
||||
@@ -1360,15 +1360,15 @@
|
||||
|
||||
return isInRange;
|
||||
};
|
||||
|
||||
|
||||
function stockNumberIsFull(item){
|
||||
if(item.isStock && item.stockNumber < item.suitNum){
|
||||
|
||||
|
||||
function stockNumberIsFull(item) {
|
||||
if (item.isStock && item.stockNumber < item.suitNum) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断商品是否可售
|
||||
* @param {Object} item
|
||||
@@ -1380,7 +1380,7 @@
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if ( item.isStock && item.stockNumber < item.suitNum && i == '+') {
|
||||
if (item.isStock && item.stockNumber < item.suitNum && i == '+') {
|
||||
uni.showToast({
|
||||
title: '库存不足',
|
||||
icon: 'none'
|
||||
@@ -1430,7 +1430,7 @@
|
||||
number: await calculateValue(item.cartNumber, i, suitNum),
|
||||
is_print: 1,
|
||||
product_type: item.type,
|
||||
is_time_discount: showLimitDiscount(item)
|
||||
is_time_discount: showLimitDiscount(item)
|
||||
};
|
||||
if (item.cartListId) {
|
||||
sendMsg.id = item.cartListId;
|
||||
@@ -1608,7 +1608,7 @@
|
||||
// 初始化
|
||||
if (Message.operate_type == 'init') {
|
||||
cartStore.limitTimeDiscount = Message.time_dis_info;
|
||||
console.log('onMessage:限时折扣',cartStore.limitTimeDiscount)
|
||||
console.log('onMessage:限时折扣', cartStore.limitTimeDiscount)
|
||||
cartInit(Message.data)
|
||||
|
||||
uni.hideLoading();
|
||||
@@ -1629,7 +1629,7 @@
|
||||
cancelText: '舍弃',
|
||||
confirmText: '合并',
|
||||
success(res) {
|
||||
showTableInfoPeopleNumPopup.value=false;
|
||||
showTableInfoPeopleNumPopup.value = false;
|
||||
if (res.confirm) {
|
||||
startUseTable({
|
||||
is_hb: 2
|
||||
@@ -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',
|
||||
@@ -1741,7 +1741,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (Message.operate_type == 'time_discount_save') {
|
||||
cartStore.limitTimeDiscount = Message.data;
|
||||
}
|
||||
@@ -1890,8 +1890,9 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log('limitTimeDiscountRes',item)
|
||||
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo.is_time_discount ==
|
||||
console.log('limitTimeDiscountRes', item)
|
||||
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo
|
||||
.is_time_discount ==
|
||||
1) {
|
||||
//限时折扣
|
||||
const price = limitUtils.returnPrice({
|
||||
@@ -1901,7 +1902,7 @@
|
||||
shopUserInfo: shopUserInfo.value,
|
||||
idKey: 'id'
|
||||
});
|
||||
console.log('限时折扣',price)
|
||||
console.log('限时折扣', price)
|
||||
return total + parseFloat(price) * parseFloat(item.cartNumber);
|
||||
}
|
||||
// 是否启用会员价 0否1是
|
||||
@@ -2301,10 +2302,13 @@
|
||||
extraInitPar.order_id = e.order_id
|
||||
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