商品弹窗修改
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<up-popup :show="visible" :round="20" mode="bottom" @close="close" :close-on-click-overlay="true">
|
<up-popup :show="visible" :round="20" mode="bottom" @close="close" :close-on-click-overlay="true">
|
||||||
<view class="shop_sku">
|
<view class="shop_sku">
|
||||||
<view class="positionabsolute">
|
|
||||||
<up-icon name="arrow-down" @click="close" color="#333" size="22"></up-icon>
|
|
||||||
</view>
|
|
||||||
<scroll-view scroll-y style="max-height: 60vh; width: 100%">
|
|
||||||
|
|
||||||
|
<scroll-view scroll-y style="max-height: 60vh; width: 100%">
|
||||||
|
<view class="positionabsolute">
|
||||||
|
<up-icon name="arrow-down" @click="close" color="#333" size="22"></up-icon>
|
||||||
|
</view>
|
||||||
<up-swiper :list="goods.images" @change="swiperChange" :current="swiperCurrent" radius="6px"
|
<up-swiper :list="goods.images" @change="swiperChange" :current="swiperCurrent" radius="6px"
|
||||||
height="250" @click="prveImgs(goods.images, goods.images[swiperCurrent])">
|
height="250" @click="prveImgs(goods.images, goods.images[swiperCurrent])">
|
||||||
</up-swiper>
|
</up-swiper>
|
||||||
@@ -159,17 +159,17 @@
|
|||||||
<view v-if="goods.type == 'package'" class="addShopping"
|
<view v-if="goods.type == 'package'" class="addShopping"
|
||||||
:class="shopCartNumber > 0 && allConditionsSatisfied ? 'active' : ''"
|
:class="shopCartNumber > 0 && allConditionsSatisfied ? 'active' : ''"
|
||||||
@click="submitSelection()">
|
@click="submitSelection()">
|
||||||
{{ skuBtnText }}
|
添加到购物车
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="addShopping" :class="shopCartNumber > 0 && canSubmit ? 'active' : ''"
|
<view v-else class="addShopping" :class="shopCartNumber > 0 && canSubmit ? 'active' : ''"
|
||||||
@click="submitSelection()">
|
@click="submitSelection()">
|
||||||
{{ skuBtnText }}
|
添加到购物车
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<view class="addShopping" :class="shopCartNumber > 0 ? 'active' : ''"
|
<view class="addShopping" :class="shopCartNumber > 0 ? 'active' : ''"
|
||||||
@click="submitSelection()">
|
@click="submitSelection()">
|
||||||
{{ skuBtnText }}
|
添加到购物车
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
@@ -205,7 +205,7 @@
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {
|
||||||
return {
|
return {
|
||||||
relatedRecommendJson:[]
|
relatedRecommendJson: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -275,7 +275,17 @@
|
|||||||
function returnFirstSku(product) {
|
function returnFirstSku(product) {
|
||||||
return product.skuList[0]
|
return product.skuList[0]
|
||||||
}
|
}
|
||||||
|
//返回是否是多规格商品
|
||||||
|
function returnIsSkuGoods(item) {
|
||||||
|
if (item.type == 'single' || item.type == 'weight' || (item.type == 'package' && item.groupType == '0')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isSkuGoods = computed(() => {
|
||||||
|
return returnIsSkuGoods(props.goods);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
function swiperChange(e) {
|
function swiperChange(e) {
|
||||||
@@ -343,8 +353,8 @@
|
|||||||
};
|
};
|
||||||
// 提交选择并执行下一步操作的方法
|
// 提交选择并执行下一步操作的方法
|
||||||
const submitSelection = async () => {
|
const submitSelection = async () => {
|
||||||
if (!isProductAvailable(specifications.productListitem.days, specifications.productListitem.startTime,
|
if (!isProductAvailable(props.goods.productListitem.days, props.goods.productListitem.startTime,
|
||||||
specifications.productListitem.endTime)) {
|
props.goods.productListitem.endTime)) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '不在可售时间内'
|
title: '不在可售时间内'
|
||||||
});
|
});
|
||||||
@@ -355,7 +365,7 @@
|
|||||||
if (shopCartNumber.value <= 0) {
|
if (shopCartNumber.value <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let res = await shoppingcart();
|
let res = null
|
||||||
|
|
||||||
if ((props.goods.type == 'package' && allConditionsSatisfied.value) || (props.goods.type ==
|
if ((props.goods.type == 'package' && allConditionsSatisfied.value) || (props.goods.type ==
|
||||||
'sku' && canSubmit.value)) {
|
'sku' && canSubmit.value)) {
|
||||||
@@ -370,12 +380,12 @@
|
|||||||
websocketsendMessage({
|
websocketsendMessage({
|
||||||
id: res ? res.cartListId : '',
|
id: res ? res.cartListId : '',
|
||||||
type: 'shopping',
|
type: 'shopping',
|
||||||
suitNum: specifications.productListitem.suitNum,
|
suitNum: props.goods.productListitem.suitNum,
|
||||||
table_code: uni.cache.get('tableCode'),
|
table_code: uni.cache.get('tableCode'),
|
||||||
shop_id: uni.cache.get('shopId'),
|
shop_id: uni.cache.get('shopId'),
|
||||||
operate_type: res ? 'edit' : 'add',
|
operate_type: res ? 'edit' : 'add',
|
||||||
product_id: specifications.product_id,
|
product_id: props.goods.product_id,
|
||||||
sku_id: specifications.sku_id,
|
sku_id: props.goods.sku_id,
|
||||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||||
shopCartNumber.value,
|
shopCartNumber.value,
|
||||||
pro_group_info: selectedGroupSnap.value,
|
pro_group_info: selectedGroupSnap.value,
|
||||||
@@ -392,12 +402,12 @@
|
|||||||
websocketsendMessage({
|
websocketsendMessage({
|
||||||
id: res ? res.cartListId : '',
|
id: res ? res.cartListId : '',
|
||||||
type: 'shopping',
|
type: 'shopping',
|
||||||
suitNum: specifications.productListitem.suitNum,
|
suitNum: props.goods.productListitem.suitNum,
|
||||||
table_code: uni.cache.get('tableCode'),
|
table_code: uni.cache.get('tableCode'),
|
||||||
shop_id: uni.cache.get('shopId'),
|
shop_id: uni.cache.get('shopId'),
|
||||||
operate_type: res ? 'edit' : 'add',
|
operate_type: res ? 'edit' : 'add',
|
||||||
product_id: specifications.product_id,
|
product_id: props.goods.product_id,
|
||||||
sku_id: specifications.sku_id,
|
sku_id: props.goods.sku_id,
|
||||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||||
shopCartNumber.value,
|
shopCartNumber.value,
|
||||||
memberPrice: props.goods.memberPrice,
|
memberPrice: props.goods.memberPrice,
|
||||||
@@ -412,14 +422,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 多规格 套餐 单规格添加数量
|
// 多规格 套餐 单规格添加数量
|
||||||
const shopCart = async (i) => {
|
const shopCart = async (i) => {
|
||||||
if (i == '-' && shopCartNumber.value <= (props.goods.suitNum || 1)) {
|
if (i == '-' && shopCartNumber.value <= (props.goods.suitNum || 1)) {
|
||||||
shopCartNumber.value = 0;
|
shopCartNumber.value = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let res = await shoppingcart();
|
let res = null
|
||||||
|
|
||||||
if (props.goods.result === 'kong') {
|
if (props.goods.result === 'kong') {
|
||||||
//没有满足可添加或者编辑的规格
|
//没有满足可添加或者编辑的规格
|
||||||
return;
|
return;
|
||||||
@@ -436,10 +446,10 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!res && shopCartNumber.value < 1) {
|
if (!res && shopCartNumber.value < 1) {
|
||||||
if (specifications.type == 'sku') {
|
if (props.goods.type == 'sku') {
|
||||||
shopCartNumber.value = parseFloat(selSku.value.suitNum);
|
shopCartNumber.value = parseFloat(selSku.value.suitNum);
|
||||||
} else {
|
} else {
|
||||||
shopCartNumber.value = parseFloat(selSku.value.suitNum);
|
shopCartNumber.value = parseFloat(props.goods.suitNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
shopCartNumber.value++;
|
shopCartNumber.value++;
|
||||||
|
|||||||
Reference in New Issue
Block a user