ChangeManagerSecondStep.vue 19 KB

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