EncryptedMobile.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <div class="validation">
  3. <div class="container">
  4. <div class="content">
  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. <a @click="chooseWay('select')" class="return"><img src="/images/all/return.png" alt=""/></a>
  11. </div>
  12. </div>
  13. <div class="content-bottom">
  14. <span class="use">使用手机号<em>{{info | hide}}</em>接收验证码</span>
  15. <div>
  16. <el-form :model="valid" :rules="rules" ref="valid" label-width="100px" class="demo-ruleForm" style="margin-top: 0;">
  17. <el-form-item prop="code">
  18. <el-input type="text" v-model="valid.code"
  19. v-bind:class="{ active: codeErrorChecked }"
  20. auto-complete="off" class="msg"
  21. placeholder="短信验证码"></el-input>
  22. <el-button type="primary" class="code"
  23. v-show="sendAccountCode"
  24. @click="getCheckCode">获取验证码</el-button>
  25. <el-button type="primary" v-show="!sendAccountCode" class="code code-send">已发送({{account_time}}s)</el-button>
  26. <span v-show="codeErrorChecked" class="tip codeError-tip" >{{codeErrorMsg}}</span>
  27. </el-form-item>
  28. <el-form-item>
  29. <a class="btn finish"
  30. :disabled="!codeChecked"
  31. @click="goNextStep">下一步</a>
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. </div>
  36. </div>
  37. <loading v-show="isShowLoading"/>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import Loading from '~components/common/loading/Loading.vue'
  43. export default {
  44. name: 'validation',
  45. components: {
  46. Loading
  47. },
  48. props: ['info'],
  49. data () {
  50. // 第一步校验验证码
  51. var validateFirstCode = (rule, value, callback) => {
  52. if (value === '') {
  53. callback(new Error('请填写正确的验证码'))
  54. this.codeErrorChecked = false
  55. this.codeChecked = false
  56. } else {
  57. if (this.valid.code !== '') {
  58. if (this.token) {
  59. if (this.valid.code !== '' && this.info !== '') {
  60. let param = new FormData()
  61. param.append('mobile', this.info)
  62. param.append('code', this.valid.code)
  63. param.append('token', this.token)
  64. let config = {
  65. headers: {'Content-Type': 'multipart/form-data'}
  66. }
  67. this.$http.post(`/update/user/checkCode/mobile`, param, config)
  68. .then(response => {
  69. if (response.data.success) {
  70. this.codeChecked = true
  71. this.codeErrorChecked = false
  72. } else {
  73. this.codeErrorChecked = true
  74. this.codeChecked = false
  75. return Promise.reject(response.data)
  76. }
  77. }).catch(err => {
  78. this.codeErrorMsg = err.errMsg
  79. })
  80. }
  81. } else {
  82. callback(new Error('请先获取验证码'))
  83. this.codeChecked = false
  84. this.codeErrorChecked = false
  85. }
  86. }
  87. callback()
  88. }
  89. }
  90. return {
  91. isShowLoading: false,
  92. sendAccountCode: true,
  93. account_time: 0,
  94. codeErrorChecked: false,
  95. codeChecked: false,
  96. codeErrorMsg: '',
  97. token: '',
  98. valid: {
  99. code: ''
  100. },
  101. rules: {
  102. code: [
  103. {validator: validateFirstCode, trigger: 'blur'}
  104. ]
  105. }
  106. }
  107. },
  108. filters: {
  109. hide: function (value) {
  110. let reg = /^(\d{3})\d{6}(\d{2})$/
  111. return value.replace(reg, '$1******$2')
  112. }
  113. },
  114. methods: {
  115. // 选择方式
  116. chooseWay (type) {
  117. this.$emit('stepEvent', type)
  118. },
  119. // 获取第一步手机验证码
  120. getCheckCode () {
  121. this.isShowLoading = true
  122. this.$http.get(`/update/user/check/mobile`, {params: {mobile: this.info}})
  123. .then(response => {
  124. this.isShowLoading = false
  125. if (response.data.success) {
  126. this.token = response.data.content.token
  127. if (this.token !== '') {
  128. this.$message({
  129. message: '验证码已经发送到您的手机,请注意查收',
  130. type: 'success'
  131. })
  132. this.sendAccountCode = false
  133. this.account_time = 60
  134. var accountTime = setInterval(() => {
  135. this.account_time--
  136. if (this.account_time <= 0) {
  137. this.sendAccountCode = true
  138. clearInterval(accountTime)
  139. }
  140. }, 1000)
  141. }
  142. } else {
  143. return Promise.reject(response.data)
  144. }
  145. }).catch(err => {
  146. this.isShowLoading = false
  147. this.$message.error(err.errMsg)
  148. })
  149. },
  150. // 手机号验证下一步
  151. goNextStep () {
  152. if (this.codeChecked) {
  153. this.isShowLoading = true
  154. let param = new FormData()
  155. param.append('mobile', this.info)
  156. param.append('code', this.valid.code)
  157. param.append('token', this.token)
  158. let config = {
  159. headers: {'Content-Type': 'multipart/form-data'}
  160. }
  161. this.$http.post(`/update/user/check/mobile`, param, config)
  162. .then(response => {
  163. this.isShowLoading = false
  164. if (response.data.success) {
  165. this.$emit('stepEvent', 'new')
  166. this.$emit('tokenEvent', response.data.content)
  167. } else {
  168. return Promise.reject(response.data)
  169. }
  170. }).catch(err => {
  171. this.isShowLoading = false
  172. this.$message.error(err.errMsg)
  173. })
  174. }
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .validation {
  181. margin: 0 auto;
  182. width: 100%;
  183. background: #eee;
  184. .container{
  185. padding-top: 50px;
  186. margin: 0 auto;
  187. width: 980px;
  188. text-align: center;
  189. .content{
  190. padding: 0 50px;
  191. margin: 50px auto 0;
  192. width: 100%;
  193. /*height: 540px;*/
  194. text-align: center;
  195. background: #fff;
  196. .content-top{
  197. height: 80px;
  198. line-height: 80px;
  199. h3{
  200. margin-bottom: 0;
  201. font-size: 24px;
  202. color: #000;
  203. border-bottom: 1px solid #dcdcdc;
  204. }
  205. .step{
  206. position: relative;
  207. margin-top: 10px;
  208. img{
  209. width: 315px;
  210. height: 46px;
  211. }
  212. .step-item{
  213. position: absolute;
  214. top: 45px;
  215. left: 265px;
  216. span{
  217. margin-right: 78px;
  218. font-size: 14px;
  219. color: #b4b4b4;
  220. }
  221. span.active {
  222. color: #0076ad;
  223. }
  224. }
  225. }
  226. }
  227. form {
  228. margin-top: 150px;
  229. padding-bottom: 44px;
  230. input{
  231. padding: 0 0 0 18px;
  232. width: 360px;
  233. height: 44px;
  234. line-height: 44px;
  235. font-size: 14px;
  236. color: #000;
  237. border-radius: 0;
  238. }
  239. input.answer {
  240. background: url("/images/all/more.png") no-repeat 325px center;
  241. cursor: pointer;
  242. }
  243. ul{
  244. display: none;
  245. position: absolute;
  246. top: 44px;
  247. left: 0;
  248. width: 360px;
  249. background: #fff;
  250. box-shadow: 0 0 5px rgba(0,0,0,.5);
  251. -moz-box-shadow: 0 0 5px rgba(0,0,0,.5);
  252. -o-box-shadow: 0 0 5px rgba(0,0,0,.5);
  253. -webkit-box-shadow: 0 0 5px rgba(0,0,0,.5);
  254. z-index: 10;
  255. li{
  256. padding-left: 18px;
  257. width: 100%;
  258. height: 30px;
  259. line-height: 30px;
  260. text-align: left;
  261. font-size: 14px;
  262. color: #000;
  263. cursor: pointer;
  264. &:hover{
  265. background: #0076ad;
  266. color: #fff;
  267. }
  268. }
  269. }
  270. span.tip{
  271. position: absolute;
  272. top: 0;
  273. right: -238px;
  274. font-size: 13px;
  275. color: #8c8c8c;
  276. a{
  277. font-size: 13px;
  278. color: #0076ad;
  279. }
  280. }
  281. span.tip.codeError-tip{
  282. position: absolute;
  283. top: 3px;
  284. left: 378px;
  285. width: 200px;
  286. text-align: left;
  287. color: #ff4949;
  288. font-size: 12px;
  289. }
  290. i{
  291. position: absolute;
  292. top: 13px;
  293. left: 20px;
  294. font-size: 20px;
  295. color: #a0a0a0;
  296. }
  297. .btn {
  298. margin: 34px 0 16px 0;
  299. width: 360px;
  300. height: 44px;
  301. line-height: 44px;
  302. font-size: 16px;
  303. color: #fff;
  304. background: #0076AD;
  305. border-radius: 3px;
  306. }
  307. }
  308. .content-bottom{
  309. margin: 155px auto 0;
  310. padding-bottom: 50px;
  311. width: 360px;
  312. div.warp{
  313. padding-bottom: 65px;
  314. }
  315. p{
  316. font-size: 24px;
  317. color: #323232;
  318. img{
  319. margin-right: 20px;
  320. width: 30px;
  321. height: 28px;
  322. }
  323. }
  324. p.pass{
  325. font-size: 24px;
  326. color: #e77405;
  327. img{
  328. height: 30px;
  329. }
  330. }
  331. p.passed {
  332. color: #2ab300;
  333. img{
  334. height: 30px;
  335. }
  336. }
  337. span{
  338. display: inline-block;
  339. font-size: 14px;
  340. color: #8b8b8b;
  341. }
  342. span.close-tip{
  343. margin: 15px 0 140px 0;
  344. }
  345. .close-btn{
  346. margin: 0 auto;
  347. width: 200px;
  348. height: 36px;
  349. line-height: 36px;
  350. font-size: 14px;
  351. text-align: center;
  352. color: #323232;
  353. border: 1px solid #d2d2d2;
  354. border-radius: 3px;
  355. cursor: pointer ;
  356. }
  357. span.use{
  358. display: inline-block;
  359. margin-bottom: 30px;
  360. width: 360px;
  361. font-size: 14px;
  362. color: #000;
  363. text-align: left;
  364. em{
  365. font-size: 14px;
  366. font-style: normal;
  367. color: #000;
  368. }
  369. }
  370. .form-group {
  371. margin: 0 auto 16px;
  372. position: relative;
  373. width: 360px;
  374. height: 44px;
  375. line-height: 44px;
  376. input{
  377. padding: 0 0 0 18px;
  378. width: 360px;
  379. height: 44px;
  380. line-height: 44px;
  381. font-size: 14px;
  382. color: #000;
  383. border-radius: 0;
  384. }
  385. input.msg{
  386. float: left;
  387. width: 210px;
  388. padding: 0 0 0 18px;
  389. height: 44px;
  390. line-height: 44px;
  391. font-size: 14px;
  392. color: #000;
  393. border-radius: 0;
  394. }
  395. span.msg{
  396. float: right;
  397. margin: 0;
  398. width: 130px;
  399. height: 44px;
  400. line-height: 44px;
  401. text-align: center ;
  402. font-size: 14px;
  403. color: #5a5a5a;
  404. background: #f4f4f4;
  405. border: 1px solid #dcdcdc;
  406. cursor: pointer;
  407. }
  408. span.msg.send{
  409. background: #d2d2d2;
  410. color: #fff;
  411. }
  412. }
  413. .btn {
  414. margin: 34px 0 10px 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. .choose{
  425. margin: 155px auto 0;
  426. padding-bottom: 44px;
  427. div{
  428. padding: 0 15px;
  429. margin: 0 auto 16px;
  430. width: 360px;
  431. height: 60px;
  432. line-height: 60px;
  433. text-align: left;
  434. overflow: hidden;
  435. border: 1px solid #d2d2d2;
  436. cursor: pointer;
  437. &:hover,&.active{
  438. border-color: #0076ad;
  439. span{
  440. color: #0076ad;
  441. }
  442. i.second {
  443. color: #0076ad;
  444. }
  445. }
  446. img.first{
  447. float: left;
  448. margin: 24px 20px 0 0;
  449. font-size: 20px;
  450. color: #323232;
  451. }
  452. img.first.mob{
  453. margin: 22px 20px 0 5px;
  454. font-size: 28px;
  455. }
  456. i.second {
  457. float: right;
  458. margin: 20px 0 0 5px;
  459. font-size: 20px;
  460. color: #323232;
  461. }
  462. span{
  463. float: left;
  464. font-size: 14px;
  465. color: #323232;
  466. }
  467. }
  468. }
  469. a.return{
  470. position: absolute;
  471. left: 0;
  472. top: -15px;
  473. img{
  474. width: 34px !important;
  475. height: 34px !important;
  476. }
  477. }
  478. }
  479. }
  480. }
  481. </style>