phone.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="container">
  3. <view class="row b-b">
  4. <text class="tit">手机号或邮箱</text>
  5. <input class="input" v-model="account" type="text" placeholder="请填写手机号" placeholder-class="placeholder" />
  6. </view>
  7. <view>
  8. <view class="row b-b">
  9. <text class="tit">验证码</text>
  10. <input class="input" v-model="captcha" type="text" placeholder="请填写验证码" placeholder-class="placeholder" />
  11. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  12. </view>
  13. <button class="add-btn" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</button>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { verify } from '@/api/login.js';
  19. import { mapState } from 'vuex';
  20. import { registerReset, binding } from '@/api/set.js';
  21. export default {
  22. data() {
  23. return {
  24. time: '', //保存倒计时对象
  25. countDown: 0, //倒计时
  26. account: '', //手机号
  27. captcha: '', //验证码
  28. password: '', //新密码
  29. loding: false //是否载入中
  30. };
  31. },
  32. watch: {
  33. // 监听倒计时
  34. countDown(i) {
  35. if (i == 0) {
  36. clearInterval(this.time);
  37. }
  38. }
  39. },
  40. computed: {
  41. ...mapState(['userInfo'])
  42. },
  43. onLoad() {
  44. if (this.userInfo.phone == null) {
  45. this.account = '';
  46. } else {
  47. this.account = this.userInfo.phone;
  48. this.show = false;
  49. }
  50. },
  51. methods: {
  52. //发送验证码
  53. verification() {
  54. let obj = this;
  55. if (this.account == '') {
  56. this.$api.msg('请输入电话号码或邮箱');
  57. return;
  58. }
  59. // 判断是否在倒计时
  60. if (obj.countDown > 0) {
  61. return false;
  62. } else {
  63. obj.countDown = 60;
  64. obj.time = setInterval(() => {
  65. obj.countDown--;
  66. }, 1000);
  67. //调用验证码接口
  68. verify({
  69. phone: obj.account,
  70. type: 'BDING_CODE'
  71. })
  72. .then(({ data }) => {})
  73. .catch(err => {
  74. console.log(err);
  75. });
  76. }
  77. },
  78. confirm(e) {
  79. let obj = this;
  80. obj.loding = true;
  81. binding({
  82. phone: obj.account,
  83. captcha: obj.captcha
  84. })
  85. .then(({ data }) => {
  86. obj.$api.msg('绑定成功!');
  87. let spread = uni.getStorageSync('spread') || '';
  88. console.log(spread,'邀请人ID')
  89. setTimeout(function() {
  90. obj.loding = false;
  91. uni.navigateTo({
  92. url:'/pages/public/wxLogin'
  93. })
  94. }, 1000);
  95. })
  96. .catch(err => {
  97. obj.loding = false;
  98. console.log(err);
  99. });
  100. }
  101. }
  102. };
  103. </script>
  104. <style lang="scss">
  105. page {
  106. background: $page-color-base;
  107. }
  108. .row {
  109. display: flex;
  110. align-items: center;
  111. position: relative;
  112. padding: 0 30rpx;
  113. height: 110rpx;
  114. background: #fff;
  115. .tit {
  116. flex-shrink: 0;
  117. width: 200rpx;
  118. font-size: 30rpx;
  119. color: $font-color-dark;
  120. }
  121. .input {
  122. flex: 1;
  123. font-size: 30rpx;
  124. color: $font-color-dark;
  125. }
  126. .iconlocation {
  127. font-size: 36rpx;
  128. color: $font-color-light;
  129. }
  130. }
  131. .add-btn {
  132. display: flex;
  133. align-items: center;
  134. justify-content: center;
  135. width: 690rpx;
  136. height: 80rpx;
  137. margin: 60rpx auto;
  138. font-size: $font-lg;
  139. color: #fff;
  140. background-color: $base-color;
  141. border-radius: 10rpx;
  142. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  143. }
  144. .bg-gray {
  145. background-color: $color-gray;
  146. }
  147. .code {
  148. color: #32baff;
  149. font-size: 23rpx;
  150. border-left: 1px solid #eeeeee;
  151. width: 150rpx;
  152. flex-shrink: 0;
  153. text-align: center;
  154. }
  155. </style>