更新购物车
This commit is contained in:
@@ -43,6 +43,9 @@
|
||||
<view class="panelfiveitemthere flex-start">
|
||||
<text>招牌</text>
|
||||
</view>
|
||||
<view class="describe" v-if="item.suitNum>1 && item.type!= 'sku'" style="font-size: 20rpx;">
|
||||
「{{item.suitNum}}{{item.unitName}}起点」
|
||||
</view>
|
||||
<!-- <view class="panelfiveitemfour">
|
||||
{{item.shortTitle?item.shortTitle:''}}
|
||||
</view>
|
||||
@@ -56,10 +59,9 @@
|
||||
<text class="tips"
|
||||
:class="shopInfo.isVip == 0 || shopInfo.isMemberPrice==0?'lineThrough':''">¥</text>
|
||||
<!-- 会员价与价格 -->
|
||||
<text
|
||||
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}}</text>
|
||||
<!-- 原价 -->
|
||||
<!-- <text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> -->
|
||||
<text class="price">
|
||||
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}}
|
||||
</text>
|
||||
<!-- 单位 -->
|
||||
<text class="unit" v-if="item.unitName">/{{item.unitName}}</text>
|
||||
</view>
|
||||
@@ -72,18 +74,19 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else class="flex-between" style="margin-top: 32rpx;margin-bottom: 48rpx;">
|
||||
<view v-else class="flex-between"
|
||||
style="margin-top: 32rpx;margin-bottom: 48rpx; flex-wrap: inherit">
|
||||
<view class="panelfiveitemsex flex-between">
|
||||
<view class="panelfiveitemsex_oen">
|
||||
<text class="tips"
|
||||
:class="shopInfo.isVip ==0 || shopInfo.isMemberPrice==0?'lineThrough':''">¥</text>
|
||||
<!-- 会员价与价格 -->
|
||||
<text
|
||||
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice|| item.salePrice):item.salePrice}}</text>
|
||||
<!-- 原价 -->
|
||||
<!-- <text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> -->
|
||||
<!-- 单位 -->
|
||||
<text class="price">
|
||||
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice|| item.salePrice):item.salePrice}}
|
||||
</text>
|
||||
<text class="unit" v-if="item.unitName">/{{item.unitName}}</text>
|
||||
<!-- <text v-if="item.suitNum>1 && item.type!= 'sku'"
|
||||
style="font-size: 16rpx;">「{{item.suitNum}}{{item.unitName}}起点」</text> -->
|
||||
</view>
|
||||
</view>
|
||||
<!-- single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券 -->
|
||||
@@ -105,8 +108,6 @@
|
||||
</view>
|
||||
</view>
|
||||
<text class="num"> {{ ifcartNumber(item) }} </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"
|
||||
@@ -162,6 +163,11 @@
|
||||
<view class="lookBack" v-if="specifications.item.isHot == 1">热销</view>
|
||||
<view class="describe"> {{item1.shortTitle?item1.shortTitle:''}} </view>
|
||||
|
||||
<view class="describe" v-if="item1.suitNum>1 && item1.type!= 'sku'"
|
||||
style="font-size: 20rpx;">
|
||||
「{{item1.suitNum}}{{item1.unitName}}起点」
|
||||
</view>
|
||||
|
||||
<view v-if="item1.isSoldStock == 1 || item1.isSaleTime == 0" class="flex-between">
|
||||
<view class="money">
|
||||
<view>¥</view>
|
||||
@@ -177,13 +183,17 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="flex-between">
|
||||
<view v-else class="flex-between" style="flex-wrap: inherit;">
|
||||
<view class="money">
|
||||
<view>¥</view>
|
||||
<text class="money_num" style="margin-right: 10rpx;">
|
||||
<text class="money_num">
|
||||
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item1.memberPrice||item1.salePrice):item1.salePrice}}
|
||||
</text>
|
||||
<text v-if="item1.unitName">/{{item1.unitName}}</text>
|
||||
<text class="money_num" v-if="item1.unitName">/{{item1.unitName}}</text>
|
||||
<!-- <text v-if="item1.suitNum>1 && item1.type!= 'sku'"
|
||||
style="font-size: 14rpx;">
|
||||
「{{item1.suitNum}}{{item1.unitName}}起点」
|
||||
</text> -->
|
||||
</view>
|
||||
<view class="flex-end"
|
||||
v-if="item1.type == 'sku' || (item1.type == 'package' && item1.groupType == '1')">
|
||||
@@ -233,8 +243,8 @@
|
||||
<!-- 店铺详情 -->
|
||||
<shopindex ref="showShopInfoRef"></shopindex>
|
||||
<!-- 购物车 -->
|
||||
<shoppingCartes :cartLists_count="cartLists_count" :cartList="matchedProducts" :showCart="showCart"
|
||||
@customevent='websocketsendMessage' @close="showCart = !showCart">
|
||||
<shoppingCartes :cartLists_count="cartLists_count" v-if="matchedProducts.length>0" :cartList="matchedProducts"
|
||||
:showCart="showCart" @customevent='websocketsendMessage' @close="showCart = !showCart">
|
||||
</shoppingCartes>
|
||||
|
||||
<!-- 显示购物车栏 -->
|
||||
@@ -325,12 +335,21 @@
|
||||
<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>
|
||||
<text v-if="specifications.item.result.suitNum>1">
|
||||
「{{specifications.item.result.suitNum}}{{specifications.item.result.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" v-if="specifications.item.unitName">/{{specifications.item.unitName}}</text>
|
||||
<text class="num">
|
||||
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? (specifications.item.memberPrice||specifications.item.salePrice):specifications.item.salePrice}}
|
||||
</text>
|
||||
<text class="i" v-if="specifications.item.unitName">
|
||||
/{{specifications.item.unitName}}
|
||||
</text>
|
||||
<text v-if="specifications.item.suitNum>1">
|
||||
「{{specifications.item.suitNum}}{{specifications.item.unitName}}起点」
|
||||
</text>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -393,6 +412,7 @@
|
||||
import shoppingCartes from './components/shoppingCartes.vue'
|
||||
import confirmorder from './components/confirmorder.vue'
|
||||
import Loading from '@/components/Loading.vue';
|
||||
|
||||
// 获取全局属性
|
||||
const {
|
||||
proxy
|
||||
@@ -468,9 +488,7 @@
|
||||
|
||||
try {
|
||||
const shopExtend = uni.cache.get('shopTable').shopExtendMap.shopinfo_bg
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
// 计算高度
|
||||
const navScroll = ref(null)
|
||||
@@ -591,11 +609,6 @@
|
||||
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
|
||||
uni.$u.debounce(navScroll.value = res.scrollTop, 500)
|
||||
uni.$u.debounce(mainScroll(res), 500)
|
||||
if (res.scrollTop >= 44) {
|
||||
// store.showSearch = true
|
||||
} else {
|
||||
// store.showSearch = false
|
||||
}
|
||||
});
|
||||
|
||||
// 点击详情
|
||||
@@ -683,8 +696,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 存储选中的选项
|
||||
|
||||
// 监听 specifications 的变化
|
||||
watch(
|
||||
() => specifications.item.groupSnap,
|
||||
@@ -695,7 +706,6 @@
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// 存储选中的选项,二维数组
|
||||
const selectedOptions = ref(
|
||||
specifications.item.groupSnap.map(() => [])
|
||||
@@ -763,12 +773,25 @@
|
||||
//添加购物车数量
|
||||
const shopCartNumber = ref(0)
|
||||
|
||||
// 多规格 去添加购物车
|
||||
const shopCart = (i) => {
|
||||
if (i == '+') {
|
||||
shopCartNumber.value++;
|
||||
// 多规格 套餐添加数量
|
||||
const shopCart = async (i) => {
|
||||
let res = await shoppingcart()
|
||||
if (i == '-') {
|
||||
if (!res && shopCartNumber.value == specifications.item.suitNum) {
|
||||
uni.showToast({
|
||||
title: `起点${specifications.item.suitNum}`,
|
||||
icon: 'none'
|
||||
})
|
||||
return false;
|
||||
} else {
|
||||
shopCartNumber.value--;
|
||||
}
|
||||
} else {
|
||||
shopCartNumber.value--;
|
||||
if (!res && shopCartNumber.value < 1) {
|
||||
shopCartNumber.value = parseFloat(specifications.item.suitNum);
|
||||
} else {
|
||||
shopCartNumber.value++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,62 +867,65 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 判断多规格和套餐 商品是否在购物车有数据
|
||||
const shoppingcart = async () => {
|
||||
let res = null
|
||||
if (specifications.item.type == "package") {
|
||||
if (!allConditionsSatisfied.value) {
|
||||
return false
|
||||
}
|
||||
// 是否是套餐package
|
||||
selectedGroupSnap.value = specifications.item.groupSnap.map((setmenu, index) => {
|
||||
return {
|
||||
...setmenu,
|
||||
goods: selectedOptions.value[index]
|
||||
};
|
||||
});
|
||||
res = await matchingProduct(selectedGroupSnap.value)
|
||||
} else {
|
||||
if (!canSubmit.value) {
|
||||
return false
|
||||
}
|
||||
res = await matchingProduct(specifications.item.result)
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// 提交选择并执行下一步操作的方法
|
||||
const submitSelection = async () => {
|
||||
if (shopCartNumber.value <= 0) {
|
||||
return;
|
||||
}
|
||||
let res = await shoppingcart()
|
||||
console.log(res)
|
||||
|
||||
if (shopCartNumber.value > 0) {
|
||||
let res = null
|
||||
if (specifications.item.type == "package") {
|
||||
if (!allConditionsSatisfied.value) {
|
||||
return false
|
||||
}
|
||||
// 是否是套餐package
|
||||
selectedGroupSnap.value = specifications.item.groupSnap.map((setmenu, index) => {
|
||||
return {
|
||||
...setmenu,
|
||||
goods: selectedOptions.value[index]
|
||||
};
|
||||
});
|
||||
res = await matchingProduct(selectedGroupSnap.value)
|
||||
} else {
|
||||
if (!canSubmit.value) {
|
||||
return false
|
||||
}
|
||||
res = await matchingProduct(specifications.item.result)
|
||||
}
|
||||
console.log(res, 'res')
|
||||
if (res) {
|
||||
await calculateValue(res.cartNumber, '+', shopCartNumber.value)
|
||||
}
|
||||
// 是否是套餐 有就传
|
||||
if (specifications.item.type != "package") {
|
||||
selectedGroupSnap.value = []
|
||||
}
|
||||
|
||||
websocketsendMessage({
|
||||
id: res ? res.cartListId : '',
|
||||
type: 'shopping',
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: res ? 'edit' : 'add',
|
||||
product_id: specifications.product_id,
|
||||
sku_id: specifications.sku_id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
shopCartNumber.value,
|
||||
pro_group_info: selectedGroupSnap.value,
|
||||
goods_type: specifications.item.type == "package" ? 'package' : '',
|
||||
is_print: 1,
|
||||
product_type: specifications.item.type
|
||||
})
|
||||
// 清空套餐选中
|
||||
// 是否是套餐 有就传
|
||||
if (specifications.item.type != "package") {
|
||||
selectedGroupSnap.value = []
|
||||
showShopsku.value = false
|
||||
}
|
||||
|
||||
websocketsendMessage({
|
||||
id: res ? res.cartListId : '',
|
||||
type: 'shopping',
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: res ? 'edit' : 'add',
|
||||
product_id: specifications.product_id,
|
||||
sku_id: specifications.sku_id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) : shopCartNumber
|
||||
.value,
|
||||
pro_group_info: selectedGroupSnap.value,
|
||||
goods_type: specifications.item.type == "package" ? 'package' : '',
|
||||
is_print: 1,
|
||||
product_type: specifications.item.type
|
||||
})
|
||||
// 清空套餐选中
|
||||
selectedGroupSnap.value = []
|
||||
showShopsku.value = false
|
||||
}
|
||||
|
||||
|
||||
//获取多规格数据
|
||||
const clickspecifications = async (item, index, indexs, type) => {
|
||||
if (item.isSoldStock == 1 || item.isSaleTime == 0) {
|
||||
@@ -939,6 +965,7 @@
|
||||
|
||||
// 单规格
|
||||
const singleclick = async (item, i) => {
|
||||
console.log(item)
|
||||
// 判断购物车是否有该选中商品
|
||||
let res = null
|
||||
try {
|
||||
@@ -948,15 +975,24 @@
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
// 是否起售 如果小于或者大于都是1
|
||||
let suitNum = 1;
|
||||
const cartNumberFloat = parseFloat(item.cartNumber);
|
||||
if (!res && item.suitNum > cartNumberFloat) {
|
||||
suitNum = item.suitNum;
|
||||
} else if (item.suitNum >= cartNumberFloat && i === '-') {
|
||||
suitNum = item.cartNumber;
|
||||
}
|
||||
websocketsendMessage({
|
||||
id: res ? item.cartListId : '',
|
||||
type: 'shopping',
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: await calculateValue(item.cartNumber, i) == 'del' ? 'del' : res ? 'edit' : 'add',
|
||||
operate_type: await calculateValue(item.cartNumber, i, suitNum) == 'del' ? 'del' : res ?
|
||||
'edit' : 'add',
|
||||
product_id: item.id,
|
||||
sku_id: item.skuId,
|
||||
number: await calculateValue(item.cartNumber, i),
|
||||
number: await calculateValue(item.cartNumber, i, suitNum),
|
||||
is_print: 1,
|
||||
product_type: item.type
|
||||
})
|
||||
@@ -1379,11 +1415,12 @@
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '暂无列表数据...'
|
||||
title: '暂无列表数据,请重新扫码',
|
||||
icon: "none"
|
||||
});
|
||||
isDataLoaded.value = false;
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
uni.pro.switchTab('index/index')
|
||||
}, 1000)
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user