api
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
const baseUrl = "https://api.collect.hs.hnzhwlkj.club/"; //这里放置url域名32044
|
||||
// const baseUrl = "http://192.168.0.72:8083/api/v1/"; //这里放置url域名32044
|
||||
// const baseUrl = "https://114.215.24.240:8106/api/v1/"; //这里放置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"
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user