时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.6 KiB

  1. <template>
  2. <view>
  3. <view class="lf-flex-column lf-row-center logo">
  4. <image ></image>
  5. </view>
  6. <view class="lf-row-between inpu-box">
  7. <u-icon name="phone" size="50"></u-icon>
  8. <input maxlength="11" v-model="phoneNum" placeholder="请输入手机号" />
  9. </view>
  10. <view class="lf-row-between verif-code" v-if="isCodeLogin">
  11. <view class="lf-row-between code-input">
  12. <u-icon name="lock" size="50" color="#999999"></u-icon>
  13. <input maxlength="5" v-model="codeNum" placeholder="验证码" />
  14. </view>
  15. <button class="code-btn" :style="{'background-color': isGetCode ? '#FE9903' : '#999999'}" @click="getCode">
  16. {{ isGetCode ? '获取验证码' : codeTimeNum +'s后重新获取' }}
  17. </button>
  18. </view>
  19. <view class="lf-row-between inpu-box lf-m-t-30" v-else>
  20. <u-icon name="lock" size="50"></u-icon>
  21. <input maxlength="11" v-model="password" :password="true" placeholder="请输入密码" />
  22. </view>
  23. <view @click="switchLoginType" class="login-type">{{ isCodeLogin ? '使用密码登录' : '使用验证码登录' }}</view>
  24. <button class="login-btn" @click="login">登录</button>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data(){
  30. return {
  31. phoneNum: '',
  32. codeNum: '',
  33. password: '',
  34. isGetCode: true,
  35. isCodeLogin: true,
  36. codeTimeNum: 10,
  37. codeTime: null
  38. }
  39. },
  40. onLoad(){
  41. },
  42. onUnload(){
  43. if(this.codeTime){
  44. clearInterval(this.codeTime);
  45. this.codeTime = null;
  46. }
  47. },
  48. methods: {
  49. // 切换账号和验证码登录
  50. switchLoginType(){
  51. this.codeNum = '';
  52. this.password = '';
  53. this.isCodeLogin = !this.isCodeLogin;
  54. },
  55. // 获取验证码
  56. getCode(){
  57. if(this.isGetCode){
  58. console.log("此处请求")
  59. }
  60. if(this.codeTimeNum == 10){
  61. this.isGetCode = false;
  62. if(this.codeTime){
  63. clearInterval(this.codeTime);
  64. this.codeTime = null;
  65. this.codeTimeNum = 10;
  66. }
  67. this.codeTime = setInterval(() => {
  68. this.codeTimeNum = this.codeTimeNum - 1;
  69. if(this.codeTimeNum < 0){
  70. clearInterval(this.codeTime);
  71. this.codeTime = null;
  72. this.codeTimeNum = 10;
  73. this.isGetCode = true;
  74. }
  75. }, 1000);
  76. }
  77. },
  78. // 登录
  79. login(){
  80. let pages = getCurrentPages();
  81. let prevPage = pages[pages.length - 2];
  82. // prevPage.$vm.isLogin = true; // 上一个页面登录成功
  83. // this.$toBack(); // 登录成功
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped="scoped">
  89. .logo{
  90. width: 100%;
  91. height: 220rpx;
  92. image{
  93. width: 160rpx;
  94. height: 160rpx;
  95. border-radius: 50%;
  96. background-color: #EEEEEE;
  97. }
  98. }
  99. .inpu-box{
  100. width: 686rpx;
  101. height: 88rpx;
  102. border: 2rpx solid #FE9903;
  103. border-radius: 10rpx;
  104. color: #FE9903;
  105. box-sizing: border-box;
  106. padding: 0 20rpx;
  107. margin: 0 auto;
  108. margin-top: 50rpx;
  109. input{
  110. width: 570rpx;
  111. height: 66rpx;
  112. font-size: 32rpx;
  113. display: flex;
  114. align-items: center;
  115. padding: 0 20rpx;
  116. }
  117. }
  118. .verif-code{
  119. width: 686rpx;
  120. height: 88rpx;
  121. margin: 0 auto;
  122. margin-top: 30rpx;
  123. .code-input{
  124. width: 438rpx;
  125. height: 88rpx;
  126. border: 2rpx solid #999999;
  127. border-radius: 10rpx;
  128. box-sizing: border-box;
  129. padding: 0 20rpx;
  130. input{
  131. width: 344rpx;
  132. height: 66rpx;
  133. padding: 0 20rpx;
  134. font-size: 32rpx;
  135. }
  136. }
  137. .code-btn{
  138. margin: 0;
  139. width: 228rpx;
  140. height: 88rpx;
  141. border-radius: 10rpx;
  142. color: #FFFFFF;
  143. font-size: 28rpx;
  144. line-height: 88rpx;
  145. }
  146. }
  147. .login-type{
  148. color: #FE9903;
  149. text-align: center;
  150. margin-top: 40rpx;
  151. }
  152. .login-btn{
  153. width: 686rpx;
  154. height: 88rpx;
  155. background-color: #FE9903;
  156. color: #FFFFFF;
  157. line-height: 88rpx;
  158. border-radius: 42rpx;
  159. margin-top: 100rpx;
  160. }
  161. </style>