修改手机的接入
parent
ea89482012
commit
592827bc3d
|
|
@ -1,5 +1,22 @@
|
||||||
import request from "@/utils/request.js";
|
import request from "@/utils/request.js";
|
||||||
|
|
||||||
|
// 发送手机验证码
|
||||||
|
export function sendSmsCode(mobile, scene) {
|
||||||
|
return request.post('app-api/member/auth/send-sms-code', {
|
||||||
|
mobile,
|
||||||
|
scene
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验手机验证码
|
||||||
|
export function validateSmsCode(mobile, scene, code) {
|
||||||
|
return request.post('app-api/member/auth/validate-sms-code', {
|
||||||
|
mobile,
|
||||||
|
scene,
|
||||||
|
code
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 登出系统
|
// 登出系统
|
||||||
export function logout() {
|
export function logout() {
|
||||||
return request.post('app-api/member/auth/logout');
|
return request.post('app-api/member/auth/logout');
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,8 @@ export function getUserInfo() {
|
||||||
export function updateUser(data) {
|
export function updateUser(data) {
|
||||||
return request.put('app-api/member/user/update', data);
|
return request.put('app-api/member/user/update', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修改用户手机
|
||||||
|
export function updateUserMobile(data) {
|
||||||
|
return request.put('app-api/member/user/update-mobile', data);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,12 +73,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mixins: [sendVerifyCode],
|
mixins: [sendVerifyCode],
|
||||||
mounted() {
|
|
||||||
//this.getCode();
|
|
||||||
},
|
|
||||||
onLoad() {
|
|
||||||
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
async code() {
|
async code() {
|
||||||
|
|
@ -201,7 +195,7 @@
|
||||||
getUserInfo().then(res => {
|
getUserInfo().then(res => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
that.$store.commit("UPDATE_USERINFO", res.data);
|
that.$store.commit("UPDATE_USERINFO", res.data);
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
that.$util.Tips({
|
that.$util.Tips({
|
||||||
title: '登录成功',
|
title: '登录成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
<view class="ChangePassword">
|
<view class="ChangePassword">
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view class="item" v-if="isNew">
|
<view class="item" v-if="isNew">
|
||||||
<input type='number' disabled='true' placeholder='填写手机号码1' placeholder-class='placeholder' v-model="userInfo.phone"></input>
|
<input type='number' disabled='true' placeholder-class='placeholder' v-model="userInfo.mobile" />
|
||||||
</view>
|
</view>
|
||||||
<view class="item" v-if="!isNew">
|
<view class="item" v-if="!isNew">
|
||||||
<input type='number' placeholder='填写手机号码' placeholder-class='placeholder' v-model="phone"></input>
|
<input type='number' placeholder='填写新的手机号码' placeholder-class='placeholder' v-model="phone" />
|
||||||
</view>
|
</view>
|
||||||
<view class="item acea-row row-between-wrapper">
|
<view class="item acea-row row-between-wrapper">
|
||||||
<input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" v-model="captcha"></input>
|
<input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" v-model="captcha" />
|
||||||
<button class="code font-color" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
|
<button class="code font-color" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
|
||||||
{{ text }}
|
{{ text }}
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -18,64 +18,35 @@
|
||||||
<button form-type="submit" v-if="isNew" class="confirmBnt bg-color" @click="next">下一步</button>
|
<button form-type="submit" v-if="isNew" class="confirmBnt bg-color" @click="next">下一步</button>
|
||||||
<button form-type="submit" v-if="!isNew" class="confirmBnt bg-color" @click="editPwd">保存</button>
|
<button form-type="submit" v-if="!isNew" class="confirmBnt bg-color" @click="editPwd">保存</button>
|
||||||
</view>
|
</view>
|
||||||
<!-- #ifdef MP -->
|
|
||||||
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
|
|
||||||
<!-- #endif -->
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import sendVerifyCode from "@/mixins/SendVerifyCode";
|
import { toLogin } from '@/libs/login.js';
|
||||||
import {
|
import { mapGetters } from "vuex";
|
||||||
registerVerify,
|
import * as AuthUtil from '@/api/member/auth.js';
|
||||||
bindingPhone,
|
import * as UserApi from '@/api/member/user.js';
|
||||||
verifyCode,
|
export default {
|
||||||
bindingVerify
|
|
||||||
} from '@/api/api.js';
|
|
||||||
import {
|
|
||||||
toLogin
|
|
||||||
} from '@/libs/login.js';
|
|
||||||
import {
|
|
||||||
mapGetters
|
|
||||||
} from "vuex";
|
|
||||||
// #ifdef MP
|
|
||||||
import authorize from '@/components/Authorize';
|
|
||||||
// #endif
|
|
||||||
export default {
|
|
||||||
mixins: [sendVerifyCode],
|
|
||||||
components: {
|
|
||||||
// #ifdef MP
|
|
||||||
authorize
|
|
||||||
// #endif
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
phone:'',
|
phone: '', // 需要更换的手机号
|
||||||
captcha:'',
|
captcha: '',
|
||||||
isAuto: false, //没有授权的不会自动授权
|
isNew: true, // true 是第一步,校验老的手机号验证码;false 是第二步,校验新手机号的验证码;
|
||||||
isShowAuth: false, //是否隐藏授权
|
oldCaptcha: '', // 进入第二步时,需要使用它保存老的手机验证码
|
||||||
key: '',
|
|
||||||
isNew: true,
|
timer: '',
|
||||||
timer: '',
|
|
||||||
text: '获取验证码',
|
text: '获取验证码',
|
||||||
nums: 60
|
nums: 60,
|
||||||
|
disabled: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
// this.timer = setInterval(this.getTimes, 1000);
|
|
||||||
},
|
|
||||||
computed: mapGetters(['isLogin','userInfo']),
|
computed: mapGetters(['isLogin','userInfo']),
|
||||||
onLoad() {
|
onLoad() {
|
||||||
if (this.isLogin) {
|
if (!this.isLogin) {
|
||||||
// verifyCode().then(res=>{
|
toLogin();
|
||||||
// this.$set(this, 'key', res.data.key)
|
}
|
||||||
// });
|
|
||||||
} else {
|
|
||||||
toLogin();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getTimes(){
|
getTimes() {
|
||||||
this.nums = this.nums - 1;
|
this.nums = this.nums - 1;
|
||||||
this.text = "剩余 " + this.nums + "s";
|
this.text = "剩余 " + this.nums + "s";
|
||||||
if (this.nums < 0) {
|
if (this.nums < 0) {
|
||||||
|
|
@ -87,114 +58,115 @@
|
||||||
this.text = "重新获取";
|
this.text = "重新获取";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoadFun:function(){},
|
|
||||||
// 授权关闭
|
|
||||||
authColse: function(e) {
|
|
||||||
this.isShowAuth = e
|
|
||||||
},
|
|
||||||
next() {
|
next() {
|
||||||
uni.hideLoading();
|
if (!this.captcha) {
|
||||||
this.isNew = false;
|
return this.$util.Tips({
|
||||||
this.captcha = '';
|
title: '请填写验证码'
|
||||||
clearInterval(this.timer);
|
});
|
||||||
this.disabled = false;
|
}
|
||||||
this.text = "获取验证码";
|
// 校验验证码是否正确
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中',
|
title: '加载中',
|
||||||
mask: true
|
mask: true
|
||||||
});
|
});
|
||||||
if (!this.captcha) return this.$util.Tips({
|
AuthUtil.validateSmsCode(
|
||||||
title: '请填写验证码'
|
this.userInfo.mobile,
|
||||||
});
|
2,
|
||||||
bindingVerify({
|
this.captcha
|
||||||
phone: this.userInfo.phone,
|
).then(res => {
|
||||||
captcha: this.captcha
|
|
||||||
}).then(res => {
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
|
this.oldCaptcha = this.captcha;
|
||||||
this.captcha = '';
|
this.captcha = '';
|
||||||
clearInterval(this.timer);
|
clearInterval(this.timer);
|
||||||
this.disabled = false;
|
this.disabled = false;
|
||||||
this.text = "获取验证码";
|
this.text = "获取验证码";
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
return this.$util.Tips({
|
uni.hideLoading();
|
||||||
|
return this.$util.Tips({
|
||||||
title: err
|
title: err
|
||||||
});
|
});
|
||||||
uni.hideLoading();
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
editPwd: function() {
|
editPwd: function() {
|
||||||
let that = this;
|
if (!this.phone) {
|
||||||
if (!that.phone) return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: '请填写手机号码!'
|
title: '请填写手机号码!'
|
||||||
});
|
});
|
||||||
if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
|
}
|
||||||
title: '请输入正确的手机号码!'
|
if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.phone))) {
|
||||||
});
|
return this.$util.Tips({
|
||||||
if (!that.captcha) return that.$util.Tips({
|
title: '请输入正确的手机号码!'
|
||||||
title: '请填写验证码'
|
});
|
||||||
});
|
}
|
||||||
|
if (!this.captcha) {
|
||||||
|
return this.$util.Tips({
|
||||||
|
title: '请填写验证码'
|
||||||
|
});
|
||||||
|
}
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '是否更换绑定账号',
|
title: '是否更换绑定账号',
|
||||||
confirmText: '绑定',
|
confirmText: '绑定',
|
||||||
success(res) {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (!res.confirm) {
|
||||||
bindingPhone({
|
return this.$util.Tips({
|
||||||
phone: that.phone,
|
title: '您已取消更换绑定!'
|
||||||
captcha: that.captcha
|
}, {
|
||||||
}).then(res => {
|
tab: 5,
|
||||||
return that.$util.Tips({
|
url: '/pages/users/user_info/index'
|
||||||
title: res.message,
|
});
|
||||||
icon: 'success'
|
}
|
||||||
}, {
|
UserApi.updateUserMobile({
|
||||||
tab: 5,
|
mobile: this.phone,
|
||||||
url: '/pages/users/user_info/index'
|
code: this.captcha,
|
||||||
});
|
oldCode: this.captcha
|
||||||
}).catch(err => {
|
}).then(res => {
|
||||||
return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: err
|
title: res.message,
|
||||||
});
|
icon: 'success'
|
||||||
})
|
}, {
|
||||||
} else if (res.cancel) {
|
tab: 5,
|
||||||
return that.$util.Tips({
|
url: '/pages/users/user_info/index'
|
||||||
title: '您已取消更换绑定!'
|
});
|
||||||
}, {
|
}).catch(err => {
|
||||||
tab: 5,
|
return this.$util.Tips({
|
||||||
url: '/pages/users/user_info/index'
|
title: err
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 发送验证码
|
* 发送验证码
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
async code() {
|
async code() {
|
||||||
this.nums = 60;
|
if (!this.isNew) {
|
||||||
uni.showLoading({
|
if (!this.phone) {
|
||||||
title: '加载中',
|
return this.$util.Tips({
|
||||||
mask: true
|
title: '请填写手机号码!'
|
||||||
});
|
});
|
||||||
let that = this;
|
}
|
||||||
if(!that.isNew){
|
if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.phone))) {
|
||||||
if (!that.phone) return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: '请填写手机号码!'
|
title: '请输入正确的手机号码!'
|
||||||
});
|
});
|
||||||
if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
|
}
|
||||||
title: '请输入正确的手机号码!'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
await registerVerify(that.isNew?that.userInfo.phone:that.phone).then(res => {
|
// 执行验证码的发送
|
||||||
that.$util.Tips({
|
this.nums = 60;
|
||||||
title: res.message
|
uni.showLoading({
|
||||||
|
title: '加载中',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
await AuthUtil.sendSmsCode(this.isNew ? this.userInfo.mobile : this.phone, 2).then(res => {
|
||||||
|
this.$util.Tips({
|
||||||
|
title: '验证码已发送'
|
||||||
});
|
});
|
||||||
|
this.timer = setInterval(this.getTimes, 1000);
|
||||||
that.timer = setInterval(that.getTimes, 1000);
|
this.disabled = true;
|
||||||
that.disabled = true;
|
uni.hideLoading();
|
||||||
uni.hideLoading();
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
return that.$util.Tips({
|
return this.$util.Tips({
|
||||||
title: err
|
title: err
|
||||||
});
|
});
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|
@ -210,16 +182,16 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
/* #ifdef APP-VUE */
|
/* #ifdef APP-VUE */
|
||||||
margin-top: 50rpx;
|
margin-top: 50rpx;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
/* #ifndef APP-VUE */
|
/* #ifndef APP-VUE */
|
||||||
|
|
||||||
margin-top: 200rpx;
|
margin-top: 200rpx;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
|
|
||||||
|
|
||||||
image {
|
image {
|
||||||
width: 180rpx;
|
width: 180rpx;
|
||||||
height: 180rpx;
|
height: 180rpx;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue