Login.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-01-11 11:14:26
  4. * @LastEditTime: 2022-04-28 18:35:39
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: \vue3-element-admin\src\views\Login.vue
  8. -->
  9. <template>
  10. <div class="backdrop-layer">
  11. <div class="head">
  12. <div class="logo"></div>
  13. <div class="title">飞鸟智慧确权平台
  14. </div>
  15. </div>
  16. <div class="ve_container">
  17. <el-card style="height: 300px" :body-style="{ background: '#ffffff' }">
  18. <h1>用户登录</h1>
  19. <transition name="el-fade-in-linear">
  20. <el-form
  21. :model="form"
  22. :rules="rules"
  23. v-show="!success"
  24. class="ve_form"
  25. ref="ref_form"
  26. :inline="false"
  27. @keyup.enter="onSubmit"
  28. >
  29. <el-form-item prop="phone">
  30. <el-input
  31. size="large"
  32. v-model.trim="phone"
  33. placeholder="用户名"
  34. >
  35. <template #prepend>
  36. <el-icon :size="20"><Iphone /></el-icon>
  37. </template>
  38. </el-input>
  39. </el-form-item>
  40. <el-form-item prop="code">
  41. <el-input
  42. size="large"
  43. v-model.trim="code"
  44. placeholder="验证码"
  45. >
  46. <template #prepend>
  47. <el-icon :size="20"><Key /></el-icon>
  48. </template>
  49. </el-input>
  50. </el-form-item>
  51. <el-form-item>
  52. <div style="width: 50%;float: left;text-align: left;"><el-checkbox >记住密码</el-checkbox></div>
  53. <div style="width: 50%;float: left;">
  54. <el-button
  55. class="ve_submit"
  56. type="primary"
  57. @click="onSubmit"
  58. >
  59. 登录
  60. </el-button>
  61. </div>
  62. </el-form-item>
  63. </el-form>
  64. </transition>
  65. </el-card>
  66. </div>
  67. </div>
  68. </template>
  69. <script setup>
  70. import {SET_TOKEN, SET_UNAME, SET_USER_INFO} from "@/store/modules/app/type";
  71. import Common from "@/components/Common";
  72. import { ref, reactive, toRefs } from "vue";
  73. import { useStore } from "vuex";
  74. import { useRouter } from "vue-router";
  75. const rules = {
  76. phone: [{ required: true, message: "请输入用户名", trigger: "blur" }]
  77. };
  78. // const rules = {
  79. // phone: [{ required: true, message: "请输入用户名", trigger: "blur" }]
  80. // ,
  81. // code: [{ required: true, message: "请输入验证码", trigger: "blur" }
  82. // ],
  83. // };
  84. const store = useStore();
  85. const router = useRouter();
  86. const form = reactive({
  87. "code": "",
  88. "phone": "13797066447"
  89. });
  90. const { phone, code } = toRefs(form);
  91. const ref_form = ref(null);
  92. const success = ref(false);
  93. sessionStorage.clear();
  94. store.commit(`app/${SET_TOKEN}`, "");
  95. router.options.isAddDynamicMenuRoutes = false;
  96. const onSubmit = () => {
  97. ref_form.value.validate(async (valid) => {
  98. if (valid) {
  99. const res = await VE_API.system.phoneLogin(form);
  100. if (res.code == 0) {
  101. const { token, userName, djiCloudToken } = res.data;
  102. store.commit(`app/${SET_TOKEN}`, token);
  103. store.commit(`app/djiCloudToken`, djiCloudToken);
  104. store.commit(`app/${SET_UNAME}`, userName);
  105. res.data["token"] = undefined
  106. res.data["x-auth-token"] = undefined
  107. res.data["pwd"] = undefined
  108. store.commit(`app/${SET_USER_INFO}`, JSON.stringify(res.data));
  109. success.value = true;
  110. router.push({ name: "Home" });
  111. }
  112. } else {
  113. return;
  114. }
  115. });
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .ve_container {
  120. position: absolute;
  121. z-index: 1;
  122. width: 400px;
  123. top: calc(50%);
  124. left: calc(50% - 250px);
  125. transform: translateY(-50%);
  126. transition: all 1s;
  127. min-height: 273px;
  128. text-align: center;
  129. h1 {
  130. font-size: 24px;
  131. transition: all 1s;
  132. font-weight: normal;
  133. text-align: left;
  134. margin-bottom: 36px;
  135. }
  136. .ve_form {
  137. .ve_submit {
  138. width: 100%;
  139. height: 45px;
  140. background: #0BC678;
  141. }
  142. }
  143. }
  144. .backdrop-layer{
  145. position: absolute;
  146. top: 0px;
  147. bottom: 0px;
  148. left: 0px;
  149. right: 0px;
  150. background: url(@/assets/login_bg.jpg) no-repeat;
  151. background-size:100% 100%;
  152. z-index: 1;
  153. overflow: hidden;
  154. }
  155. .head{
  156. position: absolute;
  157. left: 300px;
  158. top: 100px;
  159. display: flex;
  160. align-items: center;
  161. padding: 50px;
  162. .title{
  163. font-size: 30px;
  164. font-weight: bold;
  165. color:#006600;
  166. float: left;
  167. line-height: 50px;
  168. margin-left: 20px;
  169. }
  170. .logo{
  171. width: calc(167px * 0.5);
  172. height: calc(245px * 0.5);
  173. background: url(@/assets/img/logo-verticle.png) no-repeat;
  174. background-size:100% 100%;
  175. float: left;
  176. z-index: 1000;
  177. }
  178. }
  179. </style>