ChangePasswordChooseStyle.vue 23 KB

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