|
|
@@ -1,5 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
import { StaticUrl } from '@/config'
|
|
|
+import router from '@/router'
|
|
|
|
|
|
import selectAddressTemplate from '@/subPack-smqjh/components/selectAddress/index.vue?async'
|
|
|
|
|
|
@@ -14,8 +15,8 @@ definePage({
|
|
|
},
|
|
|
})
|
|
|
const { name } = storeToRefs(useAddressStore())
|
|
|
+const { cartList, isAddingCart } = storeToRefs(useSmqjhCartStore())
|
|
|
const isAll = ref(false)
|
|
|
-const selectCatrt = ref()
|
|
|
const tab = ref(0)
|
|
|
const selectAddress = ref(false)
|
|
|
const navList = ref([
|
|
|
@@ -28,6 +29,123 @@ const navList = ref([
|
|
|
{ title: '酒店民宿', id: 7 },
|
|
|
{ title: '代驾', id: 8 },
|
|
|
])
|
|
|
+const totalProduct = ref<Api.shoppingCartOrderConfirm>()
|
|
|
+async function handleChangeAllShop(e: { value: boolean }, shop: Api.myShoppingCart) {
|
|
|
+ const shopData = cartList.value.filter(it => it.AllShopGoods)
|
|
|
+ if (shopData.length > 1) {
|
|
|
+ shop.AllShopGoods = false
|
|
|
+ useGlobalToast().show('不能同时选中两个店铺的商品')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (e.value) {
|
|
|
+ shop.allGoods = shop.skuList.filter(it => it.shopSkuStocks !== '0' && it.isDelete !== '1').map(it => Number(it.id))
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ shop.allGoods = []
|
|
|
+ totalProduct.value = undefined
|
|
|
+ }
|
|
|
+}
|
|
|
+watch(() => cartList.value, async () => {
|
|
|
+ const ids = cartList.value.filter(it => it.allGoods.length)
|
|
|
+ if (ids.length) {
|
|
|
+ const id = ids[0].allGoods.join(',')
|
|
|
+ const res = await useSmqjhCartStore().getCartAddGoodsPrice(id)
|
|
|
+ totalProduct.value = res
|
|
|
+ }
|
|
|
+}, {
|
|
|
+ deep: true,
|
|
|
+})
|
|
|
+
|
|
|
+async function handleChangShopGoods(e: { value: number[] }, shop: Api.myShoppingCart) {
|
|
|
+ const shopData = cartList.value.filter(it => it.allGoods.length)
|
|
|
+ if (shopData.length > 1) {
|
|
|
+ shop.AllShopGoods = false
|
|
|
+ shop.allGoods = []
|
|
|
+ useGlobalToast().show('不能同时选中两个店铺的商品')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e.value.length === shop.skuList.length) {
|
|
|
+ shop.AllShopGoods = true
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ shop.AllShopGoods = false
|
|
|
+ totalProduct.value = undefined
|
|
|
+ }
|
|
|
+}
|
|
|
+function handleAllShopGoods(e: { value: boolean }) {
|
|
|
+ if (e.value) {
|
|
|
+ if (cartList.value.length > 1) {
|
|
|
+ useGlobalToast().show('多个店铺不能同时选中')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ cartList.value = cartList.value.map((it) => {
|
|
|
+ return {
|
|
|
+ ...it,
|
|
|
+ AllShopGoods: true,
|
|
|
+ allGoods: it.skuList.map(it => Number(it.id)),
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cartList.value = cartList.value.map((it) => {
|
|
|
+ return {
|
|
|
+ ...it,
|
|
|
+ AllShopGoods: false,
|
|
|
+ allGoods: [],
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+async function handleDel() {
|
|
|
+ const delGoods = cartList.value.filter(it => it.allGoods?.length > 0)
|
|
|
+ if (delGoods.length) {
|
|
|
+ await Apis.common.deleteShoppingCart({
|
|
|
+ pathParams: {
|
|
|
+ ids: delGoods.map(it => it.allGoods).join(','),
|
|
|
+ },
|
|
|
+ })
|
|
|
+ await useSmqjhCartStore().getCartList('XSB')
|
|
|
+ useGlobalToast().show({ msg: '删除成功!' })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ useGlobalToast().show({ msg: '请选择要删除的商品' })
|
|
|
+ }
|
|
|
+}
|
|
|
+async function handleSub(item: Api.CartSkuVo) {
|
|
|
+ if (unref(isAddingCart)) {
|
|
|
+ useGlobalToast().show({ msg: '移除商品中,请稍后' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (item.num === 1) {
|
|
|
+ useGlobalMessage().confirm({
|
|
|
+ msg: '是否删除该商品?',
|
|
|
+ success: async () => {
|
|
|
+ await useSmqjhCartStore().addCart(item.skuId, -1, item.shopId, 'XSB')
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ await useSmqjhCartStore().addCart(item.skuId, -1, item.shopId, 'XSB')
|
|
|
+ }
|
|
|
+}
|
|
|
+async function handleAdd(item: Api.CartSkuVo) {
|
|
|
+ if (unref(isAddingCart)) {
|
|
|
+ useGlobalToast().show({ msg: '添加商品中,请稍后' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ await useSmqjhCartStore().addCart(item.skuId, 1, item.shopId, 'XSB')
|
|
|
+}
|
|
|
+function handelPay() {
|
|
|
+ if (!unref(totalProduct)) {
|
|
|
+ useGlobalToast().show({ msg: '请选择商品' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ router.push({
|
|
|
+ name: 'xsb-confirmOrder',
|
|
|
+ params: { data: JSON.stringify(unref(totalProduct)) },
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -62,50 +180,77 @@ const navList = ref([
|
|
|
管理
|
|
|
</view>
|
|
|
</view>
|
|
|
- <scroll-view scroll-y class="content box-border">
|
|
|
- <view class="px24rpx">
|
|
|
- <view v-for="store in 5" :key="store" class="mb24rpx rounded-16rpx bg-white px24rpx pb18rpx pt28rpx">
|
|
|
- <wd-checkbox v-model="isAll" size="large">
|
|
|
- <view class="text-28rpx font-semibold">
|
|
|
- 市民请集合官方旗舰店
|
|
|
+ <scroll-view scroll-y class="content box-border px24rpx">
|
|
|
+ <view v-for="shop in cartList" :key="shop.shopId" class="mb24rpx rounded-16rpx bg-white px24rpx pb18rpx pt28rpx">
|
|
|
+ <wd-checkbox v-model="shop.AllShopGoods" size="large" @change="handleChangeAllShop($event, shop)">
|
|
|
+ <view class="text-28rpx font-semibold">
|
|
|
+ {{ shop.shopName }}
|
|
|
+ </view>
|
|
|
+ </wd-checkbox>
|
|
|
+ <view class="mt20rpx h2rpx w-full bg-#F0F0F0" />
|
|
|
+ <wd-checkbox-group v-model="shop.allGoods" size="large" @change="handleChangShopGoods($event, shop)">
|
|
|
+ <view
|
|
|
+ v-for="item in shop.skuList" :key="item.id" class="relative mt20rpx flex items-center"
|
|
|
+ >
|
|
|
+ <view class="mr20rpx h32rpx w32rpx">
|
|
|
+ <wd-checkbox :model-value="item.id" />
|
|
|
</view>
|
|
|
- </wd-checkbox>
|
|
|
- <view class="mt20rpx h2rpx w-full bg-#F0F0F0" />
|
|
|
- <wd-checkbox-group v-model="selectCatrt" size="large">
|
|
|
- <view v-for="items in 10" :key="items" class="mt20rpx flex items-center">
|
|
|
- <view class="mr20rpx h32rpx w32rpx">
|
|
|
- <wd-checkbox model-value="jingmai" />
|
|
|
- </view>
|
|
|
- <view class="flex flex-1">
|
|
|
- <image :src="`${StaticUrl}/shu.png`" class="h200rpx w200rpx flex-shrink-0" />
|
|
|
- <view class="ml20rpx flex-1">
|
|
|
- <view class="text-left text-32rpx font-semibold">
|
|
|
- <view v-for="i in 2" :key="i" class="mr5px inline-block">
|
|
|
- <wd-tag>
|
|
|
+ <view class="flex flex-1">
|
|
|
+ <image
|
|
|
+ :src="item.pic"
|
|
|
+ class="h206rpx w200rpx flex-shrink-0"
|
|
|
+ @click.stop="router.push({ name: 'xsb-goods', params: { id: String(item.skuId) } })"
|
|
|
+ />
|
|
|
+ <view class="ml20rpx flex-1">
|
|
|
+ <view class="text-left text-28rpx font-semibold">
|
|
|
+ <!-- <view v-for="i in 2" :key="i" class="mr5px inline-block">
|
|
|
+ <wd-tag type="danger">
|
|
|
惊喜回馈
|
|
|
</wd-tag>
|
|
|
- </view>
|
|
|
- 秋季应季水果纯甜
|
|
|
- 柿子
|
|
|
- </view>
|
|
|
- <view class="mt14rpx text-24rpx text-#AAAAAA">
|
|
|
- 规格:5kg,盒
|
|
|
+ </view> -->
|
|
|
+ {{ item.skuName }}
|
|
|
+ </view>
|
|
|
+ <view class="mt14rpx text-24rpx text-#AAAAAA">
|
|
|
+ 规格:{{ item.spec }}
|
|
|
+ </view>
|
|
|
+ <view class="mt14rpx flex items-center justify-between">
|
|
|
+ <view class="text-36rpx text-#FF4A39 font-semibold">
|
|
|
+ ¥{{ item.price }}
|
|
|
</view>
|
|
|
- <view class="mt14rpx flex items-center justify-between">
|
|
|
- <view class="text-36rpx text-#FF4A39 font-semibold">
|
|
|
- ¥13.95
|
|
|
+ <!-- <wd-input-number v-model="item.num" disable-input @change="handleChangeNum($event, item)" /> -->
|
|
|
+ <view class="flex items-center">
|
|
|
+ <image
|
|
|
+ :src="` ${StaticUrl}/sub-cart.png`"
|
|
|
+ class="h44rpx w44rpx"
|
|
|
+ @click.stop="handleSub(item)"
|
|
|
+ />
|
|
|
+ <view class="box-border h44rpx w84rpx flex items-center justify-center border border-#F0F0F0 border-solid text-24rpx text-#AAAAAA">
|
|
|
+ {{ item.num }}
|
|
|
</view>
|
|
|
- <!-- <wd-input-number v-model="tabs.id" /> -->
|
|
|
+ <image
|
|
|
+ :src="` ${StaticUrl}/add-cart.png`"
|
|
|
+ class="h44rpx w44rpx"
|
|
|
+ @click.stop="handleAdd(item)"
|
|
|
+ />
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- </wd-checkbox-group>
|
|
|
- </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>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </wd-checkbox-group>
|
|
|
</view>
|
|
|
- <view class="h150rpx" />
|
|
|
|
|
|
- <view v-if="false" class="box-border w-full flex items-center justify-center">
|
|
|
+ <view v-if="!cartList.length" class="box-border w-full flex items-center justify-center">
|
|
|
<view class="mt220rpx flex flex-col items-center">
|
|
|
<image :src="`${StaticUrl}/cart.png`" class="h110rpx w110rpx" />
|
|
|
<view class="mb20rpx mt20rpx text-24rpx">
|
|
|
@@ -116,42 +261,39 @@ const navList = ref([
|
|
|
</wd-button>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view class="h140rpx" />
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
- <view
|
|
|
- class="fixedShadow fixed bottom-60rpx left-0 z-99 box-border w-full flex items-center justify-between rounded-t-16rpx bg-white px24rpx pb60rpx pt10rpx"
|
|
|
- >
|
|
|
+ <view v-if="cartList.length" class="fixedShadow fixed bottom-60rpx left-0 z-99 box-border w-full flex items-center justify-between rounded-t-16rpx bg-white px24rpx pb60rpx pt10rpx">
|
|
|
<view class="ios w-full flex items-center justify-between">
|
|
|
<view class="flex items-center">
|
|
|
- <image :src="`${StaticUrl}/cart-lanzi.png`" class="h100rpx w100rpx" />
|
|
|
+ <image
|
|
|
+ :src="`${StaticUrl}/cart-lanzi.png`"
|
|
|
+ class="h100rpx w100rpx"
|
|
|
+ />
|
|
|
<view class="ml16rpx flex items-center">
|
|
|
- <wd-checkbox v-model="isAll" size="large">
|
|
|
+ <wd-checkbox v-model="isAll" size="large" @change="handleAllShopGoods">
|
|
|
全选
|
|
|
</wd-checkbox>
|
|
|
- <view class="ml10rpx text-24rpx text-#FF4A39">
|
|
|
+ <view class="ml10rpx text-24rpx text-#FF4A39" @click="handleDel">
|
|
|
删除
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="flex items-center">
|
|
|
- <view>
|
|
|
- <view class="flex items-center font-semibold">
|
|
|
- <view class="text-22rpx text-#222">
|
|
|
- 总计:
|
|
|
- </view>
|
|
|
- <view class="flex items-baseline text-24rpx text-#FF4A39">
|
|
|
- ¥
|
|
|
- <text class="text-36rpx">
|
|
|
- 8.9
|
|
|
- </text>
|
|
|
- </view>
|
|
|
+ <view class="flex items-center font-semibold">
|
|
|
+ <view class="text-22rpx text-#222">
|
|
|
+ 总计:
|
|
|
</view>
|
|
|
- <view class="text-22rpx text-#AAAAAA">
|
|
|
- 含配送费¥11
|
|
|
+ <view class="flex items-baseline text-24rpx text-#FF4A39">
|
|
|
+ ¥
|
|
|
+ <text class="text-36rpx">
|
|
|
+ {{ totalProduct?.price || '0.00' }}
|
|
|
+ </text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="ml20rpx w160rpx">
|
|
|
- <wd-button block size="large">
|
|
|
+ <wd-button block size="large" @click="handelPay">
|
|
|
结算
|
|
|
</wd-button>
|
|
|
</view>
|