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.

162 lines
3.3 KiB

  1. <template>
  2. <div class="container">
  3. <div class="loginContainer">
  4. <img
  5. class="backgroundImg"
  6. src="https://d31zlh4on95l9h.cloudfront.net/assets/registerHw.png"
  7. alt=""
  8. />
  9. <div class="loginWindow">
  10. <input type="text" class="username" v-model="userInfo.username" />
  11. <input type="password" class="password" v-model="userInfo.password" />
  12. <div class="policy">
  13. <el-checkbox-group v-model="agree">
  14. <el-checkbox value="1" />
  15. </el-checkbox-group>
  16. <span class="hasAgreed">我已阅读并同意</span>
  17. <span class="privacy">隐私条款</span>
  18. </div>
  19. <div class="login" @click="login">登录</div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script setup>
  25. import { useRouter } from "vue-router";
  26. import { ref, watch } from "vue";
  27. import { ElMessageBox, ElMessage } from "element-plus";
  28. import { fakeLinkDataListStore } from "../../store/fakeLink-dataList";
  29. const fakeLinkDataStore = fakeLinkDataListStore();
  30. const router = useRouter();
  31. const agree = ref([]);
  32. const userInfo = ref({
  33. username: "",
  34. password: "",
  35. });
  36. const login = () => {
  37. if (!userInfo.value.username) {
  38. ElMessage.error("请输入用户名");
  39. return;
  40. }
  41. if (!userInfo.value.password) {
  42. ElMessage.error("请输入密码");
  43. return;
  44. }
  45. if (agree.value.length !== 1) {
  46. ElMessage.error("请同意协议");
  47. return;
  48. }
  49. const res = fakeLinkDataStore.getUserInfo(
  50. userInfo.value.username,
  51. userInfo.value.password
  52. );
  53. if (res == 200) {
  54. ElMessage.success("登录成功");
  55. router.push("fakeLink");
  56. } else {
  57. ElMessage.error("用户名或密码不正确");
  58. }
  59. };
  60. </script>
  61. <style scoped>
  62. .container {
  63. width: 100%;
  64. height: 100%;
  65. background-image: url("https://cdn.legu168.com/jtzy/Product/pcjingwang/images/login_bg_7584f6a.png");
  66. background-size: 100% 100%;
  67. background-repeat: no-repeat;
  68. /* padding-top: 100px; */
  69. }
  70. .loginContainer {
  71. position: relative;
  72. display: flex;
  73. /* width: 100%; */
  74. /* height: 50%; */
  75. justify-content: center;
  76. padding-top: 30px;
  77. }
  78. .backgroundImg {
  79. width: 630px;
  80. height: auto;
  81. position: absolute;
  82. }
  83. .loginWindow {
  84. margin-top: 230px;
  85. background-color: rgba(255, 255, 255, 0.9);
  86. padding: 28px 50px;
  87. width: 400px;
  88. box-sizing: border-box;
  89. display: flex;
  90. flex-direction: column;
  91. z-index: 2;
  92. }
  93. .username {
  94. width: 300px;
  95. height: 38px;
  96. margin-bottom: 10px;
  97. box-sizing: border-box;
  98. font-size: 16px;
  99. padding-left: 10px;
  100. border: 1px solid rgb(221, 221, 221);
  101. outline: none;
  102. }
  103. .username:focus {
  104. border: 1px solid #409eff; /* 聚焦时的边框颜色 */
  105. }
  106. .password {
  107. width: 300px;
  108. height: 38px;
  109. margin-bottom: 10px;
  110. box-sizing: border-box;
  111. font-size: 16px;
  112. padding-left: 10px;
  113. border: 1px solid rgb(221, 221, 221);
  114. outline: none;
  115. }
  116. .password:focus {
  117. border: 1px solid #409eff; /* 聚焦时的边框颜色 */
  118. }
  119. .policy {
  120. display: flex;
  121. align-items: center;
  122. font-size: 14px;
  123. }
  124. .hasAgreed {
  125. margin-right: 5px;
  126. }
  127. .privacy {
  128. color: rgb(64, 101, 153);
  129. cursor: pointer;
  130. }
  131. .privacy:hover {
  132. color: red;
  133. }
  134. .login {
  135. width: 100%;
  136. height: 38px;
  137. color: white;
  138. background-color: rgb(248, 89, 89);
  139. font-size: 18px;
  140. margin: 20px 0px;
  141. display: flex;
  142. justify-content: center;
  143. align-items: center;
  144. cursor: pointer;
  145. }
  146. </style>