ForgetPasswordChooseStyle.vue 19 KB

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