ChangeManagerSecondStep.vue 19 KB

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