Quellcode durchsuchen

初始化登录接口

DESKTOP-6LTVLN7\Liumouren vor 2 Jahren
Ursprung
Commit
9cdcdd2225
4 geänderte Dateien mit 45 neuen und 19 gelöschten Zeilen
  1. 2 1
      src/main.js
  2. 4 3
      src/utils/request.js
  3. 30 14
      src/views/Login.vue
  4. 9 1
      vue.config.js

+ 2 - 1
src/main.js

@@ -13,9 +13,10 @@ import SvgIcon from '@/components/SvgIcon'
 Vue.component('svg-icon', SvgIcon);
 import $ from "jquery";
 import { drag } from "./directives/drag";
+import { post } from "./utils/request.js";
 
 Vue.directive("drag", drag);
-
+Vue.prototype.$Post = post;
 Vue.config.productionTip = false;
 
 Vue.use(ElementUI);

+ 4 - 3
src/utils/request.js

@@ -7,10 +7,10 @@ import {
 
 // 创建 axios 实例
 const service = axios.create({
-  baseURL: '',
+  // baseURL: 'http://121.43.55.7:8888',
   timeout: 60000, // 请求超时时间,
   headers: {
-    'Content-Type': 'application/json'
+    'Content-Type': 'application/form-data'
   }
 })
 
@@ -102,7 +102,8 @@ function post(url, data) {
       url,
       data: data,
       headers: {
-        'Content-Type': 'application/json;'
+        'token': localStorage.getItem('TOKEN'),
+        'Content-Type': 'multipart/form-data;'
       }
     }).then(res => {
       resolve(res)

+ 30 - 14
src/views/Login.vue

@@ -35,7 +35,7 @@
           />
         </svg>
       </el-input>
-      <el-input placeholder="密码"  type="password" autocomplete="off" v-model="password">
+      <el-input placeholder="密码" type="password" autocomplete="off" v-model="password">
         <svg
           class="loginInputIcon"
           slot="prefix"
@@ -120,19 +120,35 @@ export default {
         this.$message.info("请输入密码");
         return false;
       }
-      // 登录校验成功后
-      if (this.RememberYourPassword) {
-        localStorage.setItem("RememberYourPassword", true);
-        localStorage.setItem("_USER_NAME", this.userName);
-        localStorage.setItem("_PASSWORD", publicFun.Encrypt(this.password));
-      }
-      this.$router.push("/");
-      const h = this.$createElement;
-
-      this.$notify({
-        title: "登录成功",
-        message: h("i", { style: "color: teal" }, this.userName + ",欢迎回来!")
-      });
+      let param = new FormData();
+      param.append("userName", this.userName);
+      param.append("password", this.password);
+      param.append("clientId", "1");
+      this.$Post("/oauth/user/login", param).then(
+        res => {
+          // 登录成功
+          if (res.code == 200) {
+            // 登录校验成功后
+            if (this.RememberYourPassword) {
+              localStorage.setItem("RememberYourPassword", true);
+              localStorage.setItem("_USER_NAME", this.userName);
+              localStorage.setItem("_PASSWORD", publicFun.Encrypt(this.password));
+            }
+            localStorage.setItem("TOKEN", res.message);
+            this.$router.push("/");
+            const h = this.$createElement;
+            this.$notify({
+              title: "登录成功",
+              message: h("i", { style: "color: teal" }, this.userName + ",欢迎回来!")
+            });
+          } else {
+            this.$message.error(res.message);
+          }
+        },
+        error => {
+          console.log(error);
+        }
+      );
     },
     forgetYouPassword() {
       this.$message.info("正在开发中,敬请期待!");

+ 9 - 1
vue.config.js

@@ -29,6 +29,14 @@ module.exports = {
       .end();
   },
   devServer: {
-    port: 2014
+    port: 2014,
+    proxy: {
+      "/oauth": {
+        target: "http://121.43.55.7:8888",
+      },
+      "/proxy_dms": {
+        target: "http://121.43.55.7:2101",
+      }
+    }
   }
 }