Browse Source

修改请求头的token

zhaowenkang/feature-20251028181547-行情页面
wangyetao 4 weeks ago
parent
commit
eae5a6ef33
  1. 2
      api/deepMate/deepMate.js
  2. 10
      pages/deepMate/deepMate.vue
  3. 17
      utils/http.js

2
api/deepMate/deepMate.js

@ -34,7 +34,7 @@ export const postIntent = (data) => {
export const postStock = (data) => {
return http({
method: 'POST',
url: '/testApi/api/coze/decodingSecond',
url: '/api/coze/decodingSecond',
data
})
}

10
pages/deepMate/deepMate.vue

@ -203,7 +203,7 @@
const { safeAreaInsets } = uni.getSystemInfoSync();
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from "vue";
import footerBar from "../../components/footerBar-cn";
import footerBar from "../../components/footerBar";
import marked from "marked"; // marked
import { onPageScroll } from "@dcloudio/uni-app";
import { postStock, postIntent } from "../../api/deepMate/deepMate";
@ -473,7 +473,7 @@ const simulateBotResponse = async (userMessage) => {
content: userMessage,
language: 'cn',
marketList: 'hk,cn,usa,my,sg,vi,in,gb',
token: "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q"
token: "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
});
console.log("res" + res);
@ -491,9 +491,9 @@ const simulateBotResponse = async (userMessage) => {
await new Promise((resolve) => setTimeout(resolve, 2000));
//
const StockInfo = await postStock({
recordId,
parentId,
stockId,
recordId: "42",
parentId: "0",
stockId:"42",
token: memberStore.userInfo?.token || '',
language: "cn",
});

17
utils/http.js

@ -1,4 +1,4 @@
import { useUserStore } from "../stores/modules/userInfo/"
import { useUserStore } from "../stores/modules/userInfo"
const baseURL = "https://hwjb.homilychart.com"
@ -32,16 +32,19 @@ const httpInterceptor = {
'source-client': 'miniapp',
// 标准头与文档头同时设置,确保兼容
'content-type': 'application/json',
// 'contentType': 'application/json',
'version': '1',
'client': client
}
//4 添加token
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
const memberStore = useUserStore()
// const token = memberStore.userInfo?.token
const token = '6d818cda701590750245ce69393f2c32'
if (token) {
options.header.Authorization = token
}
// const token = memberStore.userInfo?.token || options.data?.token
const token = '790750702588f1ea79f24dc56ccd5d8a'
if (token) {
options.header.token = token
}
// 避免误用 Authorization 头,后端要求的是 token 头
// if (options.header.Authorization) delete options.header.Authorization
return options
}
}

Loading…
Cancel
Save