ForgetPasswordChooseStyle.vue 19 KB

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