52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
// const baseUrl = "https://api.collect.hs.hnzhwlkj.club/"; //这里放置url域名32044
|
|
// const baseUrl = "http://192.168.0.72:8083/api/v1/"; //这里放置url域名32044
|
|
const baseUrl = "http://219.157.255.213:9007/"; //这里放置url域名32044
|
|
// const baseUrl = "/api/"; //这里放置url域名32044
|
|
export function request(options){//封装的requset
|
|
let { url,data,method } = options;
|
|
data = data || {},
|
|
uni.showLoading({
|
|
title: '加载中'
|
|
});
|
|
|
|
return new Promise((resolve,rejext)=>{
|
|
uni.request({//这里是uniapp网络请求的api
|
|
url: baseUrl + url, //仅为示例,并非真实接口地址。
|
|
data,
|
|
header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('token')},
|
|
method:method||"GET",//默认请求方式是get
|
|
success: (res) => {
|
|
resolve(res)
|
|
},
|
|
complete: (data)=>{
|
|
uni.hideLoading();
|
|
}
|
|
});
|
|
})
|
|
}
|
|
export function requestx(options){//封装的requset
|
|
let { url,data,method } = options;
|
|
data = data || {};
|
|
return new Promise((resolve,rejext)=>{
|
|
uni.request({//这里是uniapp网络请求的api
|
|
url: baseUrl + url, //仅为示例,并非真实接口地址。
|
|
data,
|
|
header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('openid')},
|
|
method:method||"GET",//默认请求方式是get
|
|
success: (res) => {
|
|
resolve(res)
|
|
},
|
|
complete: (data)=>{
|
|
}
|
|
});
|
|
})
|
|
}
|
|
export function showToast(options){//封装Toast
|
|
let { title,duration,icon } = options;
|
|
uni.showToast({
|
|
title:title,
|
|
duration: 2000,
|
|
icon:icon || "none"
|
|
});
|
|
}
|