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