增加网络波动加载中,增加会员信息扫码充值

This commit is contained in:
wwz
2025-03-26 17:58:52 +08:00
parent 3a6fa55234
commit 98ce8b5544
18 changed files with 1018 additions and 128 deletions

View File

@@ -10,12 +10,14 @@
<view class="panelone">
{{ shopInfo.shopName }}
</view>
<view class="paneltow">
<view class="paneltow" v-if="distance">
距离您{{ distance }}
</view>
<view class="panelthere flex-between">
<view class="paneltheretext">
营业时间{{ (shopInfo.businessStartDay || '--') +' 至 '+ (shopInfo.businessEndDay || '--') +' '+ (shopInfo.businessTime || '')}}
营业时间{{ (shopInfo.businessStartDay || '--') +' 至 '+ (shopInfo.businessEndDay || '--')}}
{{endTimeref.startTime}} -
{{endTimeref.endTime < '05'?` 凌晨${endTimeref.endTime}`:endTimeref.endTime}}
</view>
<view class="flex-start" @click="callChildMethod">
<view style="margin-right: 14rpx;">查看</view>
@@ -103,8 +105,8 @@
</view>
</view>
<text class="num"> {{ ifcartNumber(item) }} </text>
<text class="dot num"
v-if="item.suitNum>1">{{item.suitNum<99?item.suitNum:'99+'}}</text>
<!-- <text class="dot num"
v-if="item.suitNum>1">{{item.suitNum<99?item.suitNum:'99+'}}</text> -->
<view class="btn">
<up-icon name="plus-circle-fill" color="#E9AB7A" size="25"></up-icon>
<view class="btnClick"
@@ -304,7 +306,8 @@
:key="goodsid" @click="goodsidClick(setmenuindex, option, goodsid)"
:class="{ shop_sku_box_item_selected: isOptionSelected(setmenuindex, option)}"
:disabled="isMaxSelected(setmenuindex) &&!isOptionSelected(setmenuindex, option)">
{{option.proName}}/{{option.unitName}}
{{option.proName}}
<text v-if="option.unitName">/{{option.unitName}}</text>
<view class="shop_sku_box_item_tip" v-if="specifications.item.isPauseSale == 1">
<view>售罄</view>
</view>
@@ -316,12 +319,21 @@
</scroll-view>
<view class="shop_bottom">
<view class="flex-between">
<view class="price">
<view class="price" v-if="specifications.item.type != 'package' && specifications.item.result">
<text class="i"></text>
<text
class="num">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? (specifications.item.result.memberPrice||specifications.item.result.salePrice):specifications.item.result.salePrice}}</text>
<text class="i" v-if="specifications.item.unitName">/{{specifications.item.unitName}}</text>
</view>
<view class="price" v-else>
<text class="i"></text>
<text
class="num">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? (specifications.item.memberPrice||specifications.item.salePrice):specifications.item.salePrice}}</text>
<text class="i">/{{specifications.item.unitName}}</text>
<text class="i" v-if="specifications.item.unitName">/{{specifications.item.unitName}}</text>
</view>
<view class="operation-wrap">
<view class="btn">
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
@@ -351,6 +363,8 @@
</view>
</view>
</up-popup>
<Loading :isLoading="isLoading" />
</view>
</template>
@@ -378,6 +392,7 @@
import shopindex from './components/shopindex.vue'
import shoppingCartes from './components/shoppingCartes.vue'
import confirmorder from './components/confirmorder.vue'
import Loading from '@/components/Loading.vue';
// 获取全局属性
const {
proxy
@@ -441,6 +456,9 @@
//店铺详情
const showShopInfoRef = ref(null)
// 初始加载中
const isLoading = ref(true);
//调用shop组件
const callChildMethod = () => {
if (showShopInfoRef.value) {
@@ -639,13 +657,13 @@
specInfo: selectedSpecsStr.value,
id: specifications.item.id
});
console.log(result)
// console.log(result)
if (result != true) {
specifications.sku_id = result.id
specifications.product_id = result.productId
// 添加多规格分组
specifications.item.result = result
console.log(specifications.item)
// console.log(specifications.item)
if (result.isPauseSale == 0) {
canSubmit.value = true;
} else {
@@ -811,8 +829,10 @@
// 直接返回布尔值
return result;
} else if (specifications.item.type == 'sku') {
// console.log(product,data, 'product,data')
// 多规格
return product.skuId == data.id && product.id == data.productId
return product.cartListinfo.sku_id == data.id && product.cartListinfo.product_id == data
.productId
} else {
// 其他
return product.skuId == data.skuId && product.id == data.id
@@ -845,6 +865,7 @@
}
res = await matchingProduct(specifications.item.result)
}
console.log(res, 'res')
if (res) {
await calculateValue(res.cartNumber, '+', shopCartNumber.value)
}
@@ -852,6 +873,7 @@
if (specifications.item.type != "package") {
selectedGroupSnap.value = []
}
websocketsendMessage({
id: res ? res.cartListId : '',
type: 'shopping',
@@ -1000,7 +1022,7 @@
product.cartNumber = cartItem.number
product.cartListId = cartItem.id
}
});
});
});
});
// 遍历购物车数组
@@ -1044,6 +1066,9 @@
// 初始化
if (Message.operate_type == "init") {
cartList.value = Message.data
setTimeout(()=>{
isLoading.value = false;
},1000)
}
// 清空购物车
@@ -1160,6 +1185,14 @@
if (matchedProducts.value.length > 0) {
// 购物车总数价格
let cart = matchedProducts.value.reduce((total, item) => {
if (item.type == 'sku') {
item.skuList.forEach((i, t) => {
if (item.cartListinfo.sku_id == i.id) {
item.memberPrice = i.memberPrice
item.salePrice = i.salePrice
}
})
}
// 是否启用会员价 0否1是
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice会员价
@@ -1170,7 +1203,6 @@
return total + parseFloat(item.salePrice || 0) * parseFloat(item.cartNumber);
}
}, 0);
// 向上取整并保留两位小数
return parseFloat(cart.toFixed(2));
} else {
return 0
@@ -1279,6 +1311,11 @@
// return isInDayRange && isInTimeRange;
// });
const endTimeref = reactive({
startTime: '',
endTime: ''
})
// 获取当前时间
const getCurrentTime = () => {
const now = new Date();
@@ -1294,6 +1331,12 @@
}
const currentTime = getCurrentTime();
const [startTime, endTime] = shopInfo.businessTime.split('-');
endTimeref.startTime = startTime
endTimeref.endTime = endTime
// 如果开始时间大于结束时间,说明是跨天的营业时间
if (startTime > endTime) {
return currentTime >= startTime || currentTime <= endTime;
}
return currentTime >= startTime && currentTime <= endTime;
});
@@ -1303,7 +1346,15 @@
try {
shopProductList.hots = await productminiApphotsquery()
shopProductList.productInfo = await APIgroupquery()
} catch (error) {}
} catch (error) {
uni.showToast({
title: '网络不稳定,请重新扫码进入',
icon: 'none'
})
setTimeout(() => {
uni.pro.switchTab('index/index')
}, 1000)
}
if (shopProductList.productInfo.length > 0 || shopProductList.hots.length > 0) {
//TODO handle the exception
//第一步:将所有商品的 cartNumber 初始化为 0