金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
3.8 KiB

  1. <template>
  2. <view>
  3. <lf-nav title="旧手机号验证" :showIcon="true"></lf-nav>
  4. <view class="content">
  5. <view class="list">
  6. <view class="lf-flex">
  7. <view class="lf-font-28 lf-color-black" style="width: 140rpx;">旧手机号</view>
  8. <input class="input" placeholder="请输入旧手机号" v-model="phone" maxlength="11" />
  9. </view>
  10. <view class="clear" v-if="phone.length" @click="phone = ''">
  11. <text class="lf-iconfont icon-status-error"></text>
  12. </view>
  13. </view>
  14. <view class="list">
  15. <view class="lf-flex">
  16. <view class="lf-font-28 lf-color-black" style="width: 140rpx;">验证码</view>
  17. <input class="input input-code" placeholder="请输入验证码" maxlength="8" v-model="code" />
  18. </view>
  19. <view class="code" :class="{'active-bg': is_code}" @click="getCode">
  20. <text>{{ is_code ? num +'秒后重新获取' : '获取验证码' }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. <button class="next-btn" hover-class="lf-opacity" @click="next">下一步</button>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data(){
  30. return {
  31. phone: '',
  32. code: '',
  33. is_code: false,
  34. timer: null,
  35. num: 10,
  36. token: ''
  37. }
  38. },
  39. onLoad(){
  40. var token = this.$cookieStorage.get('user_token');
  41. this.token = token;
  42. },
  43. onUnload(){
  44. if(this.timer){
  45. clearInterval(this.timer);
  46. this.timer = null;
  47. }
  48. },
  49. methods: {
  50. getCode(){
  51. let phone = this.phone;
  52. if(!phone) return this.$msg('请输入手机号');
  53. if(!this.$check(phone, 'mobile')) return this.$msg('请输入正确的手机号');
  54. if(this.is_code) return;
  55. this.is_code = true;
  56. if(this.timer){
  57. clearInterval(this.timer);
  58. this.timer = null;
  59. }
  60. this.getVerifyCode();
  61. this.timer = setInterval(() => {
  62. this.num--;
  63. if(this.num <= 0){
  64. clearInterval(this.timer);
  65. this.timer = null;
  66. this.num = 10;
  67. this.is_code = false;
  68. }
  69. }, 1000);
  70. },
  71. getVerifyCode(){
  72. this.$http.post({
  73. api: 'api/sms/verify-code',
  74. data: {
  75. mobile: this.phone
  76. },
  77. header: {
  78. 'Content-Type': 'application/x-www-form-urlencoded',
  79. Authorization: this.token
  80. }
  81. }).then(res => {
  82. this.$msg(res.data.message, {icon: 'success'});
  83. })
  84. },
  85. next(){
  86. let phone = this.phone;
  87. if(!phone) return this.$msg('请输入手机号');
  88. if(!this.$check(phone, 'mobile')) return this.$msg('请输入正确的手机号');
  89. if(!this.code) return this.$msg('请输入验证码');
  90. this.$http.post({
  91. api: 'api/user/check_old_mobile',
  92. data: {
  93. code: this.code,
  94. mobile: this.phone
  95. },
  96. header: {
  97. Authorization: this.token
  98. }
  99. }).then(res => {
  100. console.log("11111res", res)
  101. if(res.data.code == 200){
  102. this.$url('/pages/user/my/newPhone');
  103. }else{
  104. this.$msg(res.data.message);
  105. }
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped="scoped">
  112. .content{
  113. padding: 0 32rpx;
  114. }
  115. .next-btn{
  116. width: 550rpx;
  117. height: 100rpx;
  118. background: #15716E;
  119. border-radius: 50rpx;
  120. position: fixed;
  121. bottom: 10vh;
  122. left: calc(50% - 275rpx);
  123. line-height: 100rpx;
  124. color: #FFFFFF;
  125. }
  126. .list{
  127. height: 106rpx;
  128. width: 100%;
  129. border-bottom: 1rpx solid #e5e5e5;
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: center;
  133. &:nth-child(2n){
  134. margin-top: 30rpx;
  135. }
  136. .input{
  137. width: 380rpx;
  138. height: 80rpx;
  139. font-size: 32rpx;
  140. margin-left: 50rpx;
  141. }
  142. .input-code{
  143. width: 290rpx;
  144. }
  145. .clear{
  146. padding: 20rpx;
  147. }
  148. .code{
  149. min-width: 180rpx;
  150. max-width: 220rpx;
  151. height: 64rpx;
  152. padding: 0 4rpx;
  153. font-size: 24rpx;
  154. color: #15716E;
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. border-radius: 32rpx;
  159. border: 2rpx solid #15716E;
  160. }
  161. .active-bg{
  162. background: #efefef;
  163. }
  164. }
  165. </style>