login.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="mobile-login-page">
  3. <view class="login-top">
  4. <img class="login-logo" src="../static/images/login/login-logo-sj.png">
  5. <text class="login-text">
  6. {{systemName}}
  7. </text>
  8. </view>
  9. <view class="login-body">
  10. <view class="input-container">
  11. <uni-icons type="auth" size="30" class="input-icon"></uni-icons>
  12. <input type="text" v-model="userName" placeholder="请输入用户名" class="input-item-1" />
  13. </view>
  14. <view class="input-container">
  15. <uni-icons type="locked" size="30" class="input-icon"></uni-icons>
  16. <input type="password" v-model="password" placeholder="请输入密码" class="input-item-1" />
  17. </view>
  18. <view class="login-change">
  19. <checkbox-group>
  20. <label class="checkbox-zhanghao">
  21. <checkbox value="cb" color="#0550e5" checked="true"/>记住此账号
  22. </label>
  23. </checkbox-group>
  24. <text class="checkbox-zhanghao" @click="forgetPassword"> 忘记密码?</text>
  25. </view>
  26. <button class="login-btn" @click="handleLogin">登录</button>
  27. </view>
  28. <passwordLli ref="passLLiRef" :password="password" @lli-password="onLliPassword" />
  29. </view>
  30. </template>
  31. <script setup>
  32. import {toast} from "@/utils/common";
  33. import {getAppConfig,login,kaoshiList} from '@/api/login.js'
  34. import passwordLli from "@/components/password-lli/password-lli.vue";
  35. import JSEncrypt from 'jsencrypt';
  36. import {ref} from 'vue';
  37. const passLLiRef = ref(null)
  38. let systemName = ref('麦塔考试系统')
  39. let userName = ref('')
  40. let password = ref('')
  41. const lliPassword = ref('') // 加密后的密码
  42. // 加密
  43. function onLliPassword(password) {
  44. console.log('onLliPassword',password)
  45. lliPassword.value = password;
  46. }
  47. function handleLogin(){
  48. if(userName.value.length ===0){
  49. toast('请输入手机号!')
  50. return
  51. }
  52. if(password.value.length ===0){
  53. toast('请输入密码!')
  54. return
  55. }
  56. // 去除 userName 两端的空格
  57. const trimmedUserName = userName.value.trim();
  58. const trimmedPassword = lliPassword.value.trim();
  59. let req = {
  60. userName: trimmedUserName,
  61. password: trimmedPassword,
  62. }
  63. console.log('req:', req);
  64. login(req).then(res => {
  65. let obj = JSON.stringify(res.data)
  66. console.log(obj)
  67. uni.setStorage({
  68. key: 'Mta-Auth',
  69. data: obj // 假设 this.userInputValue 是用户输入的数据
  70. });
  71. uni.switchTab({
  72. url: '/pages/index/index'
  73. });
  74. })
  75. }
  76. function forgetPassword(){
  77. toast('请联系管理员修改密码!');
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .mobile-login-page {
  82. width: 100%;
  83. height: 100%;
  84. background: #FFF;
  85. text-align: center;
  86. position: absolute;
  87. overflow: auto;
  88. .login-top {
  89. height: 540rpx;
  90. background-size: cover;
  91. background-image: url("../static/images/login/login-bj-sj.png");
  92. // logo
  93. }
  94. .login-logo {
  95. width: 266rpx;
  96. max-height: 100rpx;
  97. margin-top: 156rpx;
  98. }
  99. .login-text {
  100. display: block;
  101. font-size: 64rpx;
  102. color: #FFF;
  103. margin: 24rpx 0 0;
  104. font-weight: 700
  105. }
  106. // 登录区域
  107. .login-body {
  108. width: 100%;
  109. padding: 0 60px;
  110. box-sizing: border-box;
  111. margin: 140rpx auto 0;
  112. .input-container {
  113. display: flex;
  114. align-items: center;
  115. /* 垂直对齐 */
  116. position: relative;
  117. height: 100rpx;
  118. border-radius: 50rpx;
  119. background-color: #F7F7F7;
  120. padding: 0;
  121. margin-bottom: 40rpx;
  122. }
  123. .input-icon {
  124. margin-left: 20rpx;
  125. /* 图标和输入框之间的间距 */
  126. color: #999;
  127. }
  128. }
  129. // 输入框
  130. .login-btn {
  131. width: 100%;
  132. height: 100rpx;
  133. margin-top: 60rpx;
  134. font-size: 36rpx;
  135. letter-spacing: 7.2rpx;
  136. background: linear-gradient(0deg, #436aff 0%, #234ff7 100%);
  137. border-radius: 50rpx;
  138. border: 0;
  139. color: #F7F7F7;
  140. line-height: 100rpx;
  141. }
  142. .login-change {
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. .checkbox-zhanghao {
  147. font-size: 24rpx;
  148. color: #565656;
  149. }
  150. }
  151. }
  152. </style>