Files
estate/src/api/workflow/index.ts
2026-05-13 15:28:25 +08:00

287 lines
7.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
/**
* 查询小区概况
* @param query
* @returns {*}
*/
export const workSpaceTotalListApi = (
villageId: string
): Promise<{
totalResident: number;
totalHouse: number;
totalParking: number;
totalDevice: number;
totalMaterial: number;
totalComplaint: number;
}> => {
return request({
url: '/workSpace/totalList',
method: 'get',
params: {
villageId: villageId
}
});
};
/**
* 查询近一周报修趋势
* @param query
* @returns {*}
*/
export const workSpaceRepairTrendListApi = (
villageId: string
): Promise<
{
date: string;
count: number;
}[]
> => {
return request({
url: '/workSpace/last7DaysRepairCount',
method: 'GET',
params: {
villageId: villageId
}
});
};
/**
* 查询近一周收入趋势
* @param query
* @returns {*}
*/
export const workSpaceIncomeTrendListApi = (
villageId: string,
type: number
): Promise<
{
date: string;
income: number;
}[]
> => {
return request({
url: '/workSpace/last7DaysIncomeTrend',
method: 'GET',
params: {
villageId: villageId,
type: type
}
});
};
/**
* 查询当日天气
* @param query
* @returns {*}
*/
export const workSpaceWeatherApi = (city: string): Promise<reponseType> => {
const url = 'https://uapis.cn/api/v1/misc/weather?city=' + city + '&lang=zh';
return new Promise((resolve, reject) => {
fetch(url, {
method: 'GET'
})
.then((res) => res.json())
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
};
type reponseType = {
// 省份
'province': string;
// 城市名
'city': string;
// 区县或更细一级的行政区名称。自动按 IP 定位时更常见。
'district': string;
// 行政区划代码(部分数据源可能为空)
'adcode': string;
// 天气状况描述。默认返回中文,传 `lang=en` 时返回英文。非固定枚举。
'weather': string;
// 天气图标代码。请从[天气图标代码表](#enum-list)中查看所有可能的值。
'weather_icon': string;
// 当前温度 °C
'temperature': number;
// 风向
'wind_direction': string;
// 风力等级
'wind_power': string;
// 相对湿度 %
'humidity': number;
// 数据更新时间
'report_time': string;
// 体感温度 °Cextended=true 时返回)
'feels_like': number;
// 能见度 kmextended=true 时返回)
'visibility': number;
// 气压 hPaextended=true 时返回)
'pressure': number;
// 紫外线指数extended=true 时返回)
'uv': number;
// 当前降水量 mmextended=true 时返回)
'precipitation': number;
// 云量 %extended=true 时返回)
'cloud': number;
// 空气质量指数 0-500extended=true 时返回)
'aqi': number;
// AQI 等级 1-6extended=true 时返回)
'aqi_level': number;
// AQI 等级描述(优/良/轻度污染/中度污染/重度污染/严重污染extended=true 时返回)
'aqi_category': string;
// 主要污染物(如 PM2.5、PM10、O3 等extended=true 时返回)
'aqi_primary': string;
// 空气污染物分项数据extended=true 时返回,部分数据源可能不返回)
'air_pollutants': {
// PM2.5 μg/m³
'pm25': number;
// PM10 μg/m³
'pm10': number;
// 臭氧 μg/m³
'o3': number;
// 二氧化氮 μg/m³
'no2': number;
// 二氧化硫 μg/m³
'so2': number;
// 一氧化碳 mg/m³
'co': number;
};
// 官方气象预警列表(存在有效预警时返回)
'alerts': {
// 预警标题
'title': string;
// 预警类型,如雷电、暴雨
'type': string;
// 预警级别,如蓝色、黄色、橙色、红色
'level': string;
// 预警正文
'text': string;
// 预警发布时间
'publish_time': string;
// 发布单位
'publisher': string;
// 防御指引列表
'guidance': string[];
}[];
// 当天最高温 °Cforecast=true 时返回)
'temp_max': number;
// 当天最低温 °Cforecast=true 时返回)
'temp_min': number;
// 多天天气预报最多7天forecast=true 时返回)
'forecast': {
// 日期 YYYY-MM-DD
'date': string;
// 星期几(`lang=en` 时返回英文星期)
'week': string;
// 最高温度 °C
'temp_max': number;
// 最低温度 °C
'temp_min': number;
// 白天天气(`lang=en` 时返回英文)
'weather_day': string;
// 夜间天气(`lang=en` 时返回英文)
'weather_night': string;
// 白天风向(可选,`lang=en` 时返回英文)
'wind_dir_day': string;
// 夜间风向(可选,`lang=en` 时返回英文)
'wind_dir_night': string;
// 白天风力(可选,`lang=en` 时返回英文)
'wind_scale_day': string;
// 夜间风力(可选,`lang=en` 时返回英文)
'wind_scale_night': string;
// 白天风速 km/h可选
'wind_speed_day': number;
// 湿度 %(可选)
'humidity': number;
// 降水量 mm可选
'precip': number;
// 能见度 km可选
'visibility': number;
// 紫外线指数(可选)
'uv_index': number;
// 日出时间 HH:MM可选
'sunrise': string;
// 日落时间 HH:MM可选
'sunset': string;
}[];
// 逐小时预报最多24小时hourly=true 时返回)
'hourly_forecast': {
// 预报时间ISO8601 或 YYYY-MM-DD HH:MM
'time': string;
// 温度 °C
'temperature': number;
// 天气状况
'weather': string;
// 风向(可选)
'wind_direction': string;
// 风速 km/h可选
'wind_speed': number;
// 风力等级(可选)
'wind_scale': string;
// 湿度 %(可选)
'humidity': number;
// 降水量 mm可选
'precip': number;
// 体感温度 °C可选
'feels_like': number;
// 能见度 km可选
'visibility': number;
// 降水概率 %(可选)
'pop': number;
// 紫外线指数(可选,国内城市通常不返回)
'uv_index': number;
}[];
// 分钟级降水预报minutely=true 时返回仅国内城市可用精确到2分钟
'minutely_precip': {
// 降水描述
'summary': string;
// 更新时间
'update_time': string;
// 精确到2分钟的数据点
'data': {
// 预报时间 ISO8601
'time': string;
// 该时间点的降水量 mm
'precip': number;
// 降水类型rain / snow
'type': string;
}[];
};
// 18项生活指数indices=true 时返回),每项包含 level等级名称、brief简短描述、advice详细建议
'life_indices': LifeIndices;
};
// 1. 定义单个生活指数的基础结构
type LifeIndexItem = {
level: string;
brief: string;
advice: string;
};
// 2. 定义所有可能的键名
type LifeIndexKeys =
| 'clothing'
| 'uv'
| 'car_wash'
| 'drying'
| 'air_conditioner'
| 'cold_risk'
| 'exercise'
| 'comfort'
| 'travel'
| 'fishing'
| 'allergy'
| 'sunscreen'
| 'mood'
| 'beer'
| 'umbrella'
| 'traffic'
| 'air_purifier'
| 'pollen';
// 3. 使用映射类型自动生成完整结构
type LifeIndices = {
[K in LifeIndexKeys]: LifeIndexItem;
};