Parcourir la source

add login.js to api

DYaiu il y a 4 ans
Parent
commit
4dc13543a2
2 fichiers modifiés avec 19 ajouts et 0 suppressions
  1. 13 0
      src/api/login.js
  2. 6 0
      src/views/work/work.vue

+ 13 - 0
src/api/login.js

@@ -0,0 +1,13 @@
+import request from '@/utils/axios'
+
+export function loginByUsername(username, password) {
+    const data = {
+        username,
+        password
+    }
+    return request({
+        url: '/login',
+        method: 'post',
+        data
+    })
+}

+ 6 - 0
src/views/work/work.vue

@@ -6,11 +6,14 @@
     <el-input v-model="input" placeholder="请输入内容" />
     <el-tag>{{input}}</el-tag>
     <child :val="val" @childByValue="childByValue" />
+    <br />
+    <el-button @click="login">登入</el-button>
   </div>
 </template>
 
 <script>
 import child from "@/views/work/child";
+import { loginByUsername } from "@/api/login";
 
 export default {
   name: "work",
@@ -32,6 +35,9 @@ export default {
       console.log("bb");
       this.val = chi;
       this.input = chi;
+    },
+    login: function() {
+      loginByUsername("admin", "system");
     }
   }
 };