ChangeManagerSecondStep.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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/step02.png" alt=""/>
  9. <div class="step-item"><span class="active">身份验证</span><span class="active">输入新管理员信息</span><span>更换完成</span></div>
  10. </div>
  11. </div>
  12. <div class="content-bottom">
  13. <div>
  14. <el-form :model="valid2" :rules="rules2" ref="valid2" label-width="100px" class="demo-ruleForm">
  15. <el-form-item prop="mobile">
  16. <el-input v-model="valid2.mobile" placeholder="新管理员手机号"></el-input>
  17. </el-form-item>
  18. <el-form-item prop="code">
  19. <el-input type="text" v-model="valid2.code"
  20. v-bind:class="{ active: this.secondStepCodeErrorChecked }"
  21. auto-complete="off"
  22. class="msg"
  23. placeholder="短信验证码"></el-input>
  24. <el-button type="primary" class="code"
  25. v-show="showSecondStepCode"
  26. @click="getSecondCheckCode"
  27. :disabled="getCodeBtnIsDisabled">获取验证码</el-button>
  28. <el-button type="primary" v-show="!showSecondStepCode" class="code code-send">已发送({{second_step_time}}s)</el-button>
  29. <span v-show="secondStepCodeErrorChecked" class="tip codeError-tip">{{secondCodeErrorMsg}}</span>
  30. </el-form-item>
  31. <el-form-item prop="changeReason">
  32. <el-input type="textarea" v-model="valid2.changeReason" placeholder="申诉说明"></el-input>
  33. <span class="tip description" v-show="descriptionTip">请描述您申诉的原因,并尽可能多地列举出证明此企业账号为您所有的证据</span>
  34. </el-form-item>
  35. <el-form-item prop="contactTel">
  36. <el-input type="text" v-model="valid2.contactTel" auto-complete="off" placeholder="联系电话"></el-input>
  37. </el-form-item>
  38. <el-form-item>
  39. <a class="btn finish"
  40. :disabled="!mobileSecondChecked || !secondCodeChecked || !changeReasonChecked || !contactTelChecked"
  41. @click="setNewMobile">确认</a>
  42. </el-form-item>
  43. </el-form>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. export default {
  52. name: 'validation',
  53. data () {
  54. // 第二步验证手机
  55. var validateSecondMobile = (rule, value, callback) => {
  56. if (value === '') {
  57. callback(new Error('请填写正确的手机号'))
  58. this.getCodeBtnIsDisabled = true
  59. this.mobileSecondChecked = false
  60. } else {
  61. if (this.valid2.mobile !== '') {
  62. var reg = /^1[0-9]{10}$/
  63. if (!reg.test(value)) {
  64. callback(new Error('请填写正确的手机号'))
  65. this.getCodeBtnIsDisabled = true
  66. this.mobileSecondChecked = false
  67. } else {
  68. this.getCodeBtnIsDisabled = false
  69. this.mobileSecondChecked = true
  70. }
  71. }
  72. callback()
  73. }
  74. }
  75. var validateSecondCode = (rule, value, callback) => {
  76. if (value === '') {
  77. callback(new Error('请填写正确的验证码'))
  78. this.secondStepCodeErrorChecked = false
  79. this.secondCodeChecked = false
  80. } else {
  81. if (this.valid2.code !== '') {
  82. if (this.secondToken !== '') {
  83. if (this.valid2.code !== '' && this.valid2.mobile !== '') {
  84. let param = new FormData()
  85. param.append('mobile', this.valid2.mobile)
  86. param.append('code', this.valid2.code)
  87. param.append('token', this.secondToken)
  88. let config = {
  89. headers: {'Content-Type': 'multipart/form-data'}
  90. }
  91. this.$http.post(`/sso/change/admin/check/newMobile`, param, config)
  92. .then(response => {
  93. if (response.data.success) {
  94. this.secondCodeChecked = true
  95. this.secondStepCodeErrorChecked = false
  96. } else {
  97. this.secondStepCodeErrorChecked = true
  98. this.secondCodeChecked = false
  99. return Promise.reject(response.data)
  100. }
  101. }).catch(err => {
  102. this.secondCodeErrorMsg = err.errMsg
  103. })
  104. }
  105. } else {}
  106. }
  107. callback()
  108. }
  109. }
  110. var validateSecondChangeReason = (rule, value, callback) => {
  111. if (value === '') {
  112. callback(new Error('请填写申诉说明'))
  113. this.changeReasonChecked = false
  114. this.descriptionTip = false
  115. } else {
  116. if (this.valid2.changeReason !== '') {
  117. if (value.length >= 100) {
  118. callback(new Error('输入长度过长,100个字符以内'))
  119. this.changeReasonChecked = false
  120. this.descriptionTip = false
  121. } else {
  122. this.changeReasonChecked = true
  123. this.descriptionTip = false
  124. }
  125. }
  126. callback()
  127. }
  128. }
  129. var validateSecondContactTel = (rule, value, callback) => {
  130. if (value === '') {
  131. callback(new Error('请填写正确的联系电话'))
  132. this.contactTelChecked = false
  133. } else {
  134. if (this.valid2.contactTel !== '') {
  135. var reg = /^1[0-9]{10}$/
  136. if (!reg.test(value)) {
  137. callback(new Error('请填写正确的联系电话'))
  138. this.contactTelChecked = false
  139. } else {
  140. this.contactTelChecked = true
  141. }
  142. }
  143. callback()
  144. }
  145. }
  146. return {
  147. second_step_time: 0,
  148. codeErrorChecked: false,
  149. secondStepCodeErrorChecked: false,
  150. secondCodeChecked: false,
  151. changeReasonChecked: false,
  152. contactTelChecked: false,
  153. descriptionTip: true,
  154. secondCodeErrorMsg: '',
  155. mobileSecondChecked: false,
  156. getCodeBtnIsDisabled: true,
  157. showSecondStepCode: true,
  158. valid2: {
  159. mobile: '',
  160. code: '',
  161. changeReason: '',
  162. contactTel: ''
  163. },
  164. rules2: {
  165. mobile: [
  166. {validator: validateSecondMobile, trigger: 'blur'}
  167. ],
  168. code: [
  169. {validator: validateSecondCode, trigger: 'blur'}
  170. ],
  171. changeReason: [
  172. {validator: validateSecondChangeReason, trigger: 'blur'}
  173. ],
  174. contactTel: [
  175. {validator: validateSecondContactTel, trigger: 'blur'}
  176. ]
  177. }
  178. }
  179. },
  180. computed: {
  181. firstStepToken () {
  182. return this.$store.state.login.token.data
  183. }
  184. },
  185. mounted () {
  186. // 获取邮箱token
  187. this.$nextTick(() => {
  188. this.getEmailLinkToken()
  189. })
  190. },
  191. methods: {
  192. // 获取第二步手机验证码
  193. getSecondCheckCode () {
  194. this.$http.get(`/sso/change/admin/check/newMobile`, {params: {mobile: this.valid2.mobile, token: this.firstStepToken}})
  195. .then(response => {
  196. this.secondToken = response.data.content.token
  197. if (this.secondToken !== '') {
  198. this.$message({
  199. message: '验证码已经发送到您的手机,请注意查收',
  200. type: 'success'
  201. })
  202. this.showSecondStepCode = false
  203. this.second_step_time = 60
  204. var secondStepTime = setInterval(() => {
  205. this.second_step_time--
  206. if (this.second_step_time <= 0) {
  207. this.showSecondStepCode = true
  208. clearInterval(secondStepTime)
  209. }
  210. }, 1000)
  211. }
  212. }).catch(err => {
  213. console.log(err)
  214. })
  215. },
  216. // 更换管理员确认
  217. setNewMobile () {
  218. if (this.mobileSecondChecked && this.secondCodeChecked && this.changeReasonChecked && this.contactTelChecked) {
  219. let param = new FormData()
  220. param.append('mobile', this.valid2.mobile)
  221. param.append('code', this.valid2.code)
  222. param.append('token', this.firstStepToken)
  223. param.append('codeToken', this.secondToken)
  224. param.append('changeReason', this.valid2.changeReason)
  225. param.append('contactTel', this.valid2.contactTel)
  226. let config = {
  227. headers: {'Content-Type': 'multipart/form-data'}
  228. }
  229. this.$http.post(`/sso/change/admin`, param, config)
  230. .then(response => {
  231. if (response.data.success) {
  232. this.$router.push({ path: '/change/changeManagerThirdStep' })
  233. } else {
  234. return Promise.reject(response.data)
  235. }
  236. }).catch(err => {
  237. console.log(err)
  238. })
  239. }
  240. },
  241. // 获得邮箱token
  242. getEmailLinkToken () {
  243. var url = window.location.search
  244. var request = {}
  245. if (url.indexOf('?' !== -1)) {
  246. var str = url.substr(1)
  247. var strs = str.split('&')
  248. for (var i = 0; i < strs.length; i++) {
  249. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  250. }
  251. }
  252. this.Token = request['token'] || ''
  253. if (this.Token) {
  254. this.$store.commit('login/GET_TOKEN', this.Token)
  255. }
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="scss" scoped>
  261. .validation {
  262. margin: 0 auto;
  263. width: 100%;
  264. background: #eee;
  265. .container{
  266. padding-top: 50px;
  267. margin: 0 auto;
  268. width: 980px;
  269. text-align: center;
  270. .content{
  271. padding: 0 50px;
  272. margin: 50px auto 0;
  273. width: 100%;
  274. /*height: 540px;*/
  275. text-align: center;
  276. background: #fff;
  277. .content-top{
  278. height: 80px;
  279. line-height: 80px;
  280. h3{
  281. margin-bottom: 0;
  282. font-size: 24px;
  283. color: #000;
  284. border-bottom: 1px solid #dcdcdc;
  285. }
  286. .step{
  287. position: relative;
  288. margin-top: 10px;
  289. img{
  290. width: 315px;
  291. height: 46px;
  292. }
  293. .step-item{
  294. position: absolute;
  295. top: 45px;
  296. left: 265px;
  297. span{
  298. margin-right: 57px;
  299. font-size: 14px;
  300. color: #b4b4b4;
  301. }
  302. span.active {
  303. color: #0076ad;
  304. }
  305. }
  306. }
  307. }
  308. form {
  309. margin-top: 150px;
  310. padding-bottom: 44px;
  311. input{
  312. padding: 0 0 0 18px;
  313. width: 360px;
  314. height: 44px;
  315. line-height: 44px;
  316. font-size: 14px;
  317. color: #000;
  318. border-radius: 0;
  319. }
  320. input.answer {
  321. background: url("/images/all/more.png") no-repeat 325px center;
  322. cursor: pointer;
  323. }
  324. ul{
  325. display: none;
  326. position: absolute;
  327. top: 44px;
  328. left: 0;
  329. width: 360px;
  330. background: #fff;
  331. box-shadow: 0 0 5px rgba(0,0,0,.5);
  332. -moz-box-shadow: 0 0 5px rgba(0,0,0,.5);
  333. -o-box-shadow: 0 0 5px rgba(0,0,0,.5);
  334. -webkit-box-shadow: 0 0 5px rgba(0,0,0,.5);
  335. z-index: 10;
  336. li{
  337. padding-left: 18px;
  338. width: 100%;
  339. height: 30px;
  340. line-height: 30px;
  341. text-align: left;
  342. font-size: 14px;
  343. color: #000;
  344. cursor: pointer;
  345. &:hover{
  346. background: #0076ad;
  347. color: #fff;
  348. }
  349. }
  350. }
  351. span.tip{
  352. position: absolute;
  353. top: 10px;
  354. right: -243px;
  355. width: 223px;
  356. line-height: 18px;
  357. text-align: left;
  358. font-size: 13px;
  359. color: #8c8c8c;
  360. a{
  361. font-size: 13px;
  362. color: #0076ad;
  363. }
  364. }
  365. span.tip.codeError-tip{
  366. position: absolute;
  367. top: 3px;
  368. left: 378px;
  369. width: 200px;
  370. text-align: left;
  371. color: #ff4949;
  372. font-size: 12px;
  373. }
  374. i{
  375. position: absolute;
  376. top: 13px;
  377. left: 20px;
  378. font-size: 20px;
  379. color: #a0a0a0;
  380. }
  381. .btn {
  382. margin: 34px 0 16px 0;
  383. width: 360px;
  384. height: 44px;
  385. line-height: 44px;
  386. font-size: 16px;
  387. color: #fff;
  388. background: #0076AD;
  389. border-radius: 3px;
  390. }
  391. }
  392. .content-bottom{
  393. margin: 155px auto 0;
  394. padding-bottom: 50px;
  395. width: 360px;
  396. div.warp{
  397. padding-bottom: 65px;
  398. }
  399. p{
  400. font-size: 24px;
  401. color: #323232;
  402. img{
  403. margin-right: 20px;
  404. width: 30px;
  405. height: 28px;
  406. }
  407. }
  408. p.pass{
  409. font-size: 24px;
  410. color: #e77405;
  411. img{
  412. height: 30px;
  413. }
  414. }
  415. p.passed {
  416. color: #2ab300;
  417. img{
  418. height: 30px;
  419. }
  420. }
  421. span{
  422. display: inline-block;
  423. font-size: 14px;
  424. color: #8b8b8b;
  425. }
  426. span.close-tip{
  427. margin: 15px 0 140px 0;
  428. }
  429. .close-btn{
  430. margin: 0 auto;
  431. width: 200px;
  432. height: 36px;
  433. line-height: 36px;
  434. font-size: 14px;
  435. text-align: center;
  436. color: #323232;
  437. border: 1px solid #d2d2d2;
  438. border-radius: 3px;
  439. cursor: pointer ;
  440. }
  441. span.use{
  442. display: inline-block;
  443. margin-bottom: 30px;
  444. width: 360px;
  445. font-size: 14px;
  446. color: #000;
  447. text-align: left;
  448. em{
  449. font-size: 14px;
  450. font-style: normal;
  451. color: #000;
  452. }
  453. }
  454. .form-group {
  455. margin: 0 auto 16px;
  456. position: relative;
  457. width: 360px;
  458. height: 44px;
  459. line-height: 44px;
  460. input{
  461. padding: 0 0 0 18px;
  462. width: 360px;
  463. height: 44px;
  464. line-height: 44px;
  465. font-size: 14px;
  466. color: #000;
  467. border-radius: 0;
  468. }
  469. input.msg{
  470. float: left;
  471. width: 210px;
  472. padding: 0 0 0 18px;
  473. height: 44px;
  474. line-height: 44px;
  475. font-size: 14px;
  476. color: #000;
  477. border-radius: 0;
  478. }
  479. span.msg{
  480. float: right;
  481. margin: 0;
  482. width: 130px;
  483. height: 44px;
  484. line-height: 44px;
  485. text-align: center ;
  486. font-size: 14px;
  487. color: #5a5a5a;
  488. background: #f4f4f4;
  489. border: 1px solid #dcdcdc;
  490. cursor: pointer;
  491. }
  492. span.msg.send{
  493. background: #d2d2d2;
  494. color: #fff;
  495. }
  496. }
  497. .btn {
  498. margin: 34px 0 10px 0;
  499. width: 360px;
  500. height: 44px;
  501. line-height: 44px;
  502. font-size: 16px;
  503. color: #fff;
  504. background: #0076AD;
  505. border-radius: 3px;
  506. }
  507. }
  508. .choose{
  509. margin: 155px auto 0;
  510. padding-bottom: 44px;
  511. div{
  512. padding: 0 15px;
  513. margin: 0 auto 16px;
  514. width: 360px;
  515. height: 60px;
  516. line-height: 60px;
  517. text-align: left;
  518. overflow: hidden;
  519. border: 1px solid #d2d2d2;
  520. cursor: pointer;
  521. &:hover,&.active{
  522. border-color: #0076ad;
  523. span{
  524. color: #0076ad;
  525. }
  526. i.second {
  527. color: #0076ad;
  528. }
  529. }
  530. img.first{
  531. float: left;
  532. margin: 24px 20px 0 0;
  533. font-size: 20px;
  534. color: #323232;
  535. }
  536. img.first.mob{
  537. margin: 22px 20px 0 5px;
  538. font-size: 28px;
  539. }
  540. i.second {
  541. float: right;
  542. margin: 20px 0 0 5px;
  543. font-size: 20px;
  544. color: #323232;
  545. }
  546. span{
  547. float: left;
  548. font-size: 14px;
  549. color: #323232;
  550. }
  551. }
  552. }
  553. a.return{
  554. position: absolute;
  555. left: 0;
  556. top: -15px;
  557. img{
  558. width: 34px !important;
  559. height: 34px !important;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. </style>