|
|
@@ -1,5 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
import type { LoadMoreState } from 'wot-design-uni/components/wd-loadmore/types'
|
|
|
+import selectSku from '../../components/select-sku/index.vue'
|
|
|
import { StaticUrl } from '@/config'
|
|
|
import router from '@/router'
|
|
|
|
|
|
@@ -14,6 +15,11 @@ const cartList = ref<Api.xsbCategoriesCartList[]>([])
|
|
|
const cartIds = computed(() => cartList.value.filter(it => it.isDelete !== '1' && it.shopSkuStocks !== '0').map(it => it.id))
|
|
|
const showball = ref(false)
|
|
|
const _this = getCurrentInstance()
|
|
|
+const selectGoods = ref(false)
|
|
|
+// 多规格商品skuid
|
|
|
+const selectSkuId = ref(0)
|
|
|
+const SelectGoodsNum = ref(1)
|
|
|
+const goodsInfo = ref<Api.xsbCategoryProductList | Api.xsbProductDetail | undefined>()
|
|
|
definePage({
|
|
|
name: 'xsb-classfiy',
|
|
|
islogin: false,
|
|
|
@@ -59,10 +65,6 @@ function handleTopNavChange(item: Api.xsbCategoriesChildren) {
|
|
|
})
|
|
|
getProductList()
|
|
|
}
|
|
|
-function handleOpen() {
|
|
|
- show.value = true
|
|
|
- console.log(navHeight.value, '打开')
|
|
|
-}
|
|
|
|
|
|
const categories = computed(() => {
|
|
|
return classfiylist.value.find(it => it.code === topNavActive.value)?.children || []
|
|
|
@@ -104,6 +106,7 @@ async function getProductList() {
|
|
|
productList.value = res.data
|
|
|
goodsLoading.value = 'finished'
|
|
|
isTopLoading.value = false
|
|
|
+ setProductNum()
|
|
|
}
|
|
|
|
|
|
function handlScrollBottom() {
|
|
|
@@ -126,14 +129,17 @@ function handleSrollTop() {
|
|
|
}
|
|
|
}
|
|
|
async function handleAddCart(event: WechatMiniprogram.TouchEvent, item: Api.xsbCategoryProductList) {
|
|
|
- console.log(event.detail.x, item)
|
|
|
- if (showball.value)
|
|
|
- return
|
|
|
if (!token.value) {
|
|
|
useGlobalToast().show('请先登录!')
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ if (item.skuList.length > 1) {
|
|
|
+ goodsInfo.value = item
|
|
|
+ selectGoods.value = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (showball.value)
|
|
|
+ return
|
|
|
basllObj.value.left = event.detail.x
|
|
|
basllObj.value.top = event.detail.y
|
|
|
showball.value = true
|
|
|
@@ -141,8 +147,35 @@ async function handleAddCart(event: WechatMiniprogram.TouchEvent, item: Api.xsbC
|
|
|
showball.value = false
|
|
|
}, 500)
|
|
|
await useSmqjhCartStore().addCart(item.skuList[0].skuId, 1, Number(item.shopId), 'XSB')
|
|
|
- getCartCategorList()
|
|
|
+ await getCartCategorList()
|
|
|
+ setProductNum()
|
|
|
}
|
|
|
+async function handleSubCart(event: WechatMiniprogram.TouchEvent, item: Api.xsbCategoryProductList) {
|
|
|
+ if (item.num === 1) {
|
|
|
+ useGlobalMessage().confirm({
|
|
|
+ msg: '是否删除该商品?',
|
|
|
+ success: async () => {
|
|
|
+ await useSmqjhCartStore().addCart(item.skuList[0].skuId, -1, Number(item.shopId), 'XSB')
|
|
|
+ await getCartCategorList()
|
|
|
+ setProductNum()
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (showball.value)
|
|
|
+ return
|
|
|
+ basllObj.value.left = event.detail.x
|
|
|
+ basllObj.value.top = event.detail.y
|
|
|
+ showball.value = true
|
|
|
+ setTimeout(() => {
|
|
|
+ showball.value = false
|
|
|
+ }, 500)
|
|
|
+ await useSmqjhCartStore().addCart(item.skuList[0].skuId, -1, Number(item.shopId), 'XSB')
|
|
|
+ await getCartCategorList()
|
|
|
+ setProductNum()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
if (!topNavActive.value || !leftActive.value) {
|
|
|
topNavActive.value = props.categoryList[0].code || ''
|
|
|
@@ -186,8 +219,10 @@ function handleGo(item: Api.xsbCategoryProductList) {
|
|
|
}
|
|
|
|
|
|
async function getGoodsPrice() {
|
|
|
- const res = await useSmqjhCartStore().getCartAddGoodsPrice(cartIds.value.join(','))
|
|
|
- totalProduct.value = res
|
|
|
+ if (cartIds.value.length) {
|
|
|
+ const res = await useSmqjhCartStore().getCartAddGoodsPrice(cartIds.value.join(','))
|
|
|
+ totalProduct.value = res
|
|
|
+ }
|
|
|
}
|
|
|
async function handleSub(item: Api.xsbCategoriesCartList) {
|
|
|
if (item.num === 1) {
|
|
|
@@ -216,6 +251,50 @@ onUnmounted(() => {
|
|
|
topNavActive.value = ''
|
|
|
leftActive.value = ''
|
|
|
})
|
|
|
+async function handleDelCartGoods(item: Api.xsbCategoriesCartList) {
|
|
|
+ const msg = item.isDelete ? '商品已被商家删除,是否确认删除该门店下的商品?' : '门店商品库存不足,是否删除该门店下的商品?'
|
|
|
+ useGlobalMessage().confirm({
|
|
|
+ title: '提示',
|
|
|
+ msg,
|
|
|
+ success: async () => {
|
|
|
+ uni.showLoading({ mask: true })
|
|
|
+ try {
|
|
|
+ await Apis.common.deleteShoppingCart({
|
|
|
+ pathParams: {
|
|
|
+ ids: String(item.id),
|
|
|
+ },
|
|
|
+ })
|
|
|
+ await getCartCategorList()
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ catch {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+function setProductNum() {
|
|
|
+ if (!cartList.value.length) {
|
|
|
+ productList.value = productList.value.map((goods) => {
|
|
|
+ goods.num = undefined
|
|
|
+ return goods
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ cartList.value.forEach((it) => {
|
|
|
+ productList.value = productList.value.map((goods) => {
|
|
|
+ if (goods.skuList.length && goods.skuList[0].skuId === it.skuId) {
|
|
|
+ goods.num = it.num
|
|
|
+ }
|
|
|
+ return goods
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+async function handleSkuAddCart() {
|
|
|
+ await useSmqjhCartStore().addCart(unref(selectSkuId), unref(SelectGoodsNum), Number(goodsInfo.value?.shopId), 'XSB')
|
|
|
+ getGoodsPrice()
|
|
|
+ await getCartCategorList()
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -276,7 +355,7 @@ onUnmounted(() => {
|
|
|
</scroll-view>
|
|
|
<view
|
|
|
class="right-nav box-border h144rpx w64rpx flex flex-shrink-0 flex-col items-center justify-center px20rpx text-24rpx font-semibold"
|
|
|
- @click="handleOpen"
|
|
|
+ @click="show = true"
|
|
|
>
|
|
|
展开
|
|
|
<image :src="`${StaticUrl}/xia.png`" class="mt20rpx h20rpx w20rpx" />
|
|
|
@@ -373,11 +452,30 @@ onUnmounted(() => {
|
|
|
{{ item.channelProdPrice }}
|
|
|
</text>
|
|
|
</view>
|
|
|
- <view v-if="item.spuStock" @click.stop="handleAddCart($event, item)">
|
|
|
- <image :src="`${StaticUrl}/cart-yes.png`" class="h52rpx w52rpx" />
|
|
|
+ <view v-if="!item.num">
|
|
|
+ <view v-if="item.spuStock" @click.stop="handleAddCart($event, item)">
|
|
|
+ <image :src="`${StaticUrl}/cart-yes.png`" class="h52rpx w52rpx" />
|
|
|
+ </view>
|
|
|
+ <view v-else>
|
|
|
+ <image :src="`${StaticUrl}/cart-no.png`" class="h52rpx w52rpx" />
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<view v-else>
|
|
|
- <image :src="`${StaticUrl}/cart-no.png`" class="h52rpx w52rpx" />
|
|
|
+ <view class="flex items-center">
|
|
|
+ <image
|
|
|
+ :src="` ${StaticUrl}/sub-cart.png`"
|
|
|
+ class="h44rpx w44rpx"
|
|
|
+ @click.stop="handleSubCart($event, item)"
|
|
|
+ />
|
|
|
+ <view class="box-border h44rpx w84rpx flex items-center justify-center border border-#F0F0F0 border-solid text-24rpx text-#AAAAAA">
|
|
|
+ {{ item.num }}
|
|
|
+ </view>
|
|
|
+ <image
|
|
|
+ :src="` ${StaticUrl}/add-cart.png`"
|
|
|
+ class="h44rpx w44rpx"
|
|
|
+ @click.stop="handleAddCart($event, item)"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -456,7 +554,7 @@ onUnmounted(() => {
|
|
|
¥{{ item.price }}
|
|
|
</view>
|
|
|
<!-- <wd-input-number v-model="item.num" disable-input @change="handleChangeNum($event, item)" /> -->
|
|
|
- <view class="flex items-center">
|
|
|
+ <view v-if="item.shopSkuStocks !== '0' && item.isDelete !== '1'" class="flex items-center">
|
|
|
<image
|
|
|
:src="` ${StaticUrl}/sub-cart.png`"
|
|
|
class="h44rpx w44rpx"
|
|
|
@@ -474,14 +572,16 @@ onUnmounted(() => {
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view v-if="item.shopSkuStocks == '0'" class="absolute left-0 top-0 z-1 h-full w-full flex items-center justify-center bg-[rgba(255,255,255,.6)]">
|
|
|
- <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p20rpx text-white">
|
|
|
- 商品已售罄
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view v-if="item.isDelete == '1'" class="absolute left-0 top-0 z-1 h-full w-full flex items-center justify-center bg-[rgba(255,255,255,.6)]">
|
|
|
- <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p20rpx text-white">
|
|
|
- 商品已删除
|
|
|
+ <view v-if="item.shopSkuStocks == '0' || item.isDelete == '1'" class="absolute left-0 top-0 z-1 h-full w-full bg-[rgba(255,255,255,.6)]">
|
|
|
+ <view class="relative w-full flex items-center justify-center">
|
|
|
+ <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p20rpx text-white">
|
|
|
+ {{ item.shopSkuStocks == '0' ? '商品已售罄' : '商品已删除' }}
|
|
|
+ </view>
|
|
|
+ <view class="absolute bottom-20rpx right-20rpx">
|
|
|
+ <wd-button @click="handleDelCartGoods(item)">
|
|
|
+ 删除商品
|
|
|
+ </wd-button>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -489,6 +589,22 @@ onUnmounted(() => {
|
|
|
<view class="h320rpx" />
|
|
|
</view>
|
|
|
</Zpopup>
|
|
|
+ <selectSku v-model:show="selectGoods" v-model:sku-id="selectSkuId" v-model:select-goods-num="SelectGoodsNum" :goods-info="goodsInfo!">
|
|
|
+ <template #footer>
|
|
|
+ <view class="box-border w-full flex items-center justify-between py20rpx">
|
|
|
+ <view class="w-48%">
|
|
|
+ <wd-button plain hairline block @click="selectGoods = false">
|
|
|
+ 取消
|
|
|
+ </wd-button>
|
|
|
+ </view>
|
|
|
+ <view class="w-48%">
|
|
|
+ <wd-button block @click="handleSkuAddCart">
|
|
|
+ 加入购物车
|
|
|
+ </wd-button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+ </selectSku>
|
|
|
<view v-if="showball" class="ball">
|
|
|
<image :src="`${StaticUrl}/cart-yes.png`" class="cart-img h52rpx w52rpx" />
|
|
|
</view>
|