123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <template>
- <div class="forget-pass-model">
- <div class="header-nav" @click="changeModel">
- <span><i class="el-icon-back"></i></span>
- <span><!-- 忘记密码 -->{{ $t('LoginPage.label_forget') }}</span>
- </div>
- <div class="step-container model-wrap" v-show="currentStep===0">
- <el-form
- ref="modelForm"
- label-position="right"
- label-width="0px"
- :model="form"
- :rules="rules">
- <el-form-item prop="account">
- <el-input
- type="text"
- v-model="form.account"
- auto-complete="off"
- :placeholder="$t('LoginPage.ph_account')">
- </el-input>
- </el-form-item>
- <el-form-item prop="picCode">
- <el-input
- class="input-with-slot"
- type="text"
- v-model="form.picCode"
- auto-complete="off"
- :placeholder="$t('LoginPage.ph_img_code')"
- >
- <div class="pic-box" slot="append" @click="getCodePic">
- <img :src="picSrc" alt="图形验证码"/>
- </div>
- </el-input>
- </el-form-item>
- </el-form>
- <el-button class="submit_btn" @click="getUserInfo"><!-- 下一步 -->{{ $t('Dialog.next_step') }}</el-button>
- </div>
- <div class="step-container" v-show="currentStep>0">
- <div class="container-header">
- <p> {{ $t('LoginPage.label_find_pwd',{name: form.account}) }}</p>
- <ModelSteps :active-step="currentStep"/>
- </div>
- <div class="container-inner model-wrap" v-show="currentStep===1">
- <VerificationBox
- verifies-type="mobile"
- :info-text="userMobile||$t('LoginPage.label_not_bind')"
- :hideBtn="!userMobile"
- @goNext="getCode"
- />
- <VerificationBox
- verifies-type="email"
- :info-text="userEmail||$t('LoginPage.label_not_bind')"
- :hideBtn="!userEmail"
- @goNext="getCode"
- />
- </div>
- <div class="container-inner" v-show="currentStep===2">
- <CaptchaInput
- ref="captInput"
- />
- <div class="btn-wrap">
- <el-button type="primary" plain @click="changeModel"><!-- 上一步 -->{{ $t('Dialog.prev_step') }}</el-button>
- <el-button type="primary" @click="checkInput"><!-- 下一步 -->{{ $t('Dialog.next_step') }}</el-button>
- </div>
-
- </div>
- <div class="container-inner model-wrap" v-show="currentStep===3">
- <el-form
- ref="passForm"
- label-position="right"
- label-width="0px"
- :model="passForm"
- :rules="passRules">
- <el-form-item prop="pass1">
- <el-input
- type="password" show-password
- v-model.trim="passForm.pass1"
- auto-complete="off"
- @copy.native.capture.prevent="()=>{return false}"
- @cut.native.capture.prevent="()=>{return false}"
- @paste.native.capture.prevent="()=>{return false}"
- :placeholder="$t('LoginPage.ph_new_pwd')">
- </el-input>
- </el-form-item>
- <el-form-item prop="pass2">
- <el-input
- type="password" show-password
- v-model.trim="passForm.pass2"
- auto-complete="off"
- @copy.native.capture.prevent="()=>{return false}"
- @cut.native.capture.prevent="()=>{return false}"
- @paste.native.capture.prevent="()=>{return false}"
- :placeholder="$t('ResetPwdPage.vaild_new')">
- </el-input>
- </el-form-item>
- </el-form>
- <el-button class="submit_btn" @click="handleResetPass">{{checkPassStr}}</el-button>
- </div>
- </div>
- </div>
- </template>
- <script>
- import CaptchaInput from './components/CaptchaInput.vue';
- import ModelSteps from './components/ModelSteps.vue';
- import VerificationBox from './components/VerificationBox.vue';
- import modelMixins from './modelMixins';
- import{checkPassWord} from '@/utils/commonOptions';
- import http from '@/api/http.js';
- import {departInterence } from "@/api/api.js";
- export default {
- mixins:[modelMixins],
- props:{
- autoAccount:{//自动填写的账号,如果有,作为form.accout的初始值
- type:String,
- default:''
- }
- },
- components: { VerificationBox, ModelSteps, CaptchaInput },
- data() {
- const validatePass = (rule,value,callback)=>{
- if(value===''){
- callback(new Error(/* '请输入新密码' */this.$t('LoginPage.ph_new_pwd')))
- }
- if(this.passForm.pass2!==''){
- this.$refs.passForm.validateField('pass2')
- }
- if(!checkPassWord(value)){
- callback(new Error(/* '密码要求8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型' */this.$t('ResetPwdPage.vaild_rule')))
- }else{
- callback()
- }
- }
- const validateCheck = (rule,value,callback)=>{
- if(value===''){
- callback(new Error(/* '请输入确认密码' */this.$t('ResetPwdPage.vaild_new')))
- }else if(value!==this.passForm.pass1){
- callback(new Error(/* '两次输入的密码不一致,请检查' */this.$t('ResetPwdPage.vaild_same')))
- }else{
- callback()
- }
- }
- return {
- currentStep:0,
- /* form */
- form:{//步骤0的表单
- account:this.autoAccount,
- picCode:''
- },
- picSrc:'',
- picId:'',
- passForm:{//设置新密码的表单
- pass1:'',
- pass2:''
- },
- /* form rule */
- rules:{},
- passRules:{
- pass1:[{validator: validatePass,trigger: 'blur'}],
- pass2:[{validator: validateCheck,trigger: 'blur'}]
- },
- /*user info */
- userMobile:'',//用户的手机号
- TelAreaCode:'',//用户手机号的区号
- userEmail:'',//用户的邮箱
- /* check way */
- checkWay:'',//选择的验证方式
- authCode:'',//手机/邮箱验证码,从CaptchaInput组件中取
- mobileCountDown:0,//手机获取验证码倒计时
- emailCountDown:0,//邮箱验证码倒计时
- checkPassStr:'确定',//重置密码按钮
- countDownNum:5,
- resetPassTimer:0,
- };
- },
- created(){
- this.getCodePic()
- },
- methods: {
- //获取用户账号信息
- getUserInfo(){
- //检查form是否填写完整
- const {account,picCode} = this.form
- if(!account){
- this.$message.warning(/* '请输入账号' */this.$t('LoginPage.ph_account'))
- return
- }
- if(!picCode){
- this.$message.warning(/* '请输入图形验证码' */this.$t('LoginPage.ph_img_code'))
- return
- }
- //请求接口获取账号数据,赋值userMobile,userEmail
- departInterence.accountCheck({
- CaptchaId:this.picId,
- CaptchaCode:picCode,
- UserName:account
- }).then(res=>{
- if(res.Ret!==200){
- //刷新图形验证码
- this.getCodePic()
- this.form.picCode=''
- return
- }
- if(res.Data){
- this.userMobile = res.Data.Mobile||''
- this.userEmail = res.Data.Email||''
- this.TelAreaCode = res.Data.TelAreaCode||''
- this.goSteps()
- }
-
- })
- },
- //获取对应验证方式的验证码
- getCode(way){
- this.checkWay = way
- departInterence.getCodeVerify({
- VerifyType:way==='mobile'?1:2,
- CaptchaId:this.picId,
- CaptchaCode:this.form.picCode,
- Mobile:way==='mobile'?this.userMobile:'',
- TelAreaCode:way==='mobile'?this.TelAreaCode:'',
- Email:way==='email'?this.userEmail:'',
- Source:3
- }).then(res=>{
- if(res.Ret!==200) return
- this.goSteps()
- })
- },
- //检查输入的验证码
- checkInput(){
- const code = this.$refs.captInput.captchas.map((x) => x.num).join("");
- if(code.length!==6){
- this.$message.warning('请输入完整的验证码')
- return
- }
- departInterence.checkCodeVerify({
- FindType:this.checkWay==='mobile'?1:2,
- VerifyCode:code,
- UserName:this.form.account,
- Mobile:this.checkWay==='mobile'?this.userMobile:'',
- Email:this.checkWay==='email'?this.userEmail:'',
- TelAreaCode:this.checkWay==='mobile'?this.TelAreaCode:''
- }).then(res=>{
- if(res.Ret!==200) return
- this.goSteps()
- })
- },
- goSteps(){
- this.currentStep++
- },
- changeModel(){
- if(this.currentStep>0){
- this.currentStep--
- if(this.currentStep===0){
- this.getCodePic()
- this.form.picCode = ''
- }
- }else{
- this.$emit('changeModel')
- }
-
- },
- handleResetPass(){
- if(this.checkPassStr.includes('去登陆')){
- this.$emit('changeModel')
- return
- }
- this.$refs.passForm.validate((valid)=>{
- if(valid){
- //重置密码
- departInterence.resetPass({
- UserName:this.form.account,
- Password:new http.Base64().encode(this.passForm.pass1),
- RePassword:new http.Base64().encode(this.passForm.pass2)
- }).then(res=>{
- if(res.Ret!==200) return
- this.$message.success(/* '重置密码成功,请登陆' */this.$t('LoginPage.reset_pwd_success_msg'))
- localStorage.setItem('timeKey',Date.now())
- localStorage.setItem("account", new http.Base64().encode(this.form.account));
- localStorage.setItem("checkPass", new http.Base64().encode(this.passForm.pass1));
- this.resetPassCountDown()
- this.resetPassTimer = setInterval(()=>{
- this.resetPassCountDown()
- },1000)
- })
- }
- })
- },
- resetPassCountDown(){
- this.countDownNum--
- this.checkPassStr = `去登陆(${this.countDownNum}s)`
- if(this.countDownNum<=0){
- clearInterval(this.resetPassTimer)
- this.$emit('changeModel')
- return
- }
- }
- },
- };
- </script>
- <style lang="scss">
- @import "./css/formStyle.scss";
- </style>
- <style scoped lang="scss">
- .forget-pass-model{
- .header-nav{
- font-size: 38px;
- margin-bottom: 60px;
- cursor: pointer;
- }
- .step-container{
- .container-header{
- margin-bottom: 60px;
- p{
- font-size: 18px;
- padding-bottom: 20px;
- border-bottom: 1px solid #DCDFE6;
- margin-bottom: 60px;
- }
- .el-steps{
- margin-top: 60px;
- }
- }
- .container-inner{
- .btn-wrap{
- margin-top: 100px;
- text-align: center;
- .el-button{
- width:200px;
- }
- }
- }
- }
- }
- </style>
|