ChangeManagerSecondStep.vue 20 KB

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