123 lines
2.4 KiB
Vue
123 lines
2.4 KiB
Vue
import { http } from '@/utils/http'; // @/ 已经映射到 ./src/
|
||
// ts对 HTTP 方法名称的大小写敏感。在 TypeScript 的类型定义中,HTTP 方法通常被定义为全大写的字符串字面量类型,如 "POST",而非"post"。
|
||
interface LoginParams {
|
||
username : string;
|
||
password : string;
|
||
captcha ?: string; //非必填字段
|
||
}
|
||
|
||
/**
|
||
* 统一的登录方法
|
||
* @param config 登录参数
|
||
* @returns 登录请求的 Promise
|
||
*/
|
||
export function loginApi(config : LoginParams) {
|
||
// 如果传了 captcha,走本地登录(/sys/login),否则走单点登录(/sys/sinopecLogin)
|
||
const url = config.captcha ? '/sys/login' : '/sys/sinopecLogin';
|
||
return http({
|
||
url,
|
||
method: 'POST',
|
||
data: config,
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 热更新
|
||
* @param
|
||
* @returns
|
||
*/
|
||
export function upDateAppApi(path : string) {
|
||
return http({
|
||
url: '/sys/common/upDateApp',
|
||
method: 'GET',
|
||
data: {
|
||
path
|
||
}
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获取是否灰化
|
||
* @param id 权限id
|
||
* @returns 0正常 1灰化
|
||
*/
|
||
export function jurisdictionApi(id : string) {
|
||
return http({
|
||
url: '/CxcJurisdiction/cxcJurisdiction/queryById',
|
||
method: 'GET',
|
||
data: {
|
||
id
|
||
}
|
||
});
|
||
}
|
||
|
||
export function getUserPermissionApi(config : object) { // 获取权限
|
||
return http({
|
||
url: '/sys/permission/getUserPermissionByToken',
|
||
method: 'GET',
|
||
data: config
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获取首页轮播图
|
||
*/
|
||
export function queryCarouselApi(config : object) {
|
||
return http({
|
||
url: '/CxcDaping/cxcDaping/list',
|
||
method: 'GET',
|
||
data: config
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 获取分类字典
|
||
*/
|
||
export function getCategoryItemsApi(pid : string) {
|
||
return http({
|
||
url: '/sys/category/findtree',
|
||
method: 'GET',
|
||
data: {
|
||
pid
|
||
}
|
||
})
|
||
}
|
||
|
||
export function getDictItemsApi(dictCode : string) { // 字典标签专用
|
||
return http({
|
||
url: `/sys/dict/getDictItems/${dictCode}`,
|
||
method: 'GET'
|
||
})
|
||
}
|
||
|
||
export function deleteFile(config : object) {//删除文件 by 闵
|
||
return http({
|
||
url: `/sys/common/deleteFileAndCache`,
|
||
method: 'GET',
|
||
data: config
|
||
})
|
||
}
|
||
|
||
/*根据经纬度获取地理位置*/
|
||
export function getLocationApi(longitude : number, latitude : number) {
|
||
return http({
|
||
url: `/sys/common/getLocation`,
|
||
method: 'GET',
|
||
data: {
|
||
longitude,
|
||
latitude
|
||
}
|
||
})
|
||
}
|
||
|
||
/*根据经纬度或城市名称获取天气信息*/
|
||
export function getWeatherApi(longitude : number, latitude : number) {
|
||
return http({
|
||
url: `/sys/common/getWeather`,
|
||
method: 'GET',
|
||
data: {
|
||
longitude,
|
||
latitude
|
||
}
|
||
})
|
||
} |