3 Star 11 Fork 0

大彭Sir/emlog论坛项目

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
api.js 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
大彭Sir 提交于 2年前 . 评论功能完成
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);
}
});
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pengsirs/emlog-forum-project.git
git@gitee.com:pengsirs/emlog-forum-project.git
pengsirs
emlog-forum-project
emlog论坛项目
master

搜索帮助