瀏覽代碼

商品类型spuType为“0”的时候需要填写收货地址

lifanagju_citu 6 月之前
父節點
當前提交
2711925167
共有 2 個文件被更改,包括 12 次插入10 次删除
  1. 11 7
      pages/order/confirm.vue
  2. 1 3
      pages/pay/result.vue

+ 11 - 7
pages/order/confirm.vue

@@ -306,11 +306,11 @@
 
   // 提交订单
   function onConfirm() {
-    if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
+    if (spuType.value === '0' && addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
       sheep.$helper.toast('请选择收货地址');
       return;
     }
-    if (addressState.value.deliveryType === 2) {
+    if (spuType.value === '0' && addressState.value.deliveryType === 2) {
       if (!addressState.value.pickUpInfo.id) {
         sheep.$helper.toast('请选择自提门店地址');
         return;
@@ -328,9 +328,8 @@
         return;
       }
     }
-    console.log(state.orderPayload, 'submit-order-pay', state);
 
-    if (spuType.value !== '0' && !state.orderPayload?.email || !test.email(state.orderPayload.email)) {
+    if (spuType.value !== '0' && !state.orderPayload?.email && !test.email(state.orderPayload.email)) {
       const title = !state.orderPayload.email ? '请填写接收邮箱!' : '邮箱格式不正确!'
       uni.showToast({ title, icon: 'none', duration: 2000 })
       return
@@ -383,8 +382,8 @@
     }
   }
 
-  const spuType = ref('')
-  let salesLotterySpuId = ''
+  const spuType = ref('') // '0': 有物流的商品
+  let salesLotterySpuId = '' // 参与抽奖的id
   // 检查库存 & 计算订单价格
   async function getOrderInfo() {
     // 计算价格
@@ -407,7 +406,12 @@
     }
     state.orderInfo = data;
     spuType.value = state.orderInfo?.items?.length && state.orderInfo.items.every(k => k.spuType === '0') ? '0' : ''
-    salesLotterySpuId = Boolean(!spuType.value) ? state.orderPayload?.spuId : ''
+
+    // 虚拟商品
+    if (!spuType.value) {
+      salesLotterySpuId = state.orderPayload?.spuId
+      addressState.value.deliveryType = undefined
+    }
     
     state.couponInfo = data.coupons || [];
     // 设置收货地址

+ 1 - 3
pages/pay/result.vue

@@ -141,7 +141,6 @@
     state.counter++;
     // 1. 加载订单信息
     const { data, code } = await PayOrderApi.getOrder(id);
-    // console.log('getOrder:', data)
     if (code === 0) {
       state.orderInfo = data;
       if (!state.orderInfo || state.orderInfo.status === 30) {
@@ -281,7 +280,6 @@
   const getRecord = async (orderId) => {
     if (!orderId) return
     const res = await PrizeApi.getLuckLotteryRecordByOrderId(orderId)
-    // console.log('prizeData:', res)
     prizeData.value = res?.data || []
   }
   
@@ -307,7 +305,7 @@
 
   // 领取
   const handleReceive = async () => {
-    if (!addressState.value?.addressInfo && !Object.keys(addressState.value.addressInfo).length) {
+    if (!addressState.value?.addressInfo || !Object.keys(addressState.value.addressInfo).length) {
       uni.showToast({
         title: '请选择收货地址',
         icon: 'none',