支持调用 yudao 后端接口

pull/8/head
YunaiV 2023-10-29 22:01:20 +08:00
parent 84b4060c73
commit d32a47b027
3 changed files with 26 additions and 0 deletions

View File

@ -51,6 +51,9 @@
if (options.page) { if (options.page) {
sheep.$router.go(decodeURIComponent(options.page)); sheep.$router.go(decodeURIComponent(options.page));
} }
// TODO
sheep.$api.app.test();
}); });
// //

View File

@ -2,6 +2,18 @@ import request from '@/sheep/request';
import { baseUrl } from '@/sheep/config'; import { baseUrl } from '@/sheep/config';
export default { export default {
// TODO 芋艿:测试
test: () =>
request({
url: '/app-api/promotion/decorate/list',
params: {
page: 1
},
custom: {
showError: false,
showLoading: false,
},
}),
// 系统初始化 // 系统初始化
init: (templateId) => init: (templateId) =>
request({ request({

View File

@ -85,6 +85,12 @@ http.interceptors.request.use(
} }
const token = uni.getStorageSync('token'); const token = uni.getStorageSync('token');
if (token) config.header['Authorization'] = 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; return config;
}, },
(error) => { (error) => {
@ -199,6 +205,11 @@ const request = (config) => {
if (config.url[0] !== '/') { if (config.url[0] !== '/') {
config.url = apiPath + config.url; 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); return http.middleware(config);
}; };