|
|
@@ -1,5 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
-const isChecked = ref(false)
|
|
|
+import router from '@/router'
|
|
|
+
|
|
|
definePage({
|
|
|
name: 'smqjh-giveaways-vip',
|
|
|
islogin: true,
|
|
|
@@ -10,23 +11,99 @@ definePage({
|
|
|
onMounted(() => {
|
|
|
getGiftsList()
|
|
|
})
|
|
|
-
|
|
|
-const giveawaysList = ref<Api.giftsListModel>()
|
|
|
+const { selectedAddress } = storeToRefs(useUserStore())
|
|
|
+const giveawaysList = ref<Api.giftsListModel[]>([])
|
|
|
+const isPicking = ref(false)
|
|
|
async function getGiftsList() {
|
|
|
const res = await Apis.sys.giftsList({})
|
|
|
- giveawaysList.value = res.data
|
|
|
+ giveawaysList.value = res.data || []
|
|
|
}
|
|
|
function handleChange(value: any) {
|
|
|
console.log(value)
|
|
|
}
|
|
|
+
|
|
|
+async function pickUp() {
|
|
|
+ const addressId = selectedAddress.value?.id
|
|
|
+ if (!addressId) {
|
|
|
+ useGlobalToast().show({ msg: '请选择收货地址' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!giveawaysList.value.length) {
|
|
|
+ useGlobalToast().show({ msg: '暂无可领取赠品' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const firstGift = giveawaysList.value[0]
|
|
|
+ const hasInvalidGift = giveawaysList.value.some(item => !item.skuId || !item.shopId || !item.channelId)
|
|
|
+ if (hasInvalidGift) {
|
|
|
+ useGlobalToast().show({ msg: '赠品数据异常' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const hasDifferentShopOrChannel = giveawaysList.value.some((item) => {
|
|
|
+ return item.shopId !== firstGift.shopId || item.channelId !== firstGift.channelId
|
|
|
+ })
|
|
|
+ if (hasDifferentShopOrChannel) {
|
|
|
+ useGlobalToast().show({ msg: '赠品需来自同一门店和渠道' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isPicking.value) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ isPicking.value = true
|
|
|
+ try {
|
|
|
+ const items = giveawaysList.value.map((item) => {
|
|
|
+ return {
|
|
|
+ skuId: item.skuId!,
|
|
|
+ quantity: Number(item.quantity || 1),
|
|
|
+ shopId: item.shopId!,
|
|
|
+ channelId: item.channelId!,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const orderInfo = {
|
|
|
+ totalPrice: 0,
|
|
|
+ transfee: 0,
|
|
|
+ offsetPoints: 0,
|
|
|
+ shopName: firstGift.shopName || '',
|
|
|
+ price: 0,
|
|
|
+ amount: 0,
|
|
|
+ coupon: 0,
|
|
|
+ couponName: '',
|
|
|
+ orderCouponItemDTOS: [],
|
|
|
+ memberGiftAddressId: addressId,
|
|
|
+ memberGiftItems: items,
|
|
|
+ skuList: giveawaysList.value.map((item) => {
|
|
|
+ return {
|
|
|
+ prodId: item.spuId || 0,
|
|
|
+ num: Number(item.quantity || 1),
|
|
|
+ pic: item.picUrl,
|
|
|
+ price: '0',
|
|
|
+ shopId: item.shopId!,
|
|
|
+ shopSkuStocks: String(item.stock ?? ''),
|
|
|
+ skuId: item.skuId!,
|
|
|
+ skuName: item.spuName || item.skuName,
|
|
|
+ spec: item.skuName,
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ }
|
|
|
+ router.push({
|
|
|
+ name: 'xsb-confirmOrder',
|
|
|
+ params: { data: JSON.stringify(orderInfo) },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ isPicking.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<view class="px24rpx">
|
|
|
<view class="h-20rpx" />
|
|
|
<view v-for="item in giveawaysList" :key="item.channelId" class="mb-20rpx flex items-center gap-20rpx rounded-16rpx bg-#FFF p-24rpx">
|
|
|
- <view class="w-32rpx" @click="isChecked = !isChecked">
|
|
|
- <wd-icon :name="isChecked ? 'check-circle-filled' : 'circle1'" size="20px" color="#9ED605" />
|
|
|
+ <view class="w-32rpx">
|
|
|
+ <wd-icon name="check-circle-filled" size="20px" color="#9ED605" />
|
|
|
</view>
|
|
|
<view class="flex items-center gap-20rpx">
|
|
|
<image
|
|
|
@@ -47,7 +124,7 @@ function handleChange(value: any) {
|
|
|
<view class="text-36rpx text-#FF4D3A font-800">
|
|
|
¥{{ item.price }}
|
|
|
</view>
|
|
|
- <wd-input-number v-model="item.quantity" disabled @change="handleChange" />
|
|
|
+ <wd-input-number :model-value="Number(item.quantity) || 1" disabled @change="handleChange" />
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -56,7 +133,7 @@ function handleChange(value: any) {
|
|
|
<view class="h-180rpx" />
|
|
|
</view>
|
|
|
<view class="fixed bottom-0 left-0 right-0 z-9999 h-140rpx w-702rpx rounded-16rpx bg-#FFF p-24rpx shadow-[0rpx_-6rpx_12rpx_2rpx_rgba(0,0,0,0.05)]">
|
|
|
- <wd-button custom-class="h-80rpx w-full">
|
|
|
+ <wd-button custom-class="h-80rpx w-full" :loading="isPicking" @click="pickUp">
|
|
|
免费领取
|
|
|
</wd-button>
|
|
|
</view>
|