From 8e7223747438eb874ecf46988a72851ccdb58287 Mon Sep 17 00:00:00 2001
From: 346149741 <346149741@qq.com>
Date: 星期六, 22 六月 2024 17:12:59 +0800
Subject: [PATCH] Merge branch 'master' of http://218.28.192.34:9999/r/sqys/sqys_xcx

---
 policy/components/mine.vue         |   18 ++++++++-
 api/auth.js                        |    4 ++
 api/policy.js                      |    4 --
 common/http.interceptor.js         |    2 
 policy/changePhone/changePhone.vue |   74 +++++++++++++++++++++++++++++-------
 5 files changed, 80 insertions(+), 22 deletions(-)

diff --git a/api/auth.js b/api/auth.js
index b1ab4c9..bda0af4 100644
--- a/api/auth.js
+++ b/api/auth.js
@@ -32,4 +32,8 @@
 // 鏂版敞鍐岃幏鍙栭獙璇佺爜 /verify/getNew
 export function getNewVerify(data) {
 	return http.get(`/verify/getNew`, {params: data});
+}
+// 鏇存崲鎵嬫満鍙风爜 updatePhone
+export function updatePhone(data) {
+	return http.post(`/system/user/profile/updatePhone/${data.phone}`, data);
 }
\ No newline at end of file
diff --git a/api/policy.js b/api/policy.js
index c1a8d96..70d60ba 100644
--- a/api/policy.js
+++ b/api/policy.js
@@ -62,7 +62,3 @@
 export function orderUpd(data) {
 	return http.post(`/enforce/order/doResultOrder`, data, { custom: { loading: true }});
 }
-// 浼佷笟琚墽娉曟鏁� /report/team/getCompanyCount
-export function getCompanyCount(data) {
-	return http.get(`/report/team/getCompanyCount`, data, { custom: { loading: true }});
-}
\ No newline at end of file
diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 6e49d92..9099a99 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -60,7 +60,7 @@
 				// vm.$u.vuex('userInfo', null)
 				// vm.$u.vuex('token', null)
 				// uni.removeStorageSync("sessionToken")
-				// uni.clearStorageSync() // 娓呮鎵�鏈夌殑缂撳瓨
+				uni.clearStorageSync() // 娓呮鎵�鏈夌殑缂撳瓨
 				uni.showToast({
 					title: '鎺堟潈杩囨湡,璇烽噸鏂扮櫥褰�',
 					icon: 'none',
diff --git a/policy/changePhone/changePhone.vue b/policy/changePhone/changePhone.vue
index 86217f4..88d9645 100644
--- a/policy/changePhone/changePhone.vue
+++ b/policy/changePhone/changePhone.vue
@@ -8,7 +8,7 @@
 						鎵嬫満鍙�
 					</view>
 					<view class="form-input">
-						<input type="number"  placeholder="璇疯緭鍏�11浣嶆墜鏈哄彿"/>
+						<input type="number"  placeholder="璇疯緭鍏�11浣嶆墜鏈哄彿" v-model="form.phone"/>
 					</view>
 				</view>
 				<view class="form-item">
@@ -16,7 +16,7 @@
 						楠岃瘉鐮�
 					</view>
 					<view class="form-input set-flex set-flex-content-between">
-						<input type="number" placeholder="璇疯緭鍏ラ獙璇佺爜"/>
+						<input type="number" placeholder="璇疯緭鍏ラ獙璇佺爜" v-model="form.code"/>
 						<view @click="getCode">
 							<text class="driver"></text>
 							<text class="getcode">{{tips}}</text>
@@ -25,15 +25,14 @@
 				</view>
 			</view>
 			<view style="margin-top: 56rpx;">
-				<view class="per-button" @click="loging">淇敼鎵嬫満鍙�</view>
+				<view class="per-button" @click="changeCode">淇敼鎵嬫満鍙�</view>
 			</view>
 		</view>
 	</view>
 </template>
 
 <script>
-	// 00钀ュ晢鍔�,01鎵ф硶,02浼佷笟 鍖哄垎涓嶅悓鐨勭櫥闄嗛〉闈�
-	import { getCode, codeLogin, getInfo } from '@/api/auth.js'
+	import { getNewVerify, getInfo, checkCode, updatePhone } from '@/api/auth.js'
 	export default {
 		data() {
 			return {
@@ -50,6 +49,7 @@
 			}
 		},
 		onLoad(options) {
+			console.log(options)
 			if(options.code) {
 				this.form.userType = options.code
 			}
@@ -81,10 +81,13 @@
 					uni.showLoading({
 						title: '姝e湪鑾峰彇楠岃瘉鐮�'
 					})
-					getCode({phone: this.form.phone }).then(val => {
-							this.startCountdown()
-							uni.hideLoading();
-							uni.$u.toast('楠岃瘉鐮佸凡鍙戦��');
+					getNewVerify({phone: this.form.phone }).then(val => {
+							if(val.data.code == 200) {
+								this.startCountdown()
+								uni.hideLoading();
+								this.tips = `${this.countdownTime}s鍚庨噸鏂拌幏鍙朻
+								uni.$u.toast('楠岃瘉鐮佸凡鍙戦��');
+							}
 					})
 				} else {
 					uni.$u.toast('鍊掕鏃剁粨鏉熷悗鍐嶅彂閫�');
@@ -107,13 +110,54 @@
 					this.startCountdown()
 				}, 1000)
 			},
-			loging() {
-				codeLogin(this.form).then(val => {
-					if(val.data.token) {
-						this.loginToken = val.data.token
-						uni.setStorageSync('sessionToken', this.loginToken)
-						this.getInfo()
+			async checkCode() {
+				try{
+					const { data } = await checkCode(this.form)
+					if(data.code == 200 && data.data) {
+						return Promise.resolve()
+					} else {
+						uni.showToast({
+							title: '楠岃瘉鐮侀敊璇�',
+							icon: 'none'
+						})
+						throw "楠岃瘉鐮侀敊璇�"
+						return Promise.reject('楠岃瘉鐮侀敊璇�')
 					}
+				} catch(err) {
+					uni.showToast({
+						title: '楠岃瘉鐮侀敊璇�',
+						icon: 'none'
+					})
+					throw "楠岃瘉鐮侀敊璇�"
+				}
+			},
+			async changeCode() {
+				await this.checkCode()
+				if(!this.form.phone){
+					uni.showToast({
+						title: '璇疯緭鍏ユ墜鏈哄彿',
+						icon: 'none'
+					})
+					return
+				}
+				if(!this.$u.test.mobile(this.form.phone)){
+					uni.showToast({
+						title: '璇疯緭鍏ユ纭殑鎵嬫満鍙�',
+						icon: 'none'
+					})
+					return
+				}
+				updatePhone(this.form).then(val => {
+					if(val.data.code == 200) {
+						uni.showToast({
+							title: '淇敼鎴愬姛',
+							icon: 'none'
+						})
+						setTimeout(() => {
+							uni.navigateBack()
+						}, 500)
+					}
+					
 				})
 			},
 			getInfo() {
diff --git a/policy/components/mine.vue b/policy/components/mine.vue
index 587effb..f7efe29 100644
--- a/policy/components/mine.vue
+++ b/policy/components/mine.vue
@@ -31,7 +31,7 @@
 				<u-icon name="arrow-right"></u-icon>
 			</view>
 		</view>
-		<view class="logout">
+		<view class="logout" @click="logOut">
 			閫�鍑虹櫥褰�
 		</view>
 	</view>
@@ -53,7 +53,21 @@
 		methods: {
 			goChangePhone() {
 				uni.navigateTo({
-					url: '/policy/changePhone/changePhone'
+					url: `/policy/changePhone/changePhone?code=${this.userInfo.data.userType}`
+				})
+			},
+			logOut() {
+				uni.showModal({
+					title: '鎻愮ず',
+					content: '纭閫�鍑虹櫥褰曪紵',
+					success: res => {
+						if(res.confirm) {
+							uni.clearStorageSync()
+							uni.redirectTo({
+								url: '/pages/index/index'
+							})
+						}
+					}
 				})
 			}
 		}

--
Gitblit v1.9.1