shish 6 лет назад
Родитель
Сommit
4ac7ffcf07
1 измененных файлов с 24 добавлено и 31 удалено
  1. 24 31
      mall/src/pages/order/buy.vue

+ 24 - 31
mall/src/pages/order/buy.vue

@@ -120,7 +120,6 @@ export default {
     return {
       goodsInfo: {},
       tabIndex: 0,
-      region:{},
       tabs: [
         {
           name: "帮我送"
@@ -214,27 +213,33 @@ export default {
     // 生成订单
     createOrderFn() {
       let addForm = {};
+      let form =
+        this.tabIndex == 0 ? this.$refs.appDelivery.form : this.mentionForm;
+      let region = this.tabIndex == 0 ? this.$refs.appDelivery.region : {};
+      if (this.$refs.couponSel) {
+        addForm.couponId = this.$refs.couponSel.couponId;
+      }
       if (this.tabIndex == 0) {
-        
-        let form = this.$refs.appDelivery.form;
-        this.region = this.$refs.appDelivery.region;
+        let receiveUserName = form.receiveUserName;
+        if (this.$util.isEmpty(receiveUserName)) {
+          this.$msg("请填写收花人姓名");
+          return false;
+        }
+        let receiveMobile = form.receiveMobile;
+        if (this.$util.isEmpty(receiveMobile)) {
+          this.$msg("请填写收花人电话");
+          return false;
+        }
         let reachTime = form.reachTime;
         let receiveAddress = form.receiveAddress;
-
-        if(this.$util.isEmpty(reachTime)){
-           this.$msg('请填写送达时间');
-           return false;
+        if (this.$util.isEmpty(receiveAddress)) {
+          this.$msg("请填写地址!");
+          return false;
         }
-        if(this.$util.isEmpty(receiveAddress)){
-           this.$msg('请填写地址');
-           return false;
+        if (this.$util.isEmpty(reachTime) || reachTime == 0) {
+          this.$msg("请填写送达时间!");
+          return false;
         }
-        console.log(111111)
-      } else {
-        let form = this.mentionForm;
-      }
-      if (this.$refs.couponSel) {
-        addForm.couponId = this.$refs.couponSel.couponId;
       }
 
       createOrder({
@@ -242,7 +247,7 @@ export default {
         ...form,
         ...this.form,
         ...addForm,
-        ...this.region
+        ...region
       }).then(res => {
         uni.removeStorageSync("buyGoodsDetil");
         this.$util.pageTo({
@@ -278,19 +283,7 @@ export default {
     },
     // 表单验证
     formSubmit(e) {
-      let checkRules = [
-        {
-          name: "receiveUserName",
-          rule: ["required"],
-          msg: ["请填写姓名"]
-        },
-        {
-          name: "receiveMobile",
-          rule: ["required"],
-          msg: ["请填写电话"]
-        }
-      ];
-      let rules = this.tabIndex == 0 ? checkRules : [];
+      let rules = [];
       let formData = e.detail.value;
       let checkRes = form.validation(formData, rules);
       if (!checkRes) {