307 lines
8.1 KiB
Vue
307 lines
8.1 KiB
Vue
<template>
|
||
<view :style="viewColor">
|
||
<view class="tab">
|
||
<u-tabs :list="tabList" :current="current" @change="change" :activeStyle="{color: '#333', fontSize: '32rpx'}" lineColor="#e93323"></u-tabs>
|
||
</view>
|
||
<form report-submit='true'>
|
||
<view>
|
||
<view class="ChangePassword">
|
||
<view class="list">
|
||
<view class="item">
|
||
<text class="phone">{{userInfo.account}}</text>
|
||
</view>
|
||
<view v-if="current==0" class="item acea-row row-between-wrapper codeVal">
|
||
<input type='number' placeholder='验证码' placeholder-class='placeholder' class="codeIput" v-model="captcha"></input>
|
||
<button class="code" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="handleVerify">
|
||
{{ text }}
|
||
</button>
|
||
</view>
|
||
<view v-else class="item">
|
||
<input type='password' placeholder='旧密码' placeholder-class='placeholder' v-model="old_password" autocomplete="off"></input>
|
||
</view>
|
||
<view class="border"></view>
|
||
|
||
<view class="item">
|
||
<input type='password' placeholder='新密码' placeholder-class='placeholder' v-model="password" autocomplete="off"></input>
|
||
</view>
|
||
<view class="item">
|
||
<input type='password' placeholder='确认新密码' placeholder-class='placeholder' v-model="password_confirm" autocomplete="off"></input>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<button form-type="submit" @click="confirmSubmit" class="confirmBnt">确认</button>
|
||
</view>
|
||
|
||
</form>
|
||
<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
|
||
<Verify @success="success" :captchaType="'blockPuzzle'" :imgSize="{ width: '330px', height: '155px' }" ref="verify"></Verify>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
import sendVerifyCode from "@/mixins/SendVerifyCode";
|
||
import { modifyPassword, verifyCode, appletsDecrypt } from '@/api/api.js';
|
||
import { registerVerify } from '@/api/user.js'
|
||
import { changePassword, indexCode, resetPassword } from '@/api/apiUser.js'
|
||
import {
|
||
mapGetters
|
||
} from "vuex";
|
||
import authorize from '@/components/Authorize';
|
||
import Verify from '@/components/verify/verify.vue';
|
||
import { Toast } from "../../libs/uniApi";
|
||
export default {
|
||
mixins: [sendVerifyCode],
|
||
components: {
|
||
authorize,
|
||
Verify
|
||
},
|
||
data() {
|
||
return {
|
||
userInfo: {},
|
||
account:'',
|
||
old_password: '',
|
||
password_confirm: '',
|
||
password: '',
|
||
captcha:'',
|
||
current: 0,
|
||
isAuto: false, //没有授权的不会自动授权
|
||
isShowAuth: false, //是否隐藏授权
|
||
key: '',
|
||
codeVal: '',
|
||
disabled: false,
|
||
tabList: [
|
||
{name: '验证码'},
|
||
{name: '旧密码'},
|
||
]
|
||
};
|
||
},
|
||
computed: mapGetters(['isLogin', 'viewColor']),
|
||
onLoad() {
|
||
this.getUserInfo();
|
||
},
|
||
methods: {
|
||
change(e){
|
||
this.current = e.index;
|
||
},
|
||
onLoadFun:function(){
|
||
this.isShowAuth = false;
|
||
},
|
||
// 授权关闭
|
||
authColse: function(e) {
|
||
this.isShowAuth = e
|
||
},
|
||
/**
|
||
* 获取个人用户信息
|
||
*/
|
||
getUserInfo: function() {
|
||
this.userInfo = this.$store.state.app.userInfo;
|
||
},
|
||
confirmSubmit: function() {
|
||
let that = this;
|
||
if (!that.password) return that.$util.Tips({
|
||
title: '请填写密码!'
|
||
});
|
||
if (!that.password_confirm) return that.$util.Tips({
|
||
title: '请确认新密码!'
|
||
});
|
||
if (that.password !== that.password_confirm) return that.$util.Tips({
|
||
title: '两次密码不一致,请重新填写!'
|
||
});
|
||
if(this.current==0){
|
||
if (!that.captcha) return that.$util.Tips({
|
||
title: '请填写验证码'
|
||
});
|
||
resetPassword({
|
||
phone: this.userInfo.account,
|
||
code: this.captcha,
|
||
password: this.password,
|
||
password_confirm: this.password_confirm
|
||
}).then(res => {
|
||
that.$util.Tips({
|
||
title: '修改成功!',
|
||
icon: 'success'
|
||
});
|
||
this.$u.sleep(800).then(()=>{
|
||
this.$store.commit('LOGOUT');
|
||
uni.reLaunch({
|
||
url:'/pages/login/login'
|
||
})
|
||
})
|
||
}).catch(err => {
|
||
return that.$util.Tips({
|
||
title: err
|
||
});
|
||
})
|
||
}
|
||
else if(this.current==1){
|
||
changePassword({
|
||
password: that.password,
|
||
password_confirm: that.password_confirm,
|
||
old_password: that.old_password
|
||
}).then(res => {
|
||
that.$util.Tips({
|
||
title: '修改成功!',
|
||
icon: 'success'
|
||
});
|
||
this.$u.sleep(800).then(()=>{
|
||
this.$store.commit('LOGOUT');
|
||
uni.reLaunch({
|
||
url:'/pages/login/login'
|
||
})
|
||
})
|
||
}).catch(err => {
|
||
return that.$util.Tips({
|
||
title: err
|
||
});
|
||
})
|
||
}
|
||
|
||
},
|
||
/**
|
||
* 发送验证码
|
||
*
|
||
*/
|
||
async code(data) {
|
||
let that = this;
|
||
// if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.userInfo.phone))) return that.$util.Tips({
|
||
// title: '请输入正确的手机号码!'
|
||
// });
|
||
this.disabled = true
|
||
await registerVerify({
|
||
phone:that.userInfo.phone,
|
||
code:that.captcha,
|
||
type: 'change_pwd',
|
||
captchaType: 'blockPuzzle',
|
||
captchaVerification: data.captchaVerification
|
||
}).then(res => {
|
||
this.disabled = false
|
||
that.$util.Tips({
|
||
title: res.msg
|
||
});
|
||
that.sendCode();
|
||
}).catch(err => {
|
||
this.disabled = false
|
||
return that.$util.Tips({
|
||
title: err
|
||
});
|
||
});
|
||
},
|
||
success(data) {
|
||
this.$refs.verify.hide();
|
||
this.code(data);
|
||
},
|
||
handleVerify() {
|
||
indexCode({
|
||
phone: this.userInfo.account,
|
||
scene: 104 //找回密码
|
||
}).then((res)=>{
|
||
this.sendCode();
|
||
Toast('验证码已发送');
|
||
}).catch(e=>{
|
||
Toast(e)
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.tab{
|
||
background-color: #fff;
|
||
padding: 0 20rpx;
|
||
}
|
||
.ChangePassword{
|
||
background: #fff;
|
||
padding-top: 0;
|
||
}
|
||
.ChangePassword .phone {
|
||
font-size: 32rpx;
|
||
}
|
||
|
||
.ChangePassword .list .item {
|
||
width: 640rpx;
|
||
margin: 0 auto;
|
||
height: 110rpx;
|
||
border-bottom: 2rpx solid #f0f0f0;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.ChangePassword .list .item input {
|
||
width: 100%;
|
||
font-size: 32rpx;
|
||
|
||
}
|
||
/deep/.uni-input-input{
|
||
// box-shadow: inset 0 0 0 0 #fff;
|
||
}
|
||
|
||
.ChangePassword .list .item .placeholder {
|
||
color: #b9b9bc;
|
||
}
|
||
|
||
.ChangePassword .list .item input.codeIput {
|
||
width: 340rpx;
|
||
}
|
||
|
||
.ChangePassword .list .item .code {
|
||
font-size: 32rpx;
|
||
position: relative;
|
||
padding-left: 26rpx;
|
||
color: var(--view-theme);
|
||
&::before{
|
||
content: "";
|
||
width: 1rpx;
|
||
height: 30rpx;
|
||
position: absolute;
|
||
top: 10rpx;
|
||
left: 0;
|
||
background: #DDDDDD;
|
||
display: inline-block;
|
||
}
|
||
}
|
||
.ChangePassword .list .item .code.on {
|
||
color: #b9b9bc !important;
|
||
}
|
||
.ChangePassword .list .border{
|
||
width: 100%;
|
||
height: 21rpx;
|
||
background: #F5F5F5;
|
||
}
|
||
.confirmBnt {
|
||
font-size: 32rpx;
|
||
width: 580rpx;
|
||
height: 90rpx;
|
||
border-radius: 45rpx;
|
||
color: #fff;
|
||
margin: 70rpx auto 0 auto;
|
||
text-align: center;
|
||
line-height: 90rpx;
|
||
background-color: var(--view-theme);
|
||
}
|
||
.getPhoneBtn{
|
||
font-size: 32rpx;
|
||
width: 580rpx;
|
||
height: 90rpx;
|
||
border-radius: 45rpx;
|
||
border: 1px solid var(--view-theme);
|
||
color: var(--view-theme);
|
||
margin: 40rpx auto 0 auto;
|
||
text-align: center;
|
||
line-height: 90rpx;
|
||
.iconfont{
|
||
font-size: 32rpx;
|
||
margin-right: 12rpx;
|
||
}
|
||
}
|
||
</style>
|