ChangePasswordChooseStyle.vue 23 KB

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