ChangePasswordChooseStyle.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <template>
  2. <div class="validation">
  3. <div class="container">
  4. <div class="content" v-show="goFirstStep">
  5. <div class="content-top">
  6. <h3>密码重置</h3>
  7. <div class="step">
  8. <img src="/images/all/step01.png" alt=""/>
  9. <div class="step-item"><span class="active">账号验证</span><span>密码设置</span><span>设置完成</span></div>
  10. </div>
  11. </div>
  12. <div class="choose">
  13. <div v-show="hasValidPasswordWay"
  14. @click="chooseWay(1)">
  15. <img src="/images/all/icon03.png" alt="" class="first mob"/>
  16. <span>通过登录密码</span><i class="fa fa-angle-right second"></i>
  17. </div>
  18. <div v-show="hasValidPhoneWay"
  19. @click="chooseWay(2)">
  20. <img src="/images/all/icon01.png" alt="" class="first mob"/>
  21. <span>通过验证手机</span><i class="fa fa-angle-right second"></i>
  22. </div>
  23. <div v-show="hasValidEmailWay"
  24. @click="chooseWay(3)">
  25. <img src="/images/all/icon02.png" alt="" class="first"/>
  26. <span>通过验证邮箱</span><i class="fa fa-angle-right second"></i>
  27. </div>
  28. <!--修改密码隐藏人工申诉入口-->
  29. <!--<div v-show="showManualAppeal"-->
  30. <!--@click="goPasswordSetAppeal">-->
  31. <!--<img src="/images/all/icon04.png" alt="" class="first"/>-->
  32. <!--<span>通过人工申诉</span><i class="fa fa-angle-right second"></i>-->
  33. <!--</div>-->
  34. </div>
  35. </div>
  36. <div class="content" v-show="showPasswordValid">
  37. <div class="content-top">
  38. <h3>密码重置</h3>
  39. <div class="step">
  40. <img src="/images/all/step01.png" alt=""/>
  41. <div class="step-item"><span class="active">账号验证</span><span>密码设置</span><span>设置完成</span></div>
  42. <a href="" class="return"><img src="/images/all/return.png" alt=""/></a>
  43. </div>
  44. </div>
  45. <div class="content-bottom">
  46. <div>
  47. <el-form :model="valid1" :rules="rules1" ref="valid1" label-width="100px" class="demo-ruleForm" style="margin-top: 0;">
  48. <el-form-item prop="password">
  49. <el-input type="password" v-model="valid1.password"
  50. auto-complete="off"
  51. placeholder="请输入当前密码"></el-input>
  52. </el-form-item>
  53. <el-form-item>
  54. <a class="btn finish"
  55. :disabled="!oldPasswordChecked"
  56. @click="goPasswordNextStep">下一步</a>
  57. </el-form-item>
  58. </el-form>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="content" v-show="showPhoneValid">
  63. <div class="content-top">
  64. <h3>密码重置</h3>
  65. <div class="step">
  66. <img src="/images/all/step01.png" alt=""/>
  67. <div class="step-item"><span class="active">账号验证</span><span>密码设置</span><span>设置完成</span></div>
  68. <a href="" class="return"><img src="/images/all/return.png" alt=""/></a>
  69. </div>
  70. </div>
  71. <div class="content-bottom">
  72. <span class="use">使用手机号<em>{{secretMobile}}</em>接收验证码</span>
  73. <div>
  74. <el-form :model="valid" :rules="rules" ref="valid" label-width="100px" class="demo-ruleForm" style="margin-top: 0;">
  75. <el-form-item prop="code">
  76. <el-input type="text" v-model="valid.code"
  77. v-bind:class="{ active: codeErrorChecked }"
  78. auto-complete="off" class="msg"
  79. placeholder="短信验证码"></el-input>
  80. <el-button type="primary" class="code"
  81. v-show="sendAccountCode"
  82. @click="getCheckCode">获取验证码</el-button>
  83. <el-button type="primary" v-show="!sendAccountCode" class="code code-send">已发送({{account_time}}s)</el-button>
  84. <span v-show="codeErrorChecked" class="tip codeError-tip" >{{codeErrorMsg}}</span>
  85. </el-form-item>
  86. <el-form-item>
  87. <a class="btn finish"
  88. :disabled="!codeChecked"
  89. @click="goNextStep">下一步</a>
  90. </el-form-item>
  91. </el-form>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="content" v-show="showEmailValid">
  96. <div class="content-top">
  97. <h3>密码重置</h3>
  98. <div class="step">
  99. <img src="/images/all/step01.png" alt=""/>
  100. <div class="step-item"><span class="active">账号验证</span><span>密码设置</span><span>设置完成</span></div>
  101. <a href="" class="return"><img src="/images/all/return.png" alt=""/></a>
  102. </div>
  103. </div>
  104. <div class="content-bottom">
  105. <span class="use">使用电子邮箱<em>{{secretEmail}}</em>进行验证,有效期7天</span>
  106. <div class="warp"
  107. @click="firstStepValidEmail"
  108. v-show="!emailSendSuccess">
  109. <button class="btn">发送验证请求</button>
  110. </div>
  111. <div class="warp" v-show="emailSendSuccess">
  112. <button class="btn" :disabled="emailSendSuccess">已发送验证邮件,请查收</button>
  113. </div>
  114. </div>
  115. </div>
  116. <loading v-show="isShowLoading"/>
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import Loading from '~components/common/loading/Loading.vue'
  122. export default {
  123. name: 'validation',
  124. components: {
  125. Loading
  126. },
  127. data () {
  128. // 第一步校验验证码
  129. var validateFirstCode = (rule, value, callback) => {
  130. if (value === '') {
  131. callback(new Error('请填写正确的验证码'))
  132. this.codeErrorChecked = false
  133. this.codeChecked = false
  134. } else {
  135. if (this.valid.code !== '') {
  136. if (this.token) {
  137. if (this.valid.code !== '' && this.getMobile !== '') {
  138. let param = new FormData()
  139. param.append('mobile', this.getMobile)
  140. param.append('code', this.valid.code)
  141. param.append('token', this.token)
  142. let config = {
  143. headers: {'Content-Type': 'multipart/form-data'}
  144. }
  145. this.$http.post(`/sso/resetPwd/checkCode`, param, config)
  146. .then(response => {
  147. if (response.data.success) {
  148. this.codeChecked = true
  149. this.codeErrorChecked = false
  150. } else {
  151. this.codeErrorChecked = true
  152. this.codeChecked = false
  153. return Promise.reject(response.data)
  154. }
  155. }).catch(err => {
  156. this.codeErrorMsg = err.errMsg
  157. this.codeErrorChecked = true
  158. this.codeChecked = false
  159. })
  160. }
  161. } else {
  162. callback(new Error('请先获取验证码'))
  163. }
  164. }
  165. callback()
  166. }
  167. }
  168. // 第一步验证原密码
  169. var validateFirstPassword = (rule, value, callback) => {
  170. if (value === '') {
  171. callback(new Error('请填写原密码'))
  172. this.oldPasswordChecked = false
  173. } else {
  174. if (this.valid1.password !== '') {
  175. if (this.valid1.password.length >= 20) {
  176. callback(new Error('密码长度不超过20个字符'))
  177. this.oldPasswordChecked = false
  178. } else {
  179. this.oldPasswordChecked = true
  180. }
  181. }
  182. callback()
  183. }
  184. }
  185. return {
  186. isShowLoading: false,
  187. goFirstStep: true,
  188. showManualAppeal: false,
  189. hasValidPasswordWay: true,
  190. hasValidPhoneWay: false,
  191. hasValidEmailWay: false,
  192. showPasswordValid: false,
  193. showPhoneValid: false,
  194. showEmailValid: false,
  195. sendAccountCode: true,
  196. account_time: 0,
  197. codeErrorChecked: false,
  198. oldPasswordChecked: false,
  199. codeChecked: false,
  200. secretMobile: '',
  201. secretEmail: '',
  202. getMobile: '',
  203. getEmail: '',
  204. codeErrorMsg: '',
  205. firstStepToken: '',
  206. emailSendSuccess: false,
  207. valid: {
  208. code: ''
  209. },
  210. valid1: {
  211. password: ''
  212. },
  213. rules: {
  214. code: [
  215. {validator: validateFirstCode, trigger: 'blur'}
  216. ]
  217. },
  218. rules1: {
  219. password: [
  220. {validator: validateFirstPassword, trigger: 'blur'}
  221. ]
  222. }
  223. }
  224. },
  225. computed: {
  226. logged () {
  227. // console.log(this.$store.state.option.isLogin.data.content)
  228. return this.$store.state.option.isLogin.data.content
  229. }
  230. },
  231. mounted () {
  232. // 验证是否登录
  233. this.$nextTick(() => {
  234. this.isLogin()
  235. // 刷新统计信息
  236. setInterval(() => {
  237. this.isLogin()
  238. }, 10000)
  239. })
  240. // 获取验证方式
  241. this.$nextTick(() => {
  242. this.getVerifyWay()
  243. })
  244. },
  245. methods: {
  246. // 判断用户是否登录
  247. isLogin () {
  248. if (!this.logged.isLogin) {
  249. // 未登录跳到登录页面
  250. window.location.href = '/'
  251. }
  252. },
  253. // 获取验证方式
  254. getVerifyWay () {
  255. this.$http.get('/sso/resetPwd/checkType/update')
  256. .then(response => {
  257. if (response.data.success) {
  258. if (!response.data.content) {
  259. this.hasValidPhoneWay = false
  260. this.hasValidEmailWay = false
  261. } else {
  262. if (response.data.content.mobile) {
  263. this.hasValidPhoneWay = true
  264. this.getMobile = response.data.content.mobile
  265. var reg = /^(\d{3})\d{6}(\d{2})$/
  266. this.secretMobile = this.getMobile.replace(reg, '$1******$2')
  267. }
  268. if (response.data.content.email) {
  269. this.hasValidEmailWay = true
  270. this.getEmail = response.data.content.email
  271. let getEmailIndex = this.getEmail.indexOf('@')
  272. if (getEmailIndex > 3) {
  273. let len = this.getEmail.substring(3, getEmailIndex)
  274. this.secretEmail = this.getEmail.replace(len, '*')
  275. } else {
  276. this.getEmailArr = this.getEmail.split('')
  277. this.getEmailSplit = this.getEmailArr.splice(getEmailIndex, 0, '*')
  278. this.secretEmail = this.getEmailArr.join('')
  279. }
  280. }
  281. }
  282. this.showManualAppeal = true
  283. this.hasValidPasswordWay = true
  284. } else {
  285. return Promise.reject(response.data)
  286. }
  287. }).catch(err => {
  288. this.$message.error(err.errMsg)
  289. })
  290. },
  291. // 选择方式
  292. chooseWay (flag) {
  293. if (flag === 1) {
  294. this.showPasswordValid = true
  295. } else if (flag === 2) {
  296. this.showPhoneValid = true
  297. } else if (flag === 3) {
  298. this.showEmailValid = true
  299. }
  300. this.goFirstStep = false
  301. },
  302. // 跳转到人工申诉页面
  303. goPasswordSetAppeal () {
  304. window.location.href = '/appeals/passwordRestAppeal'
  305. },
  306. // 获取第一步手机验证码
  307. getCheckCode () {
  308. this.isShowLoading = true
  309. this.$http.get(`/sso/resetPwd/check/mobile`)
  310. .then(response => {
  311. this.isShowLoading = false
  312. if (response.data.success) {
  313. this.token = response.data.content.token
  314. if (this.token !== '') {
  315. this.$message({
  316. message: '验证码已经发送到您的手机,请注意查收',
  317. type: 'success'
  318. })
  319. this.sendAccountCode = false
  320. this.account_time = 60
  321. var accountTime = setInterval(() => {
  322. this.account_time--
  323. if (this.account_time <= 0) {
  324. this.sendAccountCode = true
  325. clearInterval(accountTime)
  326. }
  327. }, 1000)
  328. }
  329. } else {
  330. return Promise.reject(response.data)
  331. }
  332. }).catch(err => {
  333. this.isShowLoading = false
  334. this.$message.error(err.errMsg)
  335. })
  336. },
  337. // 原密码验证
  338. goPasswordNextStep () {
  339. if (this.oldPasswordChecked) {
  340. this.isShowLoading = true
  341. let param = new FormData()
  342. param.append('password', this.valid1.password)
  343. let config = {
  344. headers: {'Content-Type': 'multipart/form-data'}
  345. }
  346. this.$http.post(`/sso/resetPwd/check/password`, param, config)
  347. .then(response => {
  348. this.isShowLoading = false
  349. if (response.data.success) {
  350. this.$store.commit('login/GET_TOKEN', response.data.content.token)
  351. this.$router.push({ path: '/reset/passwordResetValidQuestion' })
  352. } else {
  353. return Promise.reject(response.data)
  354. }
  355. }).catch(err => {
  356. this.isShowLoading = false
  357. this.$message.error(err.errMsg)
  358. })
  359. }
  360. },
  361. // 手机号验证下一步
  362. goNextStep () {
  363. if (this.codeChecked) {
  364. this.isShowLoading = true
  365. let param = new FormData()
  366. param.append('code', this.valid.code)
  367. param.append('token', this.token)
  368. let config = {
  369. headers: {'Content-Type': 'multipart/form-data'}
  370. }
  371. this.$http.post(`/sso/resetPwd/check/mobile`, param, config)
  372. .then(response => {
  373. this.isShowLoading = false
  374. if (response.data.success) {
  375. this.$store.commit('login/GET_TOKEN', response.data.content.token)
  376. this.showPhoneValid = false
  377. this.$router.push({ path: '/reset/passwordResetValidQuestion' })
  378. } else {
  379. this.showPhoneValid = true
  380. return Promise.reject(response.data)
  381. }
  382. }).catch(err => {
  383. this.isShowLoading = false
  384. this.$message.error(err.errMsg)
  385. })
  386. }
  387. },
  388. // 第一步验证邮箱
  389. firstStepValidEmail () {
  390. this.isShowLoading = true
  391. this.$http.get(`/sso/resetPwd/check/email`)
  392. .then(response => {
  393. this.isShowLoading = false
  394. if (response.data.success) {
  395. this.emailSendSuccess = true
  396. } else {
  397. this.emailSendSuccess = false
  398. return Promise.reject(response.data)
  399. }
  400. }).catch(err => {
  401. this.isShowLoading = false
  402. // console.log(err)
  403. this.$message.error(err.errMsg)
  404. })
  405. }
  406. }
  407. }
  408. </script>
  409. <style lang="scss" scoped>
  410. .validation {
  411. margin: 0 auto;
  412. width: 100%;
  413. background: #eee;
  414. .container{
  415. padding-top: 50px;
  416. margin: 0 auto;
  417. width: 980px;
  418. text-align: center;
  419. .content{
  420. padding: 0 50px;
  421. margin: 50px auto 0;
  422. width: 100%;
  423. /*height: 540px;*/
  424. text-align: center;
  425. background: #fff;
  426. .content-top{
  427. height: 80px;
  428. line-height: 80px;
  429. h3{
  430. margin-bottom: 0;
  431. font-size: 24px;
  432. color: #000;
  433. border-bottom: 1px solid #dcdcdc;
  434. }
  435. .step{
  436. position: relative;
  437. margin-top: 10px;
  438. img{
  439. width: 315px;
  440. height: 46px;
  441. }
  442. .step-item{
  443. position: absolute;
  444. top: 45px;
  445. left: 265px;
  446. span{
  447. margin-right: 85px;
  448. font-size: 14px;
  449. color: #b4b4b4;
  450. }
  451. span.active {
  452. color: #0076ad;
  453. }
  454. }
  455. }
  456. }
  457. form {
  458. margin-top: 150px;
  459. padding-bottom: 44px;
  460. input{
  461. padding: 0 0 0 18px;
  462. width: 360px;
  463. height: 44px;
  464. line-height: 44px;
  465. font-size: 14px;
  466. color: #000;
  467. border-radius: 0;
  468. }
  469. input.answer {
  470. background: url("/images/all/more.png") no-repeat 325px center;
  471. cursor: pointer;
  472. }
  473. ul{
  474. display: none;
  475. position: absolute;
  476. top: 44px;
  477. left: 0;
  478. width: 360px;
  479. background: #fff;
  480. box-shadow: 0 0 5px rgba(0,0,0,.5);
  481. -moz-box-shadow: 0 0 5px rgba(0,0,0,.5);
  482. -o-box-shadow: 0 0 5px rgba(0,0,0,.5);
  483. -webkit-box-shadow: 0 0 5px rgba(0,0,0,.5);
  484. z-index: 10;
  485. li{
  486. padding-left: 18px;
  487. width: 100%;
  488. height: 30px;
  489. line-height: 30px;
  490. text-align: left;
  491. font-size: 14px;
  492. color: #000;
  493. cursor: pointer;
  494. &:hover{
  495. background: #0076ad;
  496. color: #fff;
  497. }
  498. }
  499. }
  500. span.tip{
  501. position: absolute;
  502. top: 0;
  503. right: -238px;
  504. font-size: 13px;
  505. color: #8c8c8c;
  506. a{
  507. font-size: 13px;
  508. color: #0076ad;
  509. }
  510. }
  511. span.tip.codeError-tip{
  512. position: absolute;
  513. top: 3px;
  514. left: 378px;
  515. width: 200px;
  516. text-align: left;
  517. color: #ff4949;
  518. font-size: 12px;
  519. }
  520. i{
  521. position: absolute;
  522. top: 13px;
  523. left: 20px;
  524. font-size: 20px;
  525. color: #a0a0a0;
  526. }
  527. .btn {
  528. margin: 34px 0 16px 0;
  529. width: 360px;
  530. height: 44px;
  531. line-height: 44px;
  532. font-size: 16px;
  533. color: #fff;
  534. background: #0076AD;
  535. border-radius: 3px;
  536. }
  537. }
  538. .content-bottom{
  539. margin: 155px auto 0;
  540. padding-bottom: 50px;
  541. width: 360px;
  542. div.warp{
  543. padding-bottom: 65px;
  544. }
  545. p{
  546. font-size: 24px;
  547. color: #323232;
  548. img{
  549. margin-right: 20px;
  550. width: 30px;
  551. height: 28px;
  552. }
  553. }
  554. p.pass{
  555. font-size: 24px;
  556. color: #e77405;
  557. img{
  558. height: 30px;
  559. }
  560. }
  561. p.passed {
  562. color: #2ab300;
  563. img{
  564. height: 30px;
  565. }
  566. }
  567. span{
  568. display: inline-block;
  569. font-size: 14px;
  570. color: #8b8b8b;
  571. }
  572. span.close-tip{
  573. margin: 15px 0 140px 0;
  574. }
  575. .close-btn{
  576. margin: 0 auto;
  577. width: 200px;
  578. height: 36px;
  579. line-height: 36px;
  580. font-size: 14px;
  581. text-align: center;
  582. color: #323232;
  583. border: 1px solid #d2d2d2;
  584. border-radius: 3px;
  585. cursor: pointer ;
  586. }
  587. span.use{
  588. display: inline-block;
  589. margin-bottom: 30px;
  590. width: 360px;
  591. font-size: 14px;
  592. color: #000;
  593. text-align: left;
  594. em{
  595. font-size: 14px;
  596. font-style: normal;
  597. color: #000;
  598. }
  599. }
  600. .form-group {
  601. margin: 0 auto 16px;
  602. position: relative;
  603. width: 360px;
  604. height: 44px;
  605. line-height: 44px;
  606. input{
  607. padding: 0 0 0 18px;
  608. width: 360px;
  609. height: 44px;
  610. line-height: 44px;
  611. font-size: 14px;
  612. color: #000;
  613. border-radius: 0;
  614. }
  615. input.msg{
  616. float: left;
  617. width: 210px;
  618. padding: 0 0 0 18px;
  619. height: 44px;
  620. line-height: 44px;
  621. font-size: 14px;
  622. color: #000;
  623. border-radius: 0;
  624. }
  625. span.msg{
  626. float: right;
  627. margin: 0;
  628. width: 130px;
  629. height: 44px;
  630. line-height: 44px;
  631. text-align: center ;
  632. font-size: 14px;
  633. color: #5a5a5a;
  634. background: #f4f4f4;
  635. border: 1px solid #dcdcdc;
  636. cursor: pointer;
  637. }
  638. span.msg.send{
  639. background: #d2d2d2;
  640. color: #fff;
  641. }
  642. }
  643. .btn {
  644. margin: 34px 0 10px 0;
  645. width: 360px;
  646. height: 44px;
  647. line-height: 44px;
  648. font-size: 16px;
  649. color: #fff;
  650. background: #0076AD;
  651. border-radius: 3px;
  652. }
  653. }
  654. .choose{
  655. margin: 155px auto 0;
  656. padding-bottom: 44px;
  657. div{
  658. padding: 0 15px;
  659. margin: 0 auto 16px;
  660. width: 360px;
  661. height: 60px;
  662. line-height: 60px;
  663. text-align: left;
  664. overflow: hidden;
  665. border: 1px solid #d2d2d2;
  666. cursor: pointer;
  667. &:hover,&.active{
  668. border-color: #0076ad;
  669. span{
  670. color: #0076ad;
  671. }
  672. i.second {
  673. color: #0076ad;
  674. }
  675. }
  676. img.first{
  677. float: left;
  678. margin: 24px 20px 0 0;
  679. font-size: 20px;
  680. color: #323232;
  681. }
  682. img.first.mob{
  683. margin: 22px 20px 0 5px;
  684. font-size: 28px;
  685. }
  686. i.second {
  687. float: right;
  688. margin: 20px 0 0 5px;
  689. font-size: 20px;
  690. color: #323232;
  691. }
  692. span{
  693. float: left;
  694. font-size: 14px;
  695. color: #323232;
  696. }
  697. }
  698. }
  699. a.return{
  700. position: absolute;
  701. left: 0;
  702. top: -15px;
  703. img{
  704. width: 34px !important;
  705. height: 34px !important;
  706. }
  707. }
  708. }
  709. }
  710. }
  711. </style>