const postApi = async(getUrl,userKey,token,data)=>{ let _this = this uni.request({ url:getUrl, header: { 'Content-Type': 'application/json', //自定义请求头信息 // 'User-Agent':250, 'user-key': userKey, 'user-token':token }, method:'POST',//请求方式,必须为大写 data:data, success: (res) => { console.log(res) }, fail:function(e){ _this.$refs.uToast.show({ message: e, duration: 1000 * 2, position:'bottom', }) } }); }; //post提交 const getApi= function(getUrl,userKey,token){ let _this = this uni.request({ url:getUrl, header: { 'Content-Type': 'application/json', //自定义请求头信息 // 'User-Agent':250, 'user-key': userKey, 'user-token':token }, method:'GET',//请求方式,必须为大写 success: (res) => { return res }, fail:function(e){ _this.$refs.uToast.show({ message: e, duration: 1000 * 2, position:'bottom', }) return {code: 7000, data: data, msg: '获取失败'} } }); } export const httpApi= { postApi, getApi };