otherPhoneLogin.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="other-box">
  3. <en-nav @navHeight="setNavHeight" :right-show="true" right-text="密码登录" @rightClick="goToPass"></en-nav>
  4. <view class="login-box" :style="{'height':'calc(100vh - '+navHeight+'px)'}">
  5. <view class="login-top">
  6. <view class="login-title">
  7. <text class="title-item sys-color-black sys-weight-600">验证登录</text>
  8. </view>
  9. <view class="login-from">
  10. <view class="from-text" :class="{'apply-shake':phoneShake}">
  11. <input type="tel" class="from-input sys-color-gray-3" max="11" v-model="phone" placeholder="请输入手机号"></input>
  12. </view>
  13. <view class="from-code" :class="{'apply-shake':codeShake}">
  14. <view class="from-text">
  15. <input type="tel" class="from-input sys-color-gray-3" v-model="code" placeholder="请输入验证码"></input>
  16. </view>
  17. <view class="code-text">
  18. <text class="sys-color-gray-3" v-if="time<=0" @click="senCode">获取验证码</text>
  19. <text class="sys-color-gray-3" v-else>{{time}} s</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="login-but sys-color-white sys-background-black sys-selected-but" @click="login" :class="{'sys-unselected-but':!isLogin}">登录</view>
  24. <view class="local-txt sys-color-gray-9">若长时间未收到验证码,请使用以下方式快速登录</view>
  25. </view>
  26. </view>
  27. <view class="login-bottom">
  28. <other-login></other-login>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import EnNav from "@/components/en-utils/en-nav/en-nav";
  34. import tools from "@/service/tools";
  35. import OtherLogin from "@/pages/login/model/otherLogin";
  36. export default {
  37. name:'otherPhoneLogin',
  38. components: {OtherLogin, EnNav},
  39. data() {
  40. return {
  41. navHeight:40,
  42. isLogin:false,
  43. phoneShake:false,
  44. codeShake:false,
  45. phone:'',
  46. code:'',
  47. time:0,
  48. }
  49. },
  50. watch:{
  51. 'phone':function (){
  52. this.verifyIsLogin()
  53. },
  54. 'code':function (){
  55. this.verifyIsLogin()
  56. },
  57. },
  58. methods: {
  59. login(){
  60. if(this.phone.length !== 11){
  61. tools.error('请输入手机号码')
  62. this.setShake(1)
  63. tools.vibrate()
  64. return false
  65. }
  66. if(this.code ===''){
  67. tools.error('请输入验证码')
  68. this.setShake(2)
  69. tools.vibrate()
  70. return false
  71. }
  72. uni.switchTab({
  73. 'url':'/pages/index/index'
  74. })
  75. },
  76. setShake(type){
  77. if(type===1){
  78. this.phoneShake=true
  79. }else {
  80. this.codeShake=true
  81. }
  82. setTimeout(()=>{
  83. this.phoneShake=false
  84. this.codeShake=false
  85. },500)
  86. },
  87. setNavHeight(navHeight){
  88. this.navHeight=navHeight
  89. },
  90. verifyIsLogin(){
  91. this.isLogin = this.phone.length === 11 && this.code !== '';
  92. },
  93. senCode(){
  94. if(this.phone.length !== 11){
  95. tools.error('请输入手机号码')
  96. this.setShake(1)
  97. tools.vibrate()
  98. return false
  99. }
  100. this.time=60
  101. let timeServe=setInterval(()=>{
  102. --this.time
  103. if(this.time<=0){
  104. clearInterval(timeServe)
  105. }
  106. },1000)
  107. },
  108. goToPass(){
  109. uni.navigateTo({
  110. 'url':'/pages/login/passLogin'
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .other-box{
  118. padding: 82rpx 80rpx 0 80rpx;
  119. box-sizing: border-box;
  120. position: relative;
  121. .login-top{
  122. .login-title{
  123. padding-bottom: 60rpx;
  124. .title-item{
  125. font-size: 48rpx;
  126. }
  127. }
  128. .login-from{
  129. .from-text{
  130. width: 100%;
  131. padding-bottom: 40rpx;
  132. border-bottom: 1rpx solid #E0E0E0;
  133. .from-input{
  134. font-size: 32rpx;
  135. height: 44rpx;
  136. line-height: 44rpx;
  137. }
  138. .from-input::placeholder{
  139. color: #999999;
  140. }
  141. }
  142. .from-code{
  143. margin-top: 60rpx;
  144. display: flex;
  145. justify-content: space-between;
  146. .from-text{
  147. width: 344rpx;
  148. }
  149. .code-text{
  150. width: 180rpx;
  151. height: 44rpx;
  152. line-height: 44rpx;
  153. text-align: center;
  154. text{
  155. font-size: 32rpx;
  156. }
  157. }
  158. }
  159. }
  160. .login-but{
  161. margin-top: 120rpx;
  162. }
  163. .local-txt{
  164. padding-top: 32rpx;
  165. font-size: 24rpx;
  166. text-align: center;
  167. }
  168. }
  169. .login-bottom{
  170. padding-bottom: calc(186rpx + env(safe-area-inset-bottom));
  171. position: absolute;
  172. bottom: 0;
  173. left: 80rpx;
  174. width:calc(100vw - 160rpx);
  175. }
  176. }
  177. </style>