ForgetPasswordChooseStyle.vue 19 KB

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