accountVf.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="login-box-parent">
  3. <van-nav-bar title="输入验证码完成注销" left-text="返回" @click-left="$route_back" left-arrow></van-nav-bar>
  4. <div class="login-box" style="background-color: #f5f5f5;">
  5. <scroller>
  6. <div class="login-form-box" style="background-color: #fff;">
  7. <div class="setp1">
  8. <van-cell-group>
  9. <van-cell title="手机号" v-show="account_tel != ''">{{ account_tel | mobile }}</van-cell>
  10. <van-field v-model="formData.origin_verify" center clearable label="验证码" placeholder="请输入短信验证码">
  11. <van-button style="border:none;font-size:0.28rem;" :loading="sendMsgLoading" slot="button" size="small" plain type="info" @click="sendMsg" :disabled="sended">
  12. {{ sendMsgText }}
  13. </van-button>
  14. </van-field>
  15. </van-cell-group>
  16. </div>
  17. <div style="padding:0 0.32rem 0.2rem;"><van-button :loading="reg_loading" size="large" @click="nextReg" type="info">确定</van-button></div>
  18. </div>
  19. </scroller>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { returnJSEncrypt } from '@/utils/auth';
  25. export default {
  26. name: 'change_pwd',
  27. filters: {
  28. mobile(tel) {
  29. if (tel) {
  30. return tel == '' ? tel : tel.replace(tel.substring(3, 7), '****');
  31. }
  32. return '';
  33. }
  34. },
  35. data() {
  36. return {
  37. countdownSet: null,
  38. next_loading: false,
  39. reg_loading: false,
  40. mobile_error: '',
  41. mobile_success: '',
  42. complite_btn_enable: false,
  43. login_error: false,
  44. login_error_msg: '',
  45. next_btn_enable: false,
  46. userinfo: this.$userInfo(),
  47. account_info: this.$store.getters.account_info,
  48. account_tel:localStorage.getItem('a-token-tel'),
  49. setp: 1,
  50. countdown: 90,
  51. sended: false,
  52. sendMsgText: '获取验证码',
  53. sendMsgLoading: false,
  54. formData: {
  55. verify: '',
  56. origin_verify: '',
  57. tel: ''
  58. }
  59. };
  60. },
  61. watch: {
  62. formData: {
  63. handler(val, oldVal) {
  64. if (val.username != '' && val.code != '') {
  65. this.next_btn_enable = true;
  66. } else {
  67. this.next_btn_enable = false;
  68. }
  69. if (!this.checkMobile(val.username)) {
  70. this.mobile_error = '手机号格式错误';
  71. this.mobile_success = '';
  72. } else {
  73. this.mobile_error = '';
  74. this.mobile_success = 'success';
  75. }
  76. if (val.password != '' && val.password_check != '') {
  77. this.complite_btn_enable = true;
  78. } else {
  79. this.complite_btn_enable = false;
  80. }
  81. },
  82. deep: true
  83. }
  84. },
  85. activated(){
  86. // console.log(account_tel)
  87. },
  88. methods: {
  89. nextReg() {
  90. this.next_loading = true;
  91. let data = { tel: this.account_tel, verify: this.formData.origin_verify };
  92. this.$axios('post', '/api/pro/destruction', { data: returnJSEncrypt(data) }, 'v2').then(res => {
  93. if (res.data.code == 1) {
  94. this.$toast('注销成功');
  95. setTimeout(() => {
  96. this.$toast.clear();
  97. this.nologin();
  98. }, 500);
  99. }
  100. })
  101. .finally(() => {
  102. this.next_loading = false;
  103. });
  104. },
  105. nologin() {
  106. if (window.plus) {
  107. plus.storage.removeItem('Admin-Token');
  108. plus.storage.removeItem('a-token-temp');
  109. plus.storage.removeItem('a-token-tel');
  110. } else {
  111. localStorage.removeItem('a-token-temp');
  112. localStorage.removeItem('a-token-tel');
  113. localStorage.removeItem('Admin-Token');
  114. }
  115. this.$store.dispatch('clear_cache');
  116. this.$router.replace({ name: 'login' });
  117. },
  118. countDownInit() {
  119. this.sendMsgText = '已发送(' + this.countdown + ')';
  120. if (this.countdown == 0) {
  121. this.countdown = 90;
  122. this.sendMsgText = '重新发送';
  123. this.sended = false;
  124. return false;
  125. } else {
  126. this.countdownSet = setTimeout(() => {
  127. this.countdown--;
  128. this.countDownInit();
  129. }, 1000);
  130. }
  131. },
  132. checkMobile(sMobile) {
  133. if (!/^1[0123456789]\d{9}$/.test(sMobile)) {
  134. return false;
  135. } else {
  136. return true;
  137. }
  138. },
  139. sendMsg() {
  140. this.sendMsgLoading = true;
  141. let data = { mobile: this.account_tel, type: 7 };
  142. if (!this.verifyPhoneNo(data.mobile)) {
  143. this.$notify({
  144. message: '请输入正确手机号码',
  145. duration: 1000,
  146. background: '#f44'
  147. });
  148. this.sendMsgLoading = false;
  149. return false;
  150. }
  151. this.$axios('post', '/api/pro/send-sms', { data: returnJSEncrypt(data) }, 'v2')
  152. .then(res => {
  153. if (res.data.code == 1) {
  154. this.sended = true;
  155. this.countDownInit();
  156. this.$toast('已经发送,请注意查收!');
  157. } else {
  158. this.$toast(res.data.msg);
  159. }
  160. })
  161. .finally(() => {
  162. this.sendMsgLoading = false;
  163. });
  164. },
  165. verifyPhoneNo(value) {
  166. return /^1[1023456789]\d{9}$/.test(value);
  167. }
  168. }
  169. };
  170. </script>
  171. <style rel="stylesheet/scss" lang="scss" scoped>
  172. .login-box {
  173. height: calc(100% - 0.92rem);
  174. position: relative;
  175. }
  176. .login-box-parent .van-field__icon .van-icon {
  177. color: #4b0;
  178. }
  179. .login-logo {
  180. width: 6.52rem;
  181. margin: 0 auto;
  182. display: block !important;
  183. height: 3.5rem;
  184. }
  185. .setp1,
  186. .setp2 {
  187. padding-bottom: 0.36rem;
  188. }
  189. .login-box-parent .mint-cell.cell-last:before {
  190. bottom: 0;
  191. }
  192. .login-box-parent /deep/ .login-form-box {
  193. background: transparent !important;
  194. }
  195. .login-box-parent .message_code /deep/ .van-field__button {
  196. border: none;
  197. }
  198. </style>