ソースを参照

邮箱格式不正确!

lifanagju_citu 6 ヶ月 前
コミット
95f4beb8e6
1 ファイル変更7 行追加4 行削除
  1. 7 4
      pages/order/confirm.vue

+ 7 - 4
pages/order/confirm.vue

@@ -278,9 +278,9 @@
 
   const emailErrorMessage = ref(false)
   const emailChange = (e) => {
-    const email = e?.detail?.value
+    const email = e?.detail?.value || e
     emailErrorMessage.value = Boolean(!email || !test.email(email))
-    if (emailErrorMessage.value) sheep.$helper.toast('邮箱格式不正确')
+    if (emailErrorMessage.value) sheep.$helper.toast('邮箱格式不正确')
   };
 
   // 选择优惠券
@@ -329,10 +329,13 @@
       }
     }
     console.log(state.orderPayload, 'submit-order-pay', state);
-    if (spuType.value !== '0' && !state.orderPayload.email) {
-      uni.showToast({ title: '请填写接收邮箱!', icon: 'none', duration: 2000 })
+
+    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
     }
+    
     submitOrder()
   }