ChangeStepMobile.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(`/sso/change/admin/check/newMobile`, 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(`/sso/change/admin/check/mobile`)
  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('code', this.valid.code)
  156. param.append('token', this.token)
  157. let config = {
  158. headers: {'Content-Type': 'multipart/form-data'}
  159. }
  160. this.$http.post(`/sso/change/admin/check/mobile`, param, config)
  161. .then(response => {
  162. this.isShowLoading = false
  163. if (response.data.success) {
  164. this.$emit('stepEvent', 'new')
  165. this.$emit('tokenEvent', response.data.content.token)
  166. } else {
  167. return Promise.reject(response.data)
  168. }
  169. }).catch(err => {
  170. this.isShowLoading = false
  171. this.$message.error(err.errMsg)
  172. })
  173. }
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. .validation {
  180. margin: 0 auto;
  181. width: 100%;
  182. background: #eee;
  183. .container{
  184. padding-top: 50px;
  185. margin: 0 auto;
  186. width: 980px;
  187. text-align: center;
  188. .content{
  189. padding: 0 50px;
  190. margin: 50px auto 0;
  191. width: 100%;
  192. /*height: 540px;*/
  193. text-align: center;
  194. background: #fff;
  195. .content-top{
  196. height: 80px;
  197. line-height: 80px;
  198. h3{
  199. margin-bottom: 0;
  200. font-size: 24px;
  201. color: #000;
  202. border-bottom: 1px solid #dcdcdc;
  203. }
  204. .step{
  205. position: relative;
  206. margin-top: 10px;
  207. img{
  208. width: 315px;
  209. height: 46px;
  210. }
  211. .step-item{
  212. position: absolute;
  213. top: 45px;
  214. left: 265px;
  215. span{
  216. margin-right: 57px;
  217. font-size: 14px;
  218. color: #b4b4b4;
  219. }
  220. span.active {
  221. color: #0076ad;
  222. }
  223. }
  224. }
  225. }
  226. form {
  227. margin-top: 150px;
  228. padding-bottom: 44px;
  229. input{
  230. padding: 0 0 0 18px;
  231. width: 360px;
  232. height: 44px;
  233. line-height: 44px;
  234. font-size: 14px;
  235. color: #000;
  236. border-radius: 0;
  237. }
  238. input.answer {
  239. background: url("/images/all/more.png") no-repeat 325px center;
  240. cursor: pointer;
  241. }
  242. ul{
  243. display: none;
  244. position: absolute;
  245. top: 44px;
  246. left: 0;
  247. width: 360px;
  248. background: #fff;
  249. box-shadow: 0 0 5px rgba(0,0,0,.5);
  250. -moz-box-shadow: 0 0 5px rgba(0,0,0,.5);
  251. -o-box-shadow: 0 0 5px rgba(0,0,0,.5);
  252. -webkit-box-shadow: 0 0 5px rgba(0,0,0,.5);
  253. z-index: 10;
  254. li{
  255. padding-left: 18px;
  256. width: 100%;
  257. height: 30px;
  258. line-height: 30px;
  259. text-align: left;
  260. font-size: 14px;
  261. color: #000;
  262. cursor: pointer;
  263. &:hover{
  264. background: #0076ad;
  265. color: #fff;
  266. }
  267. }
  268. }
  269. span.tip{
  270. position: absolute;
  271. top: 0;
  272. right: -238px;
  273. font-size: 13px;
  274. color: #8c8c8c;
  275. a{
  276. font-size: 13px;
  277. color: #0076ad;
  278. }
  279. }
  280. span.tip.codeError-tip{
  281. position: absolute;
  282. top: 3px;
  283. left: 378px;
  284. width: 200px;
  285. text-align: left;
  286. color: #ff4949;
  287. font-size: 12px;
  288. }
  289. i{
  290. position: absolute;
  291. top: 13px;
  292. left: 20px;
  293. font-size: 20px;
  294. color: #a0a0a0;
  295. }
  296. .btn {
  297. margin: 34px 0 16px 0;
  298. width: 360px;
  299. height: 44px;
  300. line-height: 44px;
  301. font-size: 16px;
  302. color: #fff;
  303. background: #0076AD;
  304. border-radius: 3px;
  305. }
  306. }
  307. .content-bottom{
  308. margin: 155px auto 0;
  309. padding-bottom: 50px;
  310. width: 360px;
  311. div.warp{
  312. padding-bottom: 65px;
  313. }
  314. p{
  315. font-size: 24px;
  316. color: #323232;
  317. img{
  318. margin-right: 20px;
  319. width: 30px;
  320. height: 28px;
  321. }
  322. }
  323. p.pass{
  324. font-size: 24px;
  325. color: #e77405;
  326. img{
  327. height: 30px;
  328. }
  329. }
  330. p.passed {
  331. color: #2ab300;
  332. img{
  333. height: 30px;
  334. }
  335. }
  336. span{
  337. display: inline-block;
  338. font-size: 14px;
  339. color: #8b8b8b;
  340. }
  341. span.close-tip{
  342. margin: 15px 0 140px 0;
  343. }
  344. .close-btn{
  345. margin: 0 auto;
  346. width: 200px;
  347. height: 36px;
  348. line-height: 36px;
  349. font-size: 14px;
  350. text-align: center;
  351. color: #323232;
  352. border: 1px solid #d2d2d2;
  353. border-radius: 3px;
  354. cursor: pointer ;
  355. }
  356. span.use{
  357. display: inline-block;
  358. margin-bottom: 30px;
  359. width: 360px;
  360. font-size: 14px;
  361. color: #000;
  362. text-align: left;
  363. em{
  364. font-size: 14px;
  365. font-style: normal;
  366. color: #000;
  367. }
  368. }
  369. .form-group {
  370. margin: 0 auto 16px;
  371. position: relative;
  372. width: 360px;
  373. height: 44px;
  374. line-height: 44px;
  375. input{
  376. padding: 0 0 0 18px;
  377. width: 360px;
  378. height: 44px;
  379. line-height: 44px;
  380. font-size: 14px;
  381. color: #000;
  382. border-radius: 0;
  383. }
  384. input.msg{
  385. float: left;
  386. width: 210px;
  387. padding: 0 0 0 18px;
  388. height: 44px;
  389. line-height: 44px;
  390. font-size: 14px;
  391. color: #000;
  392. border-radius: 0;
  393. }
  394. span.msg{
  395. float: right;
  396. margin: 0;
  397. width: 130px;
  398. height: 44px;
  399. line-height: 44px;
  400. text-align: center ;
  401. font-size: 14px;
  402. color: #5a5a5a;
  403. background: #f4f4f4;
  404. border: 1px solid #dcdcdc;
  405. cursor: pointer;
  406. }
  407. span.msg.send{
  408. background: #d2d2d2;
  409. color: #fff;
  410. }
  411. }
  412. .btn {
  413. margin: 34px 0 10px 0;
  414. width: 360px;
  415. height: 44px;
  416. line-height: 44px;
  417. font-size: 16px;
  418. color: #fff;
  419. background: #0076AD;
  420. border-radius: 3px;
  421. }
  422. }
  423. .choose{
  424. margin: 155px auto 0;
  425. padding-bottom: 44px;
  426. div{
  427. padding: 0 15px;
  428. margin: 0 auto 16px;
  429. width: 360px;
  430. height: 60px;
  431. line-height: 60px;
  432. text-align: left;
  433. overflow: hidden;
  434. border: 1px solid #d2d2d2;
  435. cursor: pointer;
  436. &:hover,&.active{
  437. border-color: #0076ad;
  438. span{
  439. color: #0076ad;
  440. }
  441. i.second {
  442. color: #0076ad;
  443. }
  444. }
  445. img.first{
  446. float: left;
  447. margin: 24px 20px 0 0;
  448. font-size: 20px;
  449. color: #323232;
  450. }
  451. img.first.mob{
  452. margin: 22px 20px 0 5px;
  453. font-size: 28px;
  454. }
  455. i.second {
  456. float: right;
  457. margin: 20px 0 0 5px;
  458. font-size: 20px;
  459. color: #323232;
  460. }
  461. span{
  462. float: left;
  463. font-size: 14px;
  464. color: #323232;
  465. }
  466. }
  467. }
  468. a.return{
  469. position: absolute;
  470. left: 0;
  471. top: -15px;
  472. img{
  473. width: 34px !important;
  474. height: 34px !important;
  475. }
  476. }
  477. }
  478. }
  479. }
  480. </style>