From d32a47b027930dfed9b084d068a3e4245bf275ee Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Oct 2023 22:01:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B0=83=E7=94=A8=20yudao=20?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 3 +++ sheep/api/app.js | 12 ++++++++++++ sheep/request/index.js | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/pages/index/index.vue b/pages/index/index.vue index b1928c9..8d953c6 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -51,6 +51,9 @@ if (options.page) { sheep.$router.go(decodeURIComponent(options.page)); } + + // TODO 芋艿:测试接口的调用 + sheep.$api.app.test(); }); // 下拉刷新 diff --git a/sheep/api/app.js b/sheep/api/app.js index 026caca..7099047 100644 --- a/sheep/api/app.js +++ b/sheep/api/app.js @@ -2,6 +2,18 @@ import request from '@/sheep/request'; import { baseUrl } from '@/sheep/config'; export default { + // TODO 芋艿:测试 + test: () => + request({ + url: '/app-api/promotion/decorate/list', + params: { + page: 1 + }, + custom: { + showError: false, + showLoading: false, + }, + }), // 系统初始化 init: (templateId) => request({ diff --git a/sheep/request/index.js b/sheep/request/index.js index d1d3408..8fb4461 100644 --- a/sheep/request/index.js +++ b/sheep/request/index.js @@ -85,6 +85,12 @@ http.interceptors.request.use( } const token = uni.getStorageSync('token'); if (token) config.header['Authorization'] = token; + // TODO 芋艿:特殊处理 + if (config.url.indexOf('/app-api/') !== -1) { + config.header['Accept'] = '*/*' + config.header['tenant-id'] = '1'; + config.header['Authorization'] = 'Bearer test247'; + } return config; }, (error) => { @@ -199,6 +205,11 @@ const request = (config) => { if (config.url[0] !== '/') { config.url = apiPath + config.url; } + // TODO 芋艿:额外拼接 + if (config.url.indexOf('/app-api/') >= 0) { + config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 + // config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 + } return http.middleware(config); };