otherPhoneLogin.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. import {forgetPassword} from "@/api/login";
  37. export default {
  38. name:'otherPhoneLogin',
  39. components: {OtherLogin, EnNav},
  40. data() {
  41. return {
  42. navHeight:40,
  43. isLogin:false,
  44. phoneShake:false,
  45. codeShake:false,
  46. phone:'',
  47. code:'',
  48. time:0,
  49. }
  50. },
  51. watch:{
  52. 'phone':function (){
  53. this.verifyIsLogin()
  54. },
  55. 'code':function (){
  56. this.verifyIsLogin()
  57. },
  58. },
  59. methods: {
  60. login(){
  61. if(this.phone.length !== 11){
  62. tools.error('请输入手机号码')
  63. this.setShake(1)
  64. tools.vibrate()
  65. return false
  66. }
  67. if(this.code ===''){
  68. tools.error('请输入验证码')
  69. this.setShake(2)
  70. tools.vibrate()
  71. return false
  72. }
  73. forgetPassword({'mobile':this.phone,'code':this.code}).then((res)=>{
  74. if(res.code===0){
  75. tools.success('登陆成功')
  76. setTimeout(()=>{
  77. uni.switchTab({
  78. 'url':'/pages/index/index'
  79. })
  80. },1500)
  81. }else {
  82. tools.error(res.msg)
  83. }
  84. })
  85. },
  86. setShake(type){
  87. if(type===1){
  88. this.phoneShake=true
  89. }else {
  90. this.codeShake=true
  91. }
  92. setTimeout(()=>{
  93. this.phoneShake=false
  94. this.codeShake=false
  95. },500)
  96. },
  97. setNavHeight(navHeight){
  98. this.navHeight=navHeight
  99. },
  100. verifyIsLogin(){
  101. this.isLogin = this.phone.length === 11 && this.code !== '';
  102. },
  103. senCode(){
  104. if(this.phone.length !== 11){
  105. tools.error('请输入手机号码')
  106. this.setShake(1)
  107. tools.vibrate()
  108. return false
  109. }
  110. this.time=60
  111. let timeServe=setInterval(()=>{
  112. --this.time
  113. if(this.time<=0){
  114. clearInterval(timeServe)
  115. }
  116. },1000)
  117. },
  118. goToPass(){
  119. uni.navigateTo({
  120. 'url':'/pages/login/passLogin'
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. .other-box{
  128. padding: 82rpx 80rpx 0 80rpx;
  129. box-sizing: border-box;
  130. position: relative;
  131. .login-top{
  132. .login-title{
  133. padding-bottom: 60rpx;
  134. .title-item{
  135. font-size: 48rpx;
  136. }
  137. }
  138. .login-from{
  139. .from-text{
  140. width: 100%;
  141. padding-bottom: 40rpx;
  142. border-bottom: 1rpx solid #E0E0E0;
  143. .from-input{
  144. font-size: 32rpx;
  145. height: 44rpx;
  146. line-height: 44rpx;
  147. }
  148. .from-input::placeholder{
  149. color: #999999;
  150. }
  151. }
  152. .from-code{
  153. margin-top: 60rpx;
  154. display: flex;
  155. justify-content: space-between;
  156. .from-text{
  157. width: 344rpx;
  158. }
  159. .code-text{
  160. width: 180rpx;
  161. height: 44rpx;
  162. line-height: 44rpx;
  163. text-align: center;
  164. text{
  165. font-size: 32rpx;
  166. }
  167. }
  168. }
  169. }
  170. .login-but{
  171. margin-top: 120rpx;
  172. }
  173. .local-txt{
  174. padding-top: 32rpx;
  175. font-size: 24rpx;
  176. text-align: center;
  177. }
  178. }
  179. .login-bottom{
  180. padding-bottom: calc(186rpx + env(safe-area-inset-bottom));
  181. position: absolute;
  182. bottom: 0;
  183. left: 80rpx;
  184. width:calc(100vw - 160rpx);
  185. }
  186. }
  187. </style>