Răsfoiți Sursa

修改配置文件

zhaoke 3 ani în urmă
părinte
comite
61c63dfbe4
5 a modificat fișierele cu 41 adăugiri și 30 ștergeri
  1. 3 1
      public/config.js
  2. 10 2
      src/api/login.js
  3. 5 7
      src/store/modules/user.js
  4. 4 1
      src/utils/request.js
  5. 19 19
      src/views/login/index.vue

+ 3 - 1
public/config.js

@@ -1,2 +1,4 @@
 var PLATFROM_CONFIG = {};
-PLATFROM_CONFIG.baseUrl = "http://106.14.243.117:8999" // http请求地址
+PLATFROM_CONFIG.baseUrl = "http://106.14.243.117:9001" // http请求地址
+PLATFROM_CONFIG.appSecret = "40t7vcbi5bc1twyihd2dum82yn1mt1kj" //appSecret
+PLATFROM_CONFIG.appId = "unsk1w37910olf8j" //appid

+ 10 - 2
src/api/login.js

@@ -46,11 +46,19 @@ export function permission (params) {
 }
 
 //token
-export function gettoken (params) {
+export function getToken (params) {
     return request({
-        url: '/api/fs4a/GetToken',
+        url: '/api/4A/GetToken',
         method: 'post',
         data: params,
         istoken: true
     })
+}
+
+export function loginGetToken (params) {
+    return request({
+        url: '/api/4A/LoginGetToken',
+        method: 'post',
+        data: params
+    })
 }

+ 5 - 7
src/store/modules/user.js

@@ -1,7 +1,5 @@
 import { login, loginUp, getInfo } from '@/api/login'
 import { getToken, setToken, removeToken, setUserId } from '@/utils/auth'
-import { resetRouter } from '@/router'
-import { result } from 'lodash'
 
 const getDefaultState = () => {
   return {
@@ -42,7 +40,7 @@ const mutations = {
 
 const actions = {
   // user login
-  login({ commit }, userInfo) {
+  login ({ commit }, userInfo) {
     return new Promise((resolve, reject) => {
       login(userInfo).then(response => {
         const { returnData } = response
@@ -66,7 +64,7 @@ const actions = {
   },
 
   // get user info
-  getInfo({ commit, state }) {
+  getInfo ({ commit, state }) {
     return new Promise((resolve, reject) => {
 
       let data = {
@@ -87,10 +85,10 @@ const actions = {
   },
 
   // user logout
-  logout({ commit, state }) {
+  logout ({ commit, state }) {
     console.log(state)
     return new Promise((resolve, reject) => {
-      loginUp({"UserId":state.UserId,"UserType":state.UserType}).then(result => {
+      loginUp({ "UserId": state.UserId, "UserType": state.UserType }).then(result => {
         sessionStorage.removeItem("userName");
         removeToken() // must remove  token  first
         resetRouter()
@@ -110,7 +108,7 @@ const actions = {
   },
 
   // remove token
-  resetToken({ commit }) {
+  resetToken ({ commit }) {
     return new Promise(resolve => {
       removeToken() // must remove  token  first
       commit('RESET_STATE')

+ 4 - 1
src/utils/request.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 09:45:17
- * @LastEditTime: 2022-02-27 14:58:22
+ * @LastEditTime: 2022-02-27 16:01:01
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: \vue-admin-template\src\utils\request.js
@@ -28,6 +28,9 @@ const loadingInstance = Loading.service({
 // request interceptor
 service.interceptors.request.use(
   config => {
+    if (config.istoken) {
+      config.headers['appSecret'] = PLATFROM_CONFIG.appSecret
+    }
     // config.headers.common["content-type"] = "application/json"
     if (config.data) {
       config.data['OperatorId'] = getUserId()

+ 19 - 19
src/views/login/index.vue

@@ -57,7 +57,7 @@
 <script>
 import Identify from './identify.vue';
 import Dialog from "@/layout/components/Dialog/index.vue";
-import { GetCheckCode, gettoken } from '@/api/login';
+import { GetCheckCode, getToken } from '@/api/login';
 import { GetSystemSet } from "@/api/systemConfiguration";
 import { setCodeToken } from '@/utils/auth';
 export default {
@@ -93,24 +93,24 @@ export default {
     }
   },
   async created () {
-    this.getCheckCode();
-    this.getSystemSet();
-    // try {
-    //   const res = await gettoken({
-    //     'appID': 'q7kdjmmaf0kerwpf'
-    //   })
-    //   if (res.code == 0 && res.returnData.token) {
-    //     setCodeToken(res.returnData.token);
-    //     setTimeout(() => {
-    //       this.getCheckCode();
-    //       this.getSystemSet();
-    //     }, 100);
-    //   } else {
-    //     this.$message.error(res.message);
-    //   }
-    // } catch (error) {
-    //   console.log(error);
-    // }
+    // this.getCheckCode();
+    // this.getSystemSet();
+    try {
+      const res = await getToken({
+        'appID': PLATFROM_CONFIG.appId
+      })
+      if (res.code == 0 && res.returnData.token) {
+        setCodeToken(res.returnData.token);
+        setTimeout(() => {
+          this.getCheckCode();
+          this.getSystemSet();
+        }, 100);
+      } else {
+        this.$message.error(res.message);
+      }
+    } catch (error) {
+      console.log(error);
+    }
   },
   methods: {
     showPwd () {