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/changePhone/changePhone.vue |   74 +++++++++++++++++++++++++++++-------
 1 files changed, 59 insertions(+), 15 deletions(-)

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() {

--
Gitblit v1.9.1