PhoneValidation.vue 20 KB

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