Login.vue 4.8 KB

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