Browse Source

立即兑换toast提示

15591641157 2 months ago
parent
commit
f6108114bf
1 changed files with 21 additions and 6 deletions
  1. 21 6
      packages/app/src/pages/home/mall/detail/index.vue

+ 21 - 6
packages/app/src/pages/home/mall/detail/index.vue

@@ -17,7 +17,9 @@ import BottomAppBar from '@/components/bottom-app-bar.vue'
 import ButtonEvo from '@/components/button-evo.vue'
 import {usePermissions} from '../../../../composables/permissions'
 import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html.vue'
+import {useToast} from 'wot-design-uni'
 
+const toast = useToast()
 const {clickByPermission} = usePermissions()
 const userStore = useUserStore()
 const router = useRouter()
@@ -70,6 +72,23 @@ const handleConfirm = async () => {
     show.value = false
   }
 }
+
+const handleClick = (product) => {
+  if (product?.isRestrict === 1 && product?.productRepertory === 0) {
+    toast.show("库存不足")
+    return null
+  }
+  let levelIds = product.memberLevelIds.split(",");
+  if (!levelIds.includes(userInfo.value.level.level)) {
+    toast.show("您当前会员等级不符合兑换条件")
+    return null
+  }
+  // 否则,执行原来的点击逻辑
+  clickByPermission('mallExchange', () => {
+    show.value = true;
+    type.value = 'orderNow';
+  });
+}
 onLoad(async (query: { id: string }) => {
   id.value = query.id
   await setData()
@@ -168,12 +187,8 @@ onShareTimeline(() => ({
             <ButtonEvo
               block
               size="lg"
-              @click="
-                clickByPermission('mallExchange', () => {
-                  show = true
-                  type = 'orderNow'
-                })
-              "
+              :disabled="(data?.isRestrict === 1 && data?.productRepertory == 0) || (!data?.memberLevelIds.split(',').includes(userInfo.level.level)) ? 'isDisabled': null"
+              @click="handleClick(data)"
             >
               立即兑换
             </ButtonEvo>