chang-phone.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="chang-phone-box">
  3. <en-nav title="修改绑定手机" :title-color="'#333'" ></en-nav>
  4. <view class="chang-phone-from">
  5. <view class="from-text" :class="{'apply-shake':phoneShake}">
  6. <input type="tel" class="from-input sys-color-gray-3" max="11" v-model="phone" placeholder="请输入手机号"></input>
  7. </view>
  8. <view class="from-code" :class="{'apply-shake':codeShake}">
  9. <view class="from-text">
  10. <input type="tel" class="from-input sys-color-gray-3" v-model="code" placeholder="请输入验证码"></input>
  11. </view>
  12. <view class="code-text sys-background-yellow">
  13. <text class="sys-color-gray-3" v-if="time<=0" @click="senCode">获取验证码</text>
  14. <text class="sys-color-gray-3" v-else>{{time}} s</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="chang-phone-but sys-color-white sys-background-black sys-selected-but" @click="setPhone" :class="{'sys-unselected-but':!isLogin}">完成</view>
  19. </view>
  20. </template>
  21. <script>
  22. import EnNav from "@/components/en-utils/en-nav/en-nav";
  23. import tools from "@/service/tools";
  24. export default {
  25. components: {EnNav},
  26. data() {
  27. return {
  28. navHeight:40,
  29. isLogin:false,
  30. phoneShake:false,
  31. codeShake:false,
  32. phone:'',
  33. code:'',
  34. time:0
  35. }
  36. },
  37. watch:{
  38. 'phone':function (){
  39. this.verifyIsLogin()
  40. },
  41. 'code':function (){
  42. this.verifyIsLogin()
  43. },
  44. },
  45. methods: {
  46. setPhone(){
  47. if(this.phone.length !== 11){
  48. tools.error('请输入手机号码')
  49. this.setShake(1)
  50. tools.vibrate()
  51. return false
  52. }
  53. if(this.code ===''){
  54. tools.error('请输入验证码')
  55. this.setShake(2)
  56. tools.vibrate()
  57. return false
  58. }
  59. uni.redirectTo({
  60. 'url':'/pages/my/set'
  61. })
  62. },
  63. setShake(type){
  64. if(type===1){
  65. this.phoneShake=true
  66. }else if(type===3){
  67. this.passwordShake=true
  68. }else {
  69. this.codeShake=true
  70. }
  71. setTimeout(()=>{
  72. this.phoneShake=false
  73. this.passwordShake=false
  74. this.codeShake=false
  75. },500)
  76. },
  77. setNavHeight(navHeight){
  78. this.navHeight=navHeight
  79. },
  80. verifyIsLogin(){
  81. this.isLogin = this.phone.length === 11 && this.code !== '';
  82. },
  83. senCode(){
  84. if(this.phone.length !== 11){
  85. tools.error('请输入手机号码')
  86. this.setShake(2)
  87. tools.vibrate()
  88. return false
  89. }
  90. this.time=60
  91. let timeServe=setInterval(()=>{
  92. --this.time
  93. if(this.time<=0){
  94. clearInterval(timeServe)
  95. }
  96. },1000)
  97. },
  98. }
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. .chang-phone-box{
  103. padding: 0 32rpx;
  104. box-sizing: border-box;
  105. position: relative;
  106. min-height: 100vh;
  107. .chang-phone-from{
  108. margin-top: 40rpx;
  109. .from-text{
  110. width: 100%;
  111. padding-bottom: 40rpx;
  112. border-bottom: 1rpx solid #E0E0E0;
  113. .from-input{
  114. font-size: 32rpx;
  115. height: 44rpx;
  116. line-height: 44rpx;
  117. }
  118. .from-input::placeholder{
  119. color: #999999;
  120. }
  121. }
  122. .from-code{
  123. margin-top: 48rpx;
  124. display: flex;
  125. justify-content: space-between;
  126. align-items: center;
  127. .from-text{
  128. width: 344rpx;
  129. }
  130. .code-text{
  131. padding: 0 16rpx;
  132. border-radius: 200rpx;
  133. width: 180rpx;
  134. height: 60rpx;
  135. line-height: 60rpx;
  136. text-align: center;
  137. text{
  138. font-size: 32rpx;
  139. }
  140. }
  141. }
  142. .from-item{
  143. margin-top: 60rpx;
  144. }
  145. }
  146. .chang-phone-but{
  147. position: absolute;
  148. bottom:calc(50rpx + env(safe-area-inset-bottom));
  149. left: 32rpx;
  150. width:calc(100vw - 64rpx);
  151. }
  152. }
  153. </style>