代码拉取完成,页面将自动刷新
import set from '@/setting.js';
import store from './store';
// 导出域名
export const url = set.url;
export const myRequest = (options) => {
return new Promise((resolve, reject) => {
uni.request({
url: set.url + options.url,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie':options.cookie||''
},
method: options.method || 'POST',
data: options.data || {},
success: (res) => {
if (res.data.msg == 'parameter error') {
uni.showToast({
title: '必填参数缺失',
});
}else if(res.data.msg == 'sign error'){
uni.showToast({
title: '签名错误',
});
}else if(res.data.msg == 'api is closed'){
uni.showToast({
title: '未开启API,请在后台设置开启',
});
}else if(res.data.msg == 'API function is not exist'){
uni.showToast({
title: '不存在的API方法',
});
}
resolve(res);
},
// fail: (err) => {
// uni.showToast({
// title: '请求接口失败',
// });
// reject(err);
// },
});
})
};
export const apiRequest = (options) => {
return new Promise((resolve, reject) => {
uni.request({
url: 'https://api.tianapi.com' + options.url,
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: options.method || 'POST',
data: options.data || {},
success: (res) => {
resolve(res);
}
});
})
};
export const get = (options) => {
return new Promise((resolve, reject) => {
uni.request({
url: options.url,
header: options.header,
method: options.method || 'get',
data: options.data || {},
success: (res) => {
resolve(res);
}
});
})
};
export const htRequest = (options) => {
return new Promise((resolve, reject) => {
uni.request({
url: set.url + options.url,
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: options.method || 'POST',
data: options.data || {},
success: (res) => {
resolve(res);
},
fail(){
resolve(0);
}
});
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。