bindPhoneNumber.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="wrap">
  3. <view class="top"></view>
  4. <view class="content">
  5. <view class="title">绑定手机号</view>
  6. <input class="u-border-bottom" type="number" maxlength="11" v-model="tel" placeholder="请输入手机号" />
  7. <button @tap="submit" :style="[inputStyle]" class="getCaptcha">获取短信验证码</button>
  8. <u-message-input v-if="show" :focus="true" :value="messageCode" @change="change" @finish="finish" mode="bottomLine" :maxlength="codelength"></u-message-input>
  9. </view>
  10. <!-- <text v-if="messageError">验证码错误,请重新输入</text> -->
  11. <view class="captcha">
  12. <!-- <text v-if="show&&this.messageDisable==false" @tap="noCaptcha">收不到验证码点这里</text> -->
  13. <text v-if="messageShow">{{ second }}秒后可重新获取验证码</text>
  14. </view>
  15. <view class="buttom">
  16. <view class="hint">
  17. 登录代表同意
  18. <text class="link">隐私政策,</text>
  19. 并授权使用您的账号信息(如昵称、头像、收获地址)以便您统一管理
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. tel: '',
  29. messageCode:'',
  30. messageShow: false,
  31. messageDisable: false,
  32. codelength: 4,
  33. show: false,
  34. second:10,
  35. // messageError:false
  36. }
  37. },
  38. onLoad() {
  39. },
  40. computed: {
  41. inputStyle() {
  42. let style = {};
  43. if(this.tel.length==11&&this.messageDisable==false) {
  44. style.color = "#fff";
  45. style.backgroundColor = this.$u.color['warning'];
  46. }
  47. return style;
  48. }
  49. },
  50. methods: {
  51. submit() {
  52. if(this.$u.test.mobile(this.tel)&&this.messageDisable==false) {
  53. this.messageDisable = true;
  54. this.messageShow = true;
  55. this.show = true;
  56. // this.getCaptcha()
  57. let interval = setInterval(() => {
  58. this.second--;
  59. if (this.second <= 0) {
  60. this.messageDisable=false
  61. this.messageShow = false;
  62. if (this.messageCode.lenth != 4) {
  63. // this.messageError = true;
  64. }
  65. clearInterval(interval);
  66. this.second=10;
  67. }
  68. }, 1000);
  69. }
  70. },
  71. // 收不到验证码选择时的选择
  72. noCaptcha() {
  73. uni.showActionSheet({
  74. itemList: ['重新获取验证码', '接听语音验证码'],
  75. success: function(res) {
  76. },
  77. fail: function(res) {
  78. }
  79. });
  80. },
  81. // change事件侦听
  82. change(value) {
  83. // console.log('change', value);
  84. },
  85. // 输入完验证码最后一位执行
  86. finish(value) {
  87. let params = {
  88. tel:this.tel,
  89. openid:this.$store.state.vuex_user.openId,
  90. value:value
  91. };
  92. this.$u.api.bindphone(params)
  93. .then(res =>{
  94. if(res.retBody.OK=='ok'){
  95. this.$u.route({
  96. url: 'pages/template/login/code'
  97. })
  98. }else{
  99. }
  100. });
  101. console.log('finish', value);
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .hide{display: none!important;}
  108. .wrap {
  109. font-size: 28rpx;
  110. .content {
  111. width: 600rpx;
  112. margin: 80rpx auto 0;
  113. .title {
  114. text-align: left;
  115. font-size: 60rpx;
  116. font-weight: 500;
  117. margin-bottom: 100rpx;
  118. }
  119. input {
  120. text-align: left;
  121. margin-bottom: 10rpx;
  122. padding-bottom: 20rpx;
  123. border-bottom: 1px solid #ddd;
  124. }
  125. .getCaptcha {
  126. margin: 45rpx auto 130rpx;
  127. background-color: rgb(253, 243, 208);
  128. color: $u-tips-color;
  129. border: none;
  130. font-size: 30rpx;
  131. padding: 12rpx 0;
  132. &::after {
  133. border: none;
  134. }
  135. }
  136. }
  137. .buttom {
  138. .hint {
  139. padding: 20rpx 40rpx;
  140. font-size: 20rpx;
  141. color: $u-tips-color;
  142. .link {
  143. color: $u-type-warning;
  144. }
  145. }
  146. }
  147. .captcha {
  148. color: $u-type-warning;
  149. font-size: 30rpx;
  150. margin-top: 40rpx;
  151. text-align: center;
  152. }
  153. }
  154. </style>