Login.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <main>
  3. <section>
  4. <header>
  5. <img src="@/assets/login.png" />
  6. <p>欢迎使用</p>
  7. </header>
  8. <p>账号登录</p>
  9. <section>
  10. <p>账号</p>
  11. <div>
  12. <a-input placeholder="请输入手机号" :style="{ width: '250px', height: '40px' }" v-model="username">
  13. </a-input>
  14. </div>
  15. </section>
  16. <section>
  17. <p>密码</p>
  18. <div>
  19. <a-input-password
  20. placeholder="请输入手机号"
  21. :style="{ width: '250px', height: '40px' }"
  22. v-model="password"
  23. >
  24. </a-input-password>
  25. </div>
  26. </section>
  27. <section><p style="cursor: pointer" @click="goRegister">去注册</p></section>
  28. <div @click="login">登录</div>
  29. </section>
  30. </main>
  31. </template>
  32. <script>
  33. import { defineComponent, ref, inject } from "vue";
  34. export default defineComponent({
  35. components: {},
  36. props: [],
  37. setup() {
  38. const { ajax, helper } = inject("$global");
  39. const username = ref("user");
  40. const password = ref("123");
  41. const login = async () => {
  42. const result = await ajax.user.login(username.value, password.value);
  43. if (result) {
  44. helper.write("userName", result.nickname || result.username);
  45. helper.write("token", result.access_token);
  46. helper.goLink("/");
  47. }
  48. };
  49. const goRegister = () => {
  50. helper.goLink("register");
  51. };
  52. return {
  53. login,
  54. username,
  55. password,
  56. goRegister
  57. };
  58. }
  59. });
  60. </script>
  61. <style scoped>
  62. main {
  63. width: 100vw;
  64. height: 100vh;
  65. align-items: center;
  66. justify-content: center;
  67. display: flex;
  68. position: relative;
  69. > p {
  70. position: absolute;
  71. bottom: 30px;
  72. color: rgba(153, 153, 153, 1);
  73. font-size: 14px;
  74. }
  75. > section {
  76. width: 640px;
  77. border-radius: 12px;
  78. background-color: rgba(255, 255, 255, 0.52);
  79. box-shadow: 0px 2px 20px -2px rgba(0, 0, 0, 0.1);
  80. border: 1px solid rgba(187, 187, 187, 1);
  81. > header {
  82. height: 130px;
  83. background-color: rgba(65, 95, 235, 0.05);
  84. position: relative;
  85. img {
  86. height: 130px;
  87. position: absolute;
  88. top: 0;
  89. right: 0;
  90. }
  91. p {
  92. height: 130px;
  93. line-height: 130px;
  94. position: absolute;
  95. left: 30px;
  96. z-index: 2;
  97. color: rgba(51, 51, 51, 1);
  98. font-size: 36px;
  99. font-weight: bold;
  100. }
  101. }
  102. > p {
  103. text-align: center;
  104. &:nth-child(2) {
  105. margin: 60px 0 10px 0;
  106. color: rgba(16, 16, 16, 1);
  107. font-size: 28px;
  108. font-weight: bold;
  109. }
  110. &:nth-child(3) {
  111. color: rgba(102, 102, 102, 1);
  112. font-size: 18px;
  113. }
  114. }
  115. > section {
  116. display: flex;
  117. justify-content: center;
  118. margin-top: 20px;
  119. > p {
  120. display: flex;
  121. align-items: center;
  122. margin-right: 10px;
  123. }
  124. }
  125. > div {
  126. width: 332px;
  127. height: 40px;
  128. border-radius: 4px;
  129. background-color: rgba(64, 95, 234, 1);
  130. color: rgba(255, 255, 255, 1);
  131. font-size: 14px;
  132. text-align: center;
  133. box-shadow: 0px 2px 6px -2px rgba(64, 95, 234, 0.53);
  134. line-height: 40px;
  135. border: 1px solid rgba(64, 95, 234, 1);
  136. margin: 30px auto;
  137. cursor: pointer;
  138. &:hover {
  139. background-color: rgba(64, 95, 234, 0.8);
  140. }
  141. }
  142. > span {
  143. display: block;
  144. widows: 100%;
  145. text-align: center;
  146. margin-bottom: 30px;
  147. }
  148. }
  149. }
  150. </style>