/**
 * 此处填写文件描述
 * @Author: huangjq
 * @Date:   2019-10-14
 * @Project jz
 */
import DCISLoginApi from "./DCISLogin";
import Oauth2Login from "./Oauth2Login.js";
const { getSettingBool } = window.systemParamsUtils;

class LoginApi {
    api = null;

    constructor() {
        if (getSettingBool("IS_OAUTH2")) {
            this.api = new Oauth2Login();
        } else {
            this.api = new DCISLoginApi();
        }
    }

    /**
     * 判断是否登录
     */
    judgeIsLogin(response) {
        return this.api.judgeIsLogin(response);
    }

    /**
     * 登出
     */
    logout(pageObj) {
        return this.api.logout(pageObj);
    }

    /**
     * 发起请求之前执行
     */
    beforeRequest(config) {
        return this.api.beforeRequest(config);
    }

    /**
     * 请求成功之后的回调
     */
    afterResponseSuccess(response) {
        return this.api.afterResponseSuccess(response);
    }

    /**
     * 请求失败的回调
     */
    afterResponseFailed(error) {
        return this.api.afterResponseFailed(error);
    }
}

window.loginUtil = new LoginApi();
// export default LoginApi;
