ChangePasswordChooseStyle.vue 23 KB

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