1
0
forked from dyf/APP

合并版本

This commit is contained in:
liub
2025-08-15 11:09:06 +08:00
parent 4df8330738
commit 6ef2bb08b9
3 changed files with 1474 additions and 1339 deletions

View File

@ -1,9 +1,12 @@
const BASE_URL = 'http://192.168.110.169:8000';
import config from '../config/index.js';
const env = 'development'; //production development //开发of线上 改这里就行
const BASE = config[env];
const request = (options) => {
console.log("options"+JSON.stringify(options))
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
return new Promise((resolve, reject) => {
// 处理GET请求参数
let url = BASE_URL + options.url;
let url = BASE.BASE_URL + options.url;
console.log("url"+url)
if (options.method === 'GET' && options.data) {
// 使用qs序列化参数
const params = Object.keys(options.data)
@ -19,11 +22,9 @@ const request = (options) => {
header: options.header || {},
timeout: 10000,
success: (res) => {
console.log("请求成功",res);
resolve(res.data);
},
fail: (err) => {
console.log("请求失败",err);
reject(err);
}
};
@ -43,7 +44,7 @@ const request = (options) => {
});
};
// 导出基础URL以便其他地方使用
export const baseURL = BASE_URL
export const baseURL = BASE.BASE_URL
export const getToken = () => uni.getStorageSync('token') // 获取token的方法
export const clientid =() => uni.getStorageSync('clientID');
export default request;