login.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. login(req).then(res => {
  64. let obj = JSON.stringify(res.data)
  65. console.log(obj)
  66. uni.setStorage({
  67. key: 'Mta-Auth',
  68. data: obj // 假设 this.userInputValue 是用户输入的数据
  69. });
  70. uni.switchTab({
  71. url: '/pages/index/index'
  72. });
  73. })
  74. }
  75. function forgetPassword(){
  76. toast('请联系管理员修改密码!');
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .mobile-login-page {
  81. width: 100%;
  82. height: 100%;
  83. background: #FFF;
  84. text-align: center;
  85. position: absolute;
  86. overflow: auto;
  87. .login-top {
  88. height: 540rpx;
  89. background-size: cover;
  90. background-image: url("../static/images/login/login-bj-sj.png");
  91. // logo
  92. }
  93. .login-logo {
  94. width: 266rpx;
  95. max-height: 100rpx;
  96. margin-top: 156rpx;
  97. }
  98. .login-text {
  99. display: block;
  100. font-size: 64rpx;
  101. color: #FFF;
  102. margin: 24rpx 0 0;
  103. font-weight: 700
  104. }
  105. // 登录区域
  106. .login-body {
  107. width: 100%;
  108. padding: 0 60px;
  109. box-sizing: border-box;
  110. margin: 140rpx auto 0;
  111. .input-container {
  112. display: flex;
  113. align-items: center;
  114. /* 垂直对齐 */
  115. position: relative;
  116. height: 100rpx;
  117. border-radius: 50rpx;
  118. background-color: #F7F7F7;
  119. padding: 0;
  120. margin-bottom: 40rpx;
  121. }
  122. .input-icon {
  123. margin-left: 20rpx;
  124. /* 图标和输入框之间的间距 */
  125. color: #999;
  126. }
  127. }
  128. // 输入框
  129. .login-btn {
  130. width: 100%;
  131. height: 100rpx;
  132. margin-top: 60rpx;
  133. font-size: 36rpx;
  134. letter-spacing: 7.2rpx;
  135. background: linear-gradient(0deg, #436aff 0%, #234ff7 100%);
  136. border-radius: 50rpx;
  137. border: 0;
  138. color: #F7F7F7;
  139. line-height: 100rpx;
  140. }
  141. .login-change {
  142. display: flex;
  143. justify-content: space-between;
  144. align-items: center;
  145. .checkbox-zhanghao {
  146. font-size: 24rpx;
  147. color: #565656;
  148. }
  149. }
  150. }
  151. </style>