From b5f084460e9e639358fbf91056a86be8d0a5c4b2 Mon Sep 17 00:00:00 2001
From: yaolonglong <yaolonglong15@163.com>
Date: 星期四, 09 十月 2025 20:18:57 +0800
Subject: [PATCH] 获取验证码功能
---
policy/changePhone/changePhone.vue | 90 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 75 insertions(+), 15 deletions(-)
diff --git a/policy/changePhone/changePhone.vue b/policy/changePhone/changePhone.vue
index 86217f4..592dccd 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 {
@@ -52,6 +51,9 @@
onLoad(options) {
if(options.code) {
this.form.userType = options.code
+ }
+ if(options.companyId) {
+ this.form.companyId = options.companyId
}
},
onUnload() {
@@ -81,10 +83,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 +112,68 @@
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) {
+
+ if(val.data.data == 1) {
+ uni.showToast({
+ title: '淇敼鎴愬姛锛岃閲嶆柊鐧诲綍',
+ icon: 'none'
+ })
+ uni.clearStorage()
+ setTimeout(() => {
+ uni.reLaunch({
+ url: '/pages/companyLogin/companyLogin?code=02'
+ })
+ }, 500)
+ } else {
+ uni.showToast({
+ title: '淇敼鎴愬姛',
+ icon: 'none'
+ })
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 500)
+ }
+ }
+
})
},
getInfo() {
--
Gitblit v1.9.1