passLogin.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. },
  59. setShake(type){
  60. if(type===1){
  61. this.phoneShake=true
  62. }else {
  63. this.passwordShake=true
  64. }
  65. setTimeout(()=>{
  66. this.phoneShake=false
  67. this.passwordShake=false
  68. },500)
  69. },
  70. verifyIsLogin(){
  71. this.isLogin = this.phone.length === 11 && this.password.length>=6;
  72. },
  73. goToEditPass(){
  74. uni.navigateTo({
  75. 'url':'/pages/login/forgetPass'
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="scss">
  82. .pass-box{
  83. padding: 82rpx 80rpx 0 80rpx;
  84. box-sizing: border-box;
  85. position: relative;
  86. .login-top{
  87. .login-title{
  88. padding-bottom: 60rpx;
  89. .title-item{
  90. font-size: 48rpx;
  91. }
  92. }
  93. .login-from{
  94. .from-text{
  95. width: 100%;
  96. padding-bottom: 40rpx;
  97. border-bottom: 1rpx solid #E0E0E0;
  98. .from-input{
  99. font-size: 32rpx;
  100. height: 44rpx;
  101. line-height: 44rpx;
  102. }
  103. .from-input::placeholder{
  104. color: #999999;
  105. }
  106. }
  107. .from-item{
  108. margin-top: 60rpx;
  109. }
  110. }
  111. .login-but{
  112. margin-top: 120rpx;
  113. }
  114. .local-txt{
  115. padding-top: 32rpx;
  116. font-size: 24rpx;
  117. text-align: center;
  118. }
  119. }
  120. .login-bottom{
  121. padding-bottom: calc(186rpx + env(safe-area-inset-bottom));
  122. position: absolute;
  123. bottom: 0;
  124. left: 80rpx;
  125. width:calc(100vw - 160rpx);
  126. }
  127. }
  128. </style>