Эх сурвалжийг харах

支持调用 yudao 后端接口

YunaiV 1 жил өмнө
parent
commit
d32a47b027

+ 3 - 0
pages/index/index.vue

@@ -51,6 +51,9 @@
     if (options.page) {
       sheep.$router.go(decodeURIComponent(options.page));
     }
+
+    // TODO 芋艿:测试接口的调用
+    sheep.$api.app.test();
   });
 
   // 下拉刷新

+ 12 - 0
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({

+ 11 - 0
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);
 };