/*
* @Desc: 接口使用类
* @Author: Yomuki
* @Date: 2021-08-25 11:14:00
* @LastEditors: 曾茹菁
* @LastEditTime: 2021-08-25 11:43:24
*/
// 接口类生成对象
const apiClassObj = {
post: function () {},
get: function () {},
};
// 用户信息(vuex)
const user = {};
export default class {
// 接口code!=200时的报错信息(非httpcode)
_errorMsg;
// 接口url
_url;
// 使用的接口function
_apiFn;
// 参数
_params;
// 是否验证登录
_isLogin;
// post/get/delete/update
_method;
// reslove参数
_returnData = {
flag: false,
msg: "参数错误",
data: null,
};
// 成功返回后的处理函数
_successHandle;
// 用户参数拼接函数
_userParams;
constructor({
url = "",
params = {},
userParams = function (user) {
return {};
},
success = function (data) {
this.setData(data);
},
errMsg = "参数错误",
login = true,
method = "post",
}) {
this._url = url;
【class】接口使用类封装
最新推荐文章于 2023-03-05 20:22:36 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)