Browse Source

修改手机号验证

Tang 3 years ago
parent
commit
9cb168a758
1 changed files with 22 additions and 13 deletions
  1. 22 13
      pages2/verify/input.vue

+ 22 - 13
pages2/verify/input.vue

@@ -349,8 +349,8 @@ export default {
 							var vartest = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
 							if (this.$u.test.mobile(value) || vartest.test(value)) {
 								return true;
-							}else{
-								return false
+							} else {
+								return false;
 							}
 						},
 						message: '手机号码不正确',
@@ -404,8 +404,8 @@ export default {
 							var vartest1 = /^([0-9]{3,4})?[0-9]{7,8}$/;
 							if (this.$u.test.mobile(value) || vartest.test(value) || vartest1.test(value)) {
 								return true;
-							}else{
-								return false
+							} else {
+								return false;
 							}
 						},
 						message: '单位联系电话不正确',
@@ -461,7 +461,8 @@ export default {
 						trigger: ['change', 'blur']
 					}
 				]
-			}
+			},
+			isRequired: false
 		};
 	},
 	created() {
@@ -593,15 +594,19 @@ export default {
 		//验证表单
 		resultForm(int) {
 			if (this.openVerify) {
-				this.$refs.uForm.validate(valid => {
-					if (valid) {
-						if (int === 1) {
-							this.submitApi();
+				if (this.isRequired) {
+					this.submitApi();
+				} else {
+					this.$refs.uForm.validate(valid => {
+						if (valid) {
+							if (int === 1) {
+								this.submitApi();
+							}
+						} else {
+							console.log('验证失败');
 						}
-					} else {
-						console.log('验证失败');
-					}
-				});
+					});
+				}
 			}
 		},
 		async submits() {
@@ -704,6 +709,10 @@ export default {
 			var self = this;
 			this.$api.getbaseprofiletpId(this.goodsId).then(res => {
 				self.listData = JSON.parse(res.data.data.keyValue);
+				self.isRequired = self.listData.every(ims => {
+					return ims.required === false;
+				});
+				console.log(self.isRequired);
 				self.$api.getbaseprofiletpgetInfo({ goodsId: self.goodsId }).then(result => {
 					if (result.data.code === 200) {
 						if (result.data.data && result.data.data.status === 3) {