passLogin.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="pass-box">
  3. <en-nav :right-show="true" right-text="忘记密码?" @rightClick="goToEditPass"></en-nav>
  4. <view class="login-box" >
  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-text from-item" :class="{'apply-shake':passwordShake}">
  14. <input type="password" class="from-input sys-color-gray-3" v-model="password" placeholder="请输入密码"></input>
  15. </view>
  16. </view>
  17. <view class="login-but sys-color-white sys-background-black sys-selected-but" @click="login" :class="{'sys-unselected-but':!isLogin}">登录</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import EnNav from "@/components/en-utils/en-nav/en-nav";
  24. import tools from "@/service/tools";
  25. export default {
  26. components: {EnNav},
  27. data() {
  28. return {
  29. isLogin:false,
  30. phoneShake:false,
  31. passwordShake:false,
  32. phone:'',
  33. password:'',
  34. }
  35. },
  36. watch:{
  37. 'phone':function (){
  38. this.verifyIsLogin()
  39. },
  40. 'password':function (){
  41. this.verifyIsLogin()
  42. },
  43. },
  44. methods: {
  45. login(){
  46. if(this.phone.length !== 11){
  47. tools.error('请输入手机号码')
  48. this.setShake(1)
  49. tools.vibrate()
  50. return false
  51. }
  52. if(this.password ===''){
  53. tools.error('请输入密码')
  54. this.setShake(2)
  55. tools.vibrate()
  56. return false
  57. }
  58. uni.switchTab({
  59. 'url':'/pages/index/index'
  60. })
  61. },
  62. setShake(type){
  63. if(type===1){
  64. this.phoneShake=true
  65. }else {
  66. this.passwordShake=true
  67. }
  68. setTimeout(()=>{
  69. this.phoneShake=false
  70. this.passwordShake=false
  71. },500)
  72. },
  73. verifyIsLogin(){
  74. this.isLogin = this.phone.length === 11 && this.password.length>=6;
  75. },
  76. goToEditPass(){
  77. uni.navigateTo({
  78. 'url':'/pages/login/forgetPass'
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style scoped lang="scss">
  85. .pass-box{
  86. padding: 82rpx 80rpx 0 80rpx;
  87. box-sizing: border-box;
  88. position: relative;
  89. .login-top{
  90. .login-title{
  91. padding-bottom: 60rpx;
  92. .title-item{
  93. font-size: 48rpx;
  94. }
  95. }
  96. .login-from{
  97. .from-text{
  98. width: 100%;
  99. padding-bottom: 40rpx;
  100. border-bottom: 1rpx solid #E0E0E0;
  101. .from-input{
  102. font-size: 32rpx;
  103. height: 44rpx;
  104. line-height: 44rpx;
  105. }
  106. .from-input::placeholder{
  107. color: #999999;
  108. }
  109. }
  110. .from-item{
  111. margin-top: 60rpx;
  112. }
  113. }
  114. .login-but{
  115. margin-top: 120rpx;
  116. }
  117. .local-txt{
  118. padding-top: 32rpx;
  119. font-size: 24rpx;
  120. text-align: center;
  121. }
  122. }
  123. .login-bottom{
  124. padding-bottom: calc(186rpx + env(safe-area-inset-bottom));
  125. position: absolute;
  126. bottom: 0;
  127. left: 80rpx;
  128. width:calc(100vw - 160rpx);
  129. }
  130. }
  131. </style>