ChangePasswordChooseStyle.vue 22 KB

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