| | |
| | | 手机号 |
| | | </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"> |
| | |
| | | 验证码 |
| | | </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> |
| | |
| | | </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 { |
| | |
| | | onLoad(options) { |
| | | if(options.code) { |
| | | this.form.userType = options.code |
| | | } |
| | | if(options.companyId) { |
| | | this.form.companyId = options.companyId |
| | | } |
| | | }, |
| | | onUnload() { |
| | |
| | | uni.showLoading({ |
| | | title: '正在获取验证码' |
| | | }) |
| | | 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('倒计时结束后再发送'); |
| | |
| | | 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() { |