From 05bd41aab8c9dba2cf7afcd78493415761f11d9d Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期四, 26 九月 2024 08:54:08 +0800
Subject: [PATCH] update 供应商刷新问题

---
 pages/user/address/address.vue |   50 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/pages/user/address/address.vue b/pages/user/address/address.vue
index 5deb06e..c0fd7b2 100644
--- a/pages/user/address/address.vue
+++ b/pages/user/address/address.vue
@@ -78,7 +78,7 @@
 							手机号
 						</view>
 						<view class="form-item-value">
-							<input v-model="submitForm.tel" placeholder="请输入收货人手机号" class="form-input"></input>
+							<input v-model="submitForm.tel" placeholder="请输入收货人手机号" class="form-input" @blur="validatePhoneNumber()" ></input>
 						</view>
 					</view>
 					<view class="form-item">
@@ -171,6 +171,16 @@
 			};
 		},
 		methods: {
+			validatePhoneNumber() {
+					
+			    // 手机号码正则表达式,可以根据需要调整
+			    const phoneRegex = /^[1][3-9][0-9]{9}$/;
+			   if (!phoneRegex.test(this.submitForm['tel'])) {
+			  		this.$message.showToast('请填写正确手机号码')
+			  	}
+			
+			},
+			
 			addAddress() {
 				delete this.submitForm.id
 				this.submitForm['name'] = ''
@@ -219,10 +229,19 @@
 			},
 			async init_area() {
 				if (this.regionDataPlus && this.regionDataPlus.length > 0) {
-					const res = await this.$http.request('get', '/api/pub/china/area/json')
-					this.regionDataPlus = res.data && JSON.parse(res.data.replaceAll('code', 'value').replaceAll(
-						'name',
-						'text')) || []
+
+				} else {
+					var a = this.$storage.getItem('cache_area')
+					if (a) {
+						this.regionDataPlus = JSON.parse(a) || []
+					} else {
+						const res = await this.$http.request('get', '/api/pub/china/area/json')
+						// console.log('area', JSON.parse(res.data))
+						this.regionDataPlus = res.data && JSON.parse(res.data.replaceAll('code', 'value').replaceAll(
+							'name',
+							'text')) || []
+						this.$storage.setItem('cache_area', JSON.stringify(this.regionDataPlus))
+					}
 				}
 
 			},
@@ -384,6 +403,20 @@
 					this.$message.showToast('字段未填写完整')
 					return
 				}
+				if(!this.submitForm['province']||!this.submitForm['province']||!this.submitForm['province']){
+					this.$message.showToast('省市区未选择完整')
+					return
+				}
+				
+				// 手机号码正则表达式,可以根据需要调整
+				 const phoneRegex = /^[1][3-9][0-9]{9}$/;
+				if (!phoneRegex.test(this.submitForm['tel'])) {
+					this.$message.showToast('请填写正确手机号码')
+					return
+				}
+								
+				
+				
 				this.$message.showLoading()
 				const {
 					code
@@ -395,11 +428,18 @@
 				if (code === 0) {
 					this.$refs.popup_form.close()
 					this.$message.showToast(this.submitForm.id ? '修改成功' : '新增成功')
+					
 					let tmp = this
 					setTimeout(() => {
 						tmp.page.current = 1
 						tmp.refreshList()
 					}, 300)
+					//如果当前选择的地址是这个,需要更新一下数据
+					if (this.address.id && this.submitForm.id === this.address.id) {
+						this.$store.commit('setDefaultAddress', {
+							...this.submitForm
+						})
+					}
 				}
 			},
 

--
Gitblit v1.9.3