ChangeManagerSecondStep.vue 19 KB

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