ChangeManagerSecondStep.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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. if (response.data.success) {
  211. this.secondToken = response.data.content.token
  212. if (this.secondToken !== '') {
  213. this.$message({
  214. message: '验证码已经发送到您的手机,请注意查收',
  215. type: 'success'
  216. })
  217. this.showSecondStepCode = false
  218. this.second_step_time = 60
  219. var secondStepTime = setInterval(() => {
  220. this.second_step_time--
  221. if (this.second_step_time <= 0) {
  222. this.showSecondStepCode = true
  223. clearInterval(secondStepTime)
  224. }
  225. }, 1000)
  226. }
  227. } else {
  228. return Promise.reject(response.data)
  229. }
  230. }).catch(err => {
  231. this.isShowLoading = false
  232. this.$message.error(err.errMsg)
  233. })
  234. },
  235. // 更换管理员确认
  236. setNewMobile () {
  237. if (this.mobileSecondChecked && this.secondCodeChecked && this.changeReasonChecked && this.contactTelChecked) {
  238. this.isShowLoading = true
  239. let param = new FormData()
  240. param.append('mobile', this.valid2.mobile)
  241. param.append('code', this.valid2.code)
  242. param.append('token', this.firstStepToken)
  243. param.append('codeToken', this.secondToken)
  244. param.append('changeReason', this.valid2.changeReason)
  245. param.append('contactTel', this.valid2.contactTel)
  246. let config = {
  247. headers: {'Content-Type': 'multipart/form-data'}
  248. }
  249. this.$http.post(`/sso/change/admin`, param, config)
  250. .then(response => {
  251. this.isShowLoading = false
  252. if (response.data.success) {
  253. this.$router.push({ path: '/change/changeManagerThirdStep' })
  254. } else {
  255. return Promise.reject(response.data)
  256. }
  257. }).catch(err => {
  258. this.$message.error(err.errMsg)
  259. this.isShowLoading = false
  260. this.secondStepCodeErrorChecked = true
  261. this.secondCodeChecked = false
  262. this.second_step_time = 0
  263. })
  264. }
  265. },
  266. // 获得邮箱token
  267. getEmailLinkToken () {
  268. var url = window.location.search
  269. var request = {}
  270. if (url.indexOf('?' !== -1)) {
  271. var str = url.substr(1)
  272. var strs = str.split('&')
  273. for (var i = 0; i < strs.length; i++) {
  274. request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
  275. }
  276. }
  277. this.Token = request['token'] || ''
  278. if (this.Token) {
  279. this.$store.commit('login/GET_TOKEN', this.Token)
  280. }
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. .validation {
  287. margin: 0 auto;
  288. width: 100%;
  289. background: #eee;
  290. .container{
  291. padding-top: 50px;
  292. margin: 0 auto;
  293. width: 980px;
  294. text-align: center;
  295. .content{
  296. padding: 0 50px;
  297. margin: 50px auto 0;
  298. width: 100%;
  299. /*height: 540px;*/
  300. text-align: center;
  301. background: #fff;
  302. .content-top{
  303. height: 80px;
  304. line-height: 80px;
  305. h3{
  306. margin-bottom: 0;
  307. font-size: 24px;
  308. color: #000;
  309. border-bottom: 1px solid #dcdcdc;
  310. }
  311. .step{
  312. position: relative;
  313. margin-top: 10px;
  314. img{
  315. width: 315px;
  316. height: 46px;
  317. }
  318. .step-item{
  319. position: absolute;
  320. top: 45px;
  321. left: 265px;
  322. span{
  323. margin-right: 57px;
  324. font-size: 14px;
  325. color: #b4b4b4;
  326. }
  327. span.active {
  328. color: #0076ad;
  329. }
  330. }
  331. }
  332. }
  333. form {
  334. margin-top: 150px;
  335. padding-bottom: 44px;
  336. input{
  337. padding: 0 0 0 18px;
  338. width: 360px;
  339. height: 44px;
  340. line-height: 44px;
  341. font-size: 14px;
  342. color: #000;
  343. border-radius: 0;
  344. }
  345. input.answer {
  346. background: url("/images/all/more.png") no-repeat 325px center;
  347. cursor: pointer;
  348. }
  349. ul{
  350. display: none;
  351. position: absolute;
  352. top: 44px;
  353. left: 0;
  354. width: 360px;
  355. background: #fff;
  356. box-shadow: 0 0 5px rgba(0,0,0,.5);
  357. -moz-box-shadow: 0 0 5px rgba(0,0,0,.5);
  358. -o-box-shadow: 0 0 5px rgba(0,0,0,.5);
  359. -webkit-box-shadow: 0 0 5px rgba(0,0,0,.5);
  360. z-index: 10;
  361. li{
  362. padding-left: 18px;
  363. width: 100%;
  364. height: 30px;
  365. line-height: 30px;
  366. text-align: left;
  367. font-size: 14px;
  368. color: #000;
  369. cursor: pointer;
  370. &:hover{
  371. background: #0076ad;
  372. color: #fff;
  373. }
  374. }
  375. }
  376. span.tip{
  377. position: absolute;
  378. top: 10px;
  379. right: -243px;
  380. width: 223px;
  381. line-height: 18px;
  382. text-align: left;
  383. font-size: 13px;
  384. color: #8c8c8c;
  385. a{
  386. font-size: 13px;
  387. color: #0076ad;
  388. }
  389. }
  390. span.tip.codeError-tip{
  391. position: absolute;
  392. top: 3px;
  393. left: 378px;
  394. width: 200px;
  395. text-align: left;
  396. color: #ff4949;
  397. font-size: 12px;
  398. }
  399. i{
  400. position: absolute;
  401. top: 13px;
  402. left: 20px;
  403. font-size: 20px;
  404. color: #a0a0a0;
  405. }
  406. .btn {
  407. margin: 34px 0 16px 0;
  408. width: 360px;
  409. height: 44px;
  410. line-height: 44px;
  411. font-size: 16px;
  412. color: #fff;
  413. background: #0076AD;
  414. border-radius: 3px;
  415. }
  416. }
  417. .content-bottom{
  418. margin: 155px auto 0;
  419. padding-bottom: 50px;
  420. width: 360px;
  421. div.warp{
  422. padding-bottom: 65px;
  423. }
  424. p{
  425. font-size: 24px;
  426. color: #323232;
  427. img{
  428. margin-right: 20px;
  429. width: 30px;
  430. height: 28px;
  431. }
  432. }
  433. p.pass{
  434. font-size: 24px;
  435. color: #e77405;
  436. img{
  437. height: 30px;
  438. }
  439. }
  440. p.passed {
  441. color: #2ab300;
  442. img{
  443. height: 30px;
  444. }
  445. }
  446. span{
  447. display: inline-block;
  448. font-size: 14px;
  449. color: #8b8b8b;
  450. }
  451. span.close-tip{
  452. margin: 15px 0 140px 0;
  453. }
  454. .close-btn{
  455. margin: 0 auto;
  456. width: 200px;
  457. height: 36px;
  458. line-height: 36px;
  459. font-size: 14px;
  460. text-align: center;
  461. color: #323232;
  462. border: 1px solid #d2d2d2;
  463. border-radius: 3px;
  464. cursor: pointer ;
  465. }
  466. span.use{
  467. display: inline-block;
  468. margin-bottom: 30px;
  469. width: 360px;
  470. font-size: 14px;
  471. color: #000;
  472. text-align: left;
  473. em{
  474. font-size: 14px;
  475. font-style: normal;
  476. color: #000;
  477. }
  478. }
  479. .form-group {
  480. margin: 0 auto 16px;
  481. position: relative;
  482. width: 360px;
  483. height: 44px;
  484. line-height: 44px;
  485. input{
  486. padding: 0 0 0 18px;
  487. width: 360px;
  488. height: 44px;
  489. line-height: 44px;
  490. font-size: 14px;
  491. color: #000;
  492. border-radius: 0;
  493. }
  494. input.msg{
  495. float: left;
  496. width: 210px;
  497. padding: 0 0 0 18px;
  498. height: 44px;
  499. line-height: 44px;
  500. font-size: 14px;
  501. color: #000;
  502. border-radius: 0;
  503. }
  504. span.msg{
  505. float: right;
  506. margin: 0;
  507. width: 130px;
  508. height: 44px;
  509. line-height: 44px;
  510. text-align: center ;
  511. font-size: 14px;
  512. color: #5a5a5a;
  513. background: #f4f4f4;
  514. border: 1px solid #dcdcdc;
  515. cursor: pointer;
  516. }
  517. span.msg.send{
  518. background: #d2d2d2;
  519. color: #fff;
  520. }
  521. }
  522. .btn {
  523. margin: 34px 0 10px 0;
  524. width: 360px;
  525. height: 44px;
  526. line-height: 44px;
  527. font-size: 16px;
  528. color: #fff;
  529. background: #0076AD;
  530. border-radius: 3px;
  531. }
  532. }
  533. .choose{
  534. margin: 155px auto 0;
  535. padding-bottom: 44px;
  536. div{
  537. padding: 0 15px;
  538. margin: 0 auto 16px;
  539. width: 360px;
  540. height: 60px;
  541. line-height: 60px;
  542. text-align: left;
  543. overflow: hidden;
  544. border: 1px solid #d2d2d2;
  545. cursor: pointer;
  546. &:hover,&.active{
  547. border-color: #0076ad;
  548. span{
  549. color: #0076ad;
  550. }
  551. i.second {
  552. color: #0076ad;
  553. }
  554. }
  555. img.first{
  556. float: left;
  557. margin: 24px 20px 0 0;
  558. font-size: 20px;
  559. color: #323232;
  560. }
  561. img.first.mob{
  562. margin: 22px 20px 0 5px;
  563. font-size: 28px;
  564. }
  565. i.second {
  566. float: right;
  567. margin: 20px 0 0 5px;
  568. font-size: 20px;
  569. color: #323232;
  570. }
  571. span{
  572. float: left;
  573. font-size: 14px;
  574. color: #323232;
  575. }
  576. }
  577. }
  578. a.return{
  579. position: absolute;
  580. left: 0;
  581. top: -15px;
  582. img{
  583. width: 34px !important;
  584. height: 34px !important;
  585. }
  586. }
  587. }
  588. }
  589. }
  590. </style>