old_mobile.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="check">
  3. <h1>验证旧手机号</h1>
  4. <div class="line"></div>
  5. <div class="contents">
  6. <div class="old-mobile">{{mobile}}</div>
  7. <ver-code @click="sendVer" @change="changeAuthCode"></ver-code>
  8. </div>
  9. <div class="sub-container">
  10. <el-button class="next-btn" type="primary" @click="clickNext">下一步</el-button>
  11. <section>
  12. <h2>说明</h2>
  13. <p>1.修改手机号需要先验证旧手机号</p>
  14. <p>
  15. 2.若旧手机号已注销,请通过
  16. <a href="#" @click="doCheckReal">实名认证验证</a>
  17. </p>
  18. </section>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import VerCode from '@/components/ver_code'
  24. export default {
  25. components: {
  26. VerCode,
  27. },
  28. computed: {
  29. mobile() {
  30. let userMobile = this.userinfo.mobile
  31. if (!userMobile) return
  32. return `${userMobile.slice(0, 3)}****${userMobile.slice(7, 11)}`
  33. }
  34. },
  35. data() {
  36. return {
  37. authCode: '',
  38. }
  39. },
  40. mounted() {
  41. if (!this.userinfo.nickname) {
  42. location.href = '/?loginbox=show&next=' + encodeURIComponent(location.href)
  43. }
  44. },
  45. methods: {
  46. async sendVer() {
  47. let res = await this.$axios.$post('/api/user/sendMobileAuthCode', {
  48. mobile: this.userinfo.mobile
  49. })
  50. if (Number(res.status) === 1) {
  51. this.$message({
  52. message: '发送成功,请查收',
  53. type: 'success'
  54. })
  55. }
  56. },
  57. changeAuthCode(val) {
  58. this.authCode = val
  59. },
  60. async clickNext() {
  61. if (!this.authCode) {
  62. this.$message('请输入验证码')
  63. return
  64. }
  65. let res = await this.$axios.$post('/api/user/checkChangePhoneAuthCode', {
  66. mobile: this.userinfo.mobile,
  67. auth_code: this.authCode,
  68. })
  69. if (Number(res.status) === 1) {
  70. // 成功则保存history
  71. this.$message.success('校验成功!')
  72. localStorage.setItem('proginn-history', this.$route.path)
  73. localStorage.setItem('changeToken', res.data.token || '')
  74. this.$router.push('/setting/check/change_mobile')
  75. }
  76. },
  77. async doCheckReal() {
  78. let res = await this.$axios.$post(`/api/user/check_realname`)
  79. if (res.data.realname_verify_status) {
  80. // 成功则保存history
  81. localStorage.setItem('proginn-history', this.$route.path)
  82. this.$router.push('/setting/check/real_info')
  83. } else {
  84. this.$alert('请先实名认证', {
  85. confirmButtonText: '确定',
  86. callback: action => {
  87. location.href = '/setting/user'
  88. }
  89. })
  90. }
  91. },
  92. }
  93. }
  94. </script>
  95. <style scoped>
  96. .check {
  97. display: flex;
  98. flex-direction: column;
  99. align-items: center;
  100. width: 1000px;
  101. height: 588px;
  102. background: white;
  103. margin-top: 20px;
  104. }
  105. h1 {
  106. margin: 27px 0 25px;
  107. }
  108. .line {
  109. width: 960px;
  110. height: 2px;
  111. background: rgba(0, 0, 0, 0.06);
  112. }
  113. .old-mobile {
  114. margin: 102px 0 5px;
  115. }
  116. .sub-container {
  117. width: 311px;
  118. }
  119. .next-btn {
  120. width: 125px;
  121. margin: 20px 0 41px;
  122. }
  123. p {
  124. line-height: 28px;
  125. color: #919aa7;
  126. font-size: 13px;
  127. }
  128. p a {
  129. color: var(--mainColor);
  130. }
  131. </style>