| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 |
- <template>
- <div class="validation">
- <div class="container">
- <div class="content">
- <div class="content-top">
- <h3>密码重置</h3>
- <div class="step">
- <img src="/images/all/step02.png" alt=""/>
- <div class="step-item"><span class="active">账号验证</span><span class="active">密码设置</span><span>设置完成</span></div>
- </div>
- </div>
- <div>
- <el-form :model="newPassword" :rules="rulesQuestion" ref="newPassword" label-width="100px" class="demo-ruleForm">
- <el-form-item prop="password">
- <el-input type="password" v-model="newPassword.password" auto-complete="off" placeholder="新密码"></el-input>
- <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
- <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
- <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
- <div class="pwd low" v-show="showMsgTip4">密码强度 <em></em><em></em><em></em></div>
- </el-form-item>
- <el-form-item prop="confirm">
- <el-input type="password"
- v-model="newPassword.confirm"
- v-bind:class="{active: showPasswordError}"
- auto-complete="off"
- placeholder="确认密码"></el-input>
- <span class="tip passwordError" v-show="showPasswordError">两次输入密码不一致</span>
- </el-form-item>
- <el-form-item>
- <a class="btn finish"
- :disabled="!passwordChecked || !confirmChecked"
- @click="passwordSubmit">提交</a>
- </el-form-item>
- </el-form>
- </div>
- </div>
- <loading v-show="isShowLoading"/>
- </div>
- </div>
- </template>
- <script>
- import Loading from '~components/common/loading/Loading.vue'
- export default {
- name: 'validation',
- components: {
- Loading
- },
- data () {
- // 验证密保
- var validatePassword = (rule, value, callback) => {
- if (this.newPassword.password !== '') {
- if (value.length <= 20 && value.length >= 8) {
- var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
- var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
- if (reg1.test(value)) {
- // callback(new Error('密码强度强'))
- this.showMsgTip3 = true
- this.showMsgTip2 = false
- this.showMsgTip1 = false
- this.showMsgTip4 = false
- this.passwordChecked = true
- } else if (reg2.test(value)) {
- // callback(new Error('密码强度中'))
- this.showMsgTip2 = true
- this.showMsgTip3 = false
- this.showMsgTip1 = false
- this.showMsgTip4 = false
- this.passwordChecked = true
- } else {
- this.showMsgTip1 = true
- this.showMsgTip3 = false
- this.showMsgTip2 = false
- this.showMsgTip4 = false
- this.passwordChecked = false
- }
- } else {
- this.showMsgTip3 = false
- this.showMsgTip2 = false
- this.showMsgTip1 = false
- this.showMsgTip4 = true
- this.passwordChecked = false
- }
- }
- callback()
- }
- var validatePasswordTip = (rule, value, callback) => {
- if (value === '') {
- callback(new Error('请输入密码'))
- this.passwordChecked = false
- } else {
- if (this.newPassword.password !== '') {
- if (value.length <= 20 && value.length >= 8) {
- var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
- var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
- if (reg1.test(value)) {
- this.passwordChecked = true
- } else if (reg2.test(value)) {
- this.passwordChecked = true
- } else {
- callback(new Error('密码须为8-20字符的英文、数字混合'))
- this.passwordChecked = false
- }
- } else {
- callback(new Error('密码须为8-20字符的英文、数字混合'))
- this.passwordChecked = false
- }
- if (this.newPassword.confirm !== '') {
- if (value !== this.newPassword.confirm) {
- this.showPasswordError = true
- // callback(new Error('两次输入密码不一致!'))
- this.confirmChecked = false
- } else {
- this.confirmChecked = true
- this.showPasswordError = false
- callback()
- }
- }
- }
- callback()
- }
- }
- var validateConfirm = (rule, value, callback) => {
- if (value === '') {
- callback(new Error('请再次输入密码'))
- this.showPasswordError = false
- this.confirmChecked = false
- } else if (value !== this.newPassword.password) {
- // callback(new Error('两次输入密码不一致!'))
- this.showPasswordError = true
- this.confirmChecked = false
- } else {
- this.showPasswordError = false
- this.confirmChecked = true
- callback()
- }
- }
- return {
- showPasswordError: false,
- isShowLoading: false,
- showMsgTip1: false,
- showMsgTip2: false,
- showMsgTip3: false,
- showMsgTip4: false,
- passwordChecked: false,
- confirmChecked: false,
- getQuestions: '',
- question1: '',
- question2: '',
- sort1: '',
- sort2: '',
- answer1SecondChecked: false,
- answer2SecondChecked: false,
- newPassword: {
- password: '',
- confirm: ''
- },
- rulesQuestion: {
- password: [
- { validator: validatePasswordTip, trigger: 'blur' },
- { validator: validatePassword, trigger: 'change' }
- ],
- confirm: [
- { validator: validateConfirm, trigger: 'blur' }
- ]
- }
- }
- },
- computed: {
- firstStepToken () {
- return this.$store.state.login.token.data
- }
- },
- mounted () {
- // 获取邮箱token
- this.$nextTick(() => {
- this.getEmailLinkToken()
- })
- },
- methods: {
- passwordSubmit () {
- if (this.passwordChecked && this.confirmChecked) {
- this.isShowLoading = true
- let param = new FormData()
- param.append('password', this.newPassword.password)
- param.append('token', this.firstStepToken)
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post(`/sso/resetPwd`, param, config)
- .then(response => {
- if (response.data.success) {
- this.isShowLoading = false
- this.$router.push({ path: '/reset/passwordResetSetSuccess' })
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- this.$message.error(err.errMsg)
- })
- }
- },
- // 获得邮箱token
- getEmailLinkToken () {
- var url = window.location.search
- var request = {}
- if (url.indexOf('?' !== -1)) {
- var str = url.substr(1)
- var strs = str.split('&')
- for (var i = 0; i < strs.length; i++) {
- request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
- }
- }
- this.Token = request['token'] || ''
- if (this.Token) {
- this.$store.commit('login/GET_TOKEN', this.Token)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .validation {
- margin: 0 auto;
- width: 100%;
- background: #eee;
- .container{
- padding-top: 50px;
- margin: 0 auto;
- width: 980px;
- text-align: center;
- .content{
- padding: 0 50px;
- margin: 50px auto 0;
- width: 100%;
- /*height: 540px;*/
- text-align: center;
- background: #fff;
- .content-top{
- height: 80px;
- line-height: 80px;
- h3{
- margin-bottom: 0;
- font-size: 24px;
- color: #000;
- border-bottom: 1px solid #dcdcdc;
- }
- .step{
- position: relative;
- margin-top: 10px;
- img{
- width: 315px;
- height: 46px;
- }
- .step-item{
- position: absolute;
- top: 45px;
- left: 265px;
- span{
- margin-right: 85px;
- font-size: 14px;
- color: #b4b4b4;
- }
- span.active {
- color: #0076ad;
- }
- }
- }
- }
- form {
- margin-top: 150px;
- padding-bottom: 44px;
- input{
- padding: 0 0 0 18px;
- width: 360px;
- height: 44px;
- line-height: 44px;
- font-size: 14px;
- color: #000;
- border-radius: 0;
- }
- input.answer {
- background: url("/images/all/more.png") no-repeat 325px center;
- cursor: pointer;
- }
- .pwd {
- margin: 6px 0 -15px 0;
- text-align: left;
- font-size: 13px;
- em{
- display: inline-block;
- margin: 0 8px 2px 0;
- width: 24px;
- height: 6px;
- &:first-child{
- margin-left: 10px;
- }
- }
- span{
- margin-left: 10px;
- font-size: 13px;
- }
- }
- .pwd.sm{
- color: #8c8c8c;
- em {
- background: #bfbfbf;
- &:first-child{
- background: #ff4e00;
- }
- }
- span{
- color: #ff4e00;
- }
- }
- .pwd.md{
- color: #8c8c8c;
- em {
- background: #22ac38;
- &:nth-child(3){
- background: #bfbfbf;
- }
- }
- span{
- color: #22ac38;
- }
- }
- .pwd.lar{
- color: #8c8c8c;
- em {
- background: #00a0e9;
- }
- span{
- color: #00a0e9;
- }
- }
- .pwd.low{
- color: #8c8c8c;
- em{
- background: #bfbfbf;
- }
- }
- span.tip{
- position: absolute;
- top: 0;
- right: -238px;
- font-size: 13px;
- color: #8c8c8c;
- a{
- font-size: 13px;
- color: #0076ad;
- }
- }
- span.tip.passwordError{
- position: absolute;
- top: 3px;
- left: 380px;
- width: 200px;
- text-align: left;
- color: #ff4949;
- font-size: 12px;
- }
- i{
- position: absolute;
- top: 13px;
- left: 20px;
- font-size: 20px;
- color: #a0a0a0;
- }
- .btn {
- margin: 34px 0 16px 0;
- width: 360px;
- height: 44px;
- line-height: 44px;
- font-size: 16px;
- color: #fff;
- background: #0076AD;
- border-radius: 3px;
- }
- }
- .content-bottom{
- margin: 155px auto 0;
- padding-bottom: 50px;
- width: 360px;
- div.warp{
- padding-bottom: 65px;
- }
- p{
- font-size: 24px;
- color: #323232;
- img{
- margin-right: 20px;
- width: 30px;
- height: 28px;
- }
- }
- p.pass{
- font-size: 24px;
- color: #e77405;
- img{
- height: 30px;
- }
- }
- p.passed {
- color: #2ab300;
- img{
- height: 30px;
- }
- }
- span{
- display: inline-block;
- font-size: 14px;
- color: #8b8b8b;
- }
- span.close-tip{
- margin: 15px 0 140px 0;
- }
- .close-btn{
- margin: 0 auto;
- width: 200px;
- height: 36px;
- line-height: 36px;
- font-size: 14px;
- text-align: center;
- color: #323232;
- border: 1px solid #d2d2d2;
- border-radius: 3px;
- cursor: pointer ;
- }
- span.use{
- display: inline-block;
- margin-bottom: 30px;
- width: 360px;
- font-size: 14px;
- color: #000;
- text-align: left;
- em{
- font-size: 14px;
- font-style: normal;
- color: #000;
- }
- }
- .form-group {
- margin: 0 auto 16px;
- position: relative;
- width: 360px;
- height: 44px;
- line-height: 44px;
- input{
- padding: 0 0 0 18px;
- width: 360px;
- height: 44px;
- line-height: 44px;
- font-size: 14px;
- color: #000;
- border-radius: 0;
- }
- input.msg{
- float: left;
- width: 210px;
- padding: 0 0 0 18px;
- height: 44px;
- line-height: 44px;
- font-size: 14px;
- color: #000;
- border-radius: 0;
- }
- span.msg{
- float: right;
- margin: 0;
- width: 130px;
- height: 44px;
- line-height: 44px;
- text-align: center ;
- font-size: 14px;
- color: #5a5a5a;
- background: #f4f4f4;
- border: 1px solid #dcdcdc;
- cursor: pointer;
- }
- span.msg.send{
- background: #d2d2d2;
- color: #fff;
- }
- }
- .btn {
- margin: 34px 0 10px 0;
- width: 360px;
- height: 44px;
- line-height: 44px;
- font-size: 16px;
- color: #fff;
- background: #0076AD;
- border-radius: 3px;
- }
- }
- .choose{
- margin: 155px auto 0;
- padding-bottom: 44px;
- div{
- padding: 0 15px;
- margin: 0 auto 16px;
- width: 360px;
- height: 60px;
- line-height: 60px;
- text-align: left;
- overflow: hidden;
- border: 1px solid #d2d2d2;
- cursor: pointer;
- &:hover,&.active{
- border-color: #0076ad;
- span{
- color: #0076ad;
- }
- i.second {
- color: #0076ad;
- }
- }
- img.first{
- float: left;
- margin: 24px 20px 0 0;
- font-size: 20px;
- color: #323232;
- }
- img.first.mob{
- margin: 22px 20px 0 5px;
- font-size: 28px;
- }
- i.second {
- float: right;
- margin: 20px 0 0 5px;
- font-size: 20px;
- color: #323232;
- }
- span{
- float: left;
- font-size: 14px;
- color: #323232;
- }
- }
- }
- a.return{
- position: absolute;
- left: 0;
- top: -15px;
- img{
- width: 34px !important;
- height: 34px !important;
- }
- }
- }
- }
- }
- </style>
|