/* * @Author: Kane * @Date: 2023-03-02 14:48:35 * @LastEditors: Kane * @FilePath: /task_schedule/src/utils/account.ts * @Description: * * Copyright (c) ${2022} by Kane, All Rights Reserved. */ import { type AxiosResponse } from "axios"; import { service as instance } from "./api/request.js"; import { API_URL } from "./api/config.js"; import { cleanStaffInfo, clearCallerInfo } from "./api/localStorage.js"; // @ts-expect-error 之后再补充类型文件 import { router } from "../router/index.js"; // declare const require: any; // const { router, } = require( "../router/index.js" ); interface LoginInfo { p13account: string; password: string; } interface LoginCallerInfo { telsaler: string; } interface RequestResult { success: boolean; message: string; } interface LoginCallerResult extends RequestResult { tel_saler_code: string; tel_saler_name: string; team_code: string; team_name: string; department_code: string; department_name: string; } /** * 内勤员工登录 * @param data 内勤员工登录信息 * @returns 返回一个Promise对象,用于给调用者添加链式处理。 */ async function login( data: LoginInfo ): Promise> { return await instance.request( { method: "post", url: API_URL.URL_LOGIN, data, }); } /** * 坐席登录函数 * @param data 坐席登录信息 * @returns 返回一个Promise对象,用于给调用者添加链式处理。 */ async function loginCaller( data: LoginCallerInfo ): Promise> { return await instance.request( { method: "post", url: API_URL.URL_LOGIN_CALLER, data, }); } /** * 退出登录 */ function logout(): void { cleanStaffInfo(); clearCallerInfo(); void router.push( "/login" ); } export { type LoginInfo, type LoginCallerInfo, type LoginCallerResult, login, loginCaller, logout };