ChangeManagerSecondStep.vue 20 KB

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