|
@@ -1,16 +1,16 @@
|
|
|
<route lang="json5">
|
|
|
{
|
|
|
- style: {
|
|
|
- navigationBarTitleText: '购物车',
|
|
|
- navigationBarBackgroundColor: '#fff',
|
|
|
- },
|
|
|
+style: {
|
|
|
+navigationBarTitleText: '购物车',
|
|
|
+navigationBarBackgroundColor: '#fff',
|
|
|
+},
|
|
|
}
|
|
|
</route>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import TiltedButton from '@/components/tilted-button.vue'
|
|
|
import Product from '../components/product.vue'
|
|
|
-import { shoppingBag } from '@designer-hub/assets/src/assets/svgs/index'
|
|
|
+import {shoppingBag} from '@designer-hub/assets/src/assets/svgs/index'
|
|
|
import {
|
|
|
createProductItemBuy,
|
|
|
deleteProductItemBuy,
|
|
@@ -19,19 +19,19 @@ import {
|
|
|
} from '../../../../core/libs/requests'
|
|
|
import PageHelper from '@/components/page-helper.vue'
|
|
|
import BottomAppBar from '@/components/bottom-app-bar.vue'
|
|
|
-import { useUserStore } from '../../../../store'
|
|
|
-import { useRouter } from '../../../../core/utils/router'
|
|
|
-import { storeToRefs } from 'pinia'
|
|
|
-import { requestToast } from '../../../../core/utils/common'
|
|
|
-import type { ComponentExposed } from 'vue-component-type-helpers'
|
|
|
+import {useUserStore} from '../../../../store'
|
|
|
+import {useRouter} from '../../../../core/utils/router'
|
|
|
+import {storeToRefs} from 'pinia'
|
|
|
+import {requestToast} from '../../../../core/utils/common'
|
|
|
+import type {ComponentExposed} from 'vue-component-type-helpers'
|
|
|
import ButtonEvo from '@/components/button-evo.vue'
|
|
|
-import { usePermissions } from '../../../../composables/permissions'
|
|
|
+import {usePermissions} from '../../../../composables/permissions'
|
|
|
|
|
|
-const { clickByPermission } = usePermissions()
|
|
|
+const {clickByPermission} = usePermissions()
|
|
|
const pageHelperRef = ref<ComponentExposed<typeof PageHelper>>()
|
|
|
const userStore = useUserStore()
|
|
|
const router = useRouter()
|
|
|
-const { userInfo } = storeToRefs(userStore)
|
|
|
+const {userInfo} = storeToRefs(userStore)
|
|
|
const selected = ref([])
|
|
|
const points = computed(() =>
|
|
|
selected.value.reduce(
|
|
@@ -41,10 +41,13 @@ const points = computed(() =>
|
|
|
),
|
|
|
)
|
|
|
|
|
|
-const query = ref({ userId: userInfo.value?.userId })
|
|
|
+const query = ref({userId: userInfo.value?.userId})
|
|
|
const handleSelect = (product) => {
|
|
|
+ if (product.status || product.deleted || (product.isRestrict == 1 && product.productRepertory == 0)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
if (selected.value.map((it) => it.productId).includes(product.productId)) {
|
|
|
- selected.value = selected.value.filter(({ productId }) => productId !== product.productId)
|
|
|
+ selected.value = selected.value.filter(({productId}) => productId !== product.productId)
|
|
|
} else {
|
|
|
selected.value = [...selected.value, product]
|
|
|
}
|
|
@@ -84,10 +87,10 @@ const handleProductNumsChange = async (nums, product) => {
|
|
|
})
|
|
|
if (selected.value.map((it) => it.productId).includes(product.productId)) {
|
|
|
selected.value = selected.value.map((it) =>
|
|
|
- it.productId === product.productId ? { ...it, nums } : it,
|
|
|
+ it.productId === product.productId ? {...it, nums} : it,
|
|
|
)
|
|
|
}
|
|
|
- } else {
|
|
|
+ } if (nums == 0) {
|
|
|
await deleteProductItemBuy({
|
|
|
doList: [
|
|
|
{
|
|
@@ -99,7 +102,7 @@ const handleProductNumsChange = async (nums, product) => {
|
|
|
})
|
|
|
if (selected.value.map((it) => it.productId).includes(product.productId)) {
|
|
|
selected.value = selected.value.map((it) =>
|
|
|
- it.productId === product.productId ? { ...it, nums } : it,
|
|
|
+ it.productId === product.productId ? {...it, nums} : it,
|
|
|
)
|
|
|
}
|
|
|
}
|
|
@@ -107,7 +110,7 @@ const handleProductNumsChange = async (nums, product) => {
|
|
|
}
|
|
|
const handlePlaceOrder = async () => {
|
|
|
if (!selected.value.length) {
|
|
|
- await uni.showToast({ title: '请选择商品', icon: 'none' })
|
|
|
+ await uni.showToast({title: '请选择商品', icon: 'none'})
|
|
|
return ''
|
|
|
}
|
|
|
const body = {
|
|
@@ -115,7 +118,7 @@ const handlePlaceOrder = async () => {
|
|
|
userId: userInfo.value.userId,
|
|
|
item: 3,
|
|
|
list: selected.value.map(
|
|
|
- ({ productId, prodcutName, productCoverImgUrl, nums, points, vendorId }) => ({
|
|
|
+ ({productId, prodcutName, productCoverImgUrl, nums, points, vendorId}) => ({
|
|
|
productId,
|
|
|
productName: prodcutName,
|
|
|
orderImgUrl: productCoverImgUrl,
|
|
@@ -126,7 +129,7 @@ const handlePlaceOrder = async () => {
|
|
|
),
|
|
|
couponList: [],
|
|
|
}
|
|
|
- const { code, data: res } = await requestToast(() => productPlacing(body))
|
|
|
+ const {code, data: res} = await requestToast(() => productPlacing(body))
|
|
|
if (code === 0) {
|
|
|
await pageHelperRef.value?.reload()
|
|
|
await router.push(`/pages/home/mall/confirm-order/index?data=${JSON.stringify(body)}`)
|
|
@@ -176,6 +179,16 @@ const handlePlaceOrder = async () => {
|
|
|
已失效
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div
|
|
|
+ v-if="it.isRestrict == 1 && it.productRepertory == 0"
|
|
|
+ class="absolute bottom-0 w-full h-5.5 bg-[#D7D7D7] flex items-center justify-center"
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ class="text-black/60 text-xs font-normal font-['PingFang_SC'] leading-normal"
|
|
|
+ >
|
|
|
+ 库存不足
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="flex flex-col justify-between flex-1">
|
|
|
<div
|
|
@@ -199,7 +212,16 @@ const handlePlaceOrder = async () => {
|
|
|
<!-- {{ it.nums }} -->
|
|
|
<wd-input-number
|
|
|
:model-value="Number(it.nums)"
|
|
|
+ :max="it.isRestrict === 1 && it.purchaseLimit
|
|
|
+ ? Math.min(it.purchaseQuantity, it.productRepertory)
|
|
|
+ : it.isRestrict === 1 && !it.purchaseLimit
|
|
|
+ ? it.productRepertory
|
|
|
+ : it.isRestrict === 2 && it.purchaseLimit
|
|
|
+ ? it.purchaseQuantity
|
|
|
+ : 100"
|
|
|
@update:model-value="(e) => handleProductNumsChange(e, it)"
|
|
|
+ :disabled="it.status || it.deleted || (it.isRestrict == 1 && it.productRepertory == 0)"
|
|
|
+ disable-input
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|