Files
xj-screen/src/components/chinaMap/chinaHooks.ts
T
2023-12-06 16:28:08 +08:00

149 lines
4.1 KiB
TypeScript

import { getAllList, getAmbulanceList } from '/@/components/chinaMap/chinaMapApi.ts';
export enum TabType {
all = '', //所有资源
youTianYiYuan = '1', //油田医院
heZuoYiYuan = '2', //合作医院
yiLiaoDian = '3', //医疗点
jiuHuChe = '4', //救护车
}
export const tabList = [
{
name: '所有资源',
type: TabType.all,
},
{
name: '油田医院',
type: TabType.youTianYiYuan,
},
{
name: '医疗点',
type: TabType.yiLiaoDian,
},
{
name: '救护车',
type: TabType.jiuHuChe,
},
{
name: '合作医院',
type: TabType.heZuoYiYuan,
},
{
name: '地方医院',
},
{
name: '直升机',
},
{
name: '急救路线',
},
];
export const helicopter = new URL('/@/assets/img/helicopter.png', import.meta.url).href;
// 直升机位置数据
export const aircraft = [
{
category: 3,
lat: 108.861377,
lon: 34.35965,
img: helicopter,
name: '直升机',
},
{
category: 3,
lat: 106.267358,
lon: 38.520079,
img: helicopter,
name: '直升机',
},
{
category: 3,
lat: 109.505282,
lon: 36.579381,
img: helicopter,
name: '直升机',
},
{
category: 3,
lat: 107.638372,
lon: 35.734218,
img: helicopter,
name: '直升机',
},
];
export function mapApiSwitch(type, params: any) {
const basicParams = {
lat: 34, //纬度34
lon: 108, //经度
};
// 全部 油田 医疗点 合作医院
if ([TabType.all, TabType.youTianYiYuan, TabType.yiLiaoDian, TabType.heZuoYiYuan].includes(type)) {
return getAllList({ ...basicParams, ...params });
}
if ([TabType.jiuHuChe].includes(type)) {
return getAmbulanceList({});
}
}
export const mapIcon1 = new URL('/@/assets/img/mapIcon1.png', import.meta.url).href;
export const mapIcon2 = new URL('/@/assets/img/mapIcon2.png', import.meta.url).href;
export const mapIcon3 = new URL('/@/assets/img/mapIcon3.png', import.meta.url).href;
export const mapIcon4 = new URL('/@/assets/img/mapIcon4.png', import.meta.url).href;
export const mapIcon5 = new URL('/@/assets/img/mapIcon5.png', import.meta.url).href;
export const mapIcon6 = new URL('/@/assets/img/mapIcon6.png', import.meta.url).href;
export const legend1 = new URL('/@/assets/img/legend1.png', import.meta.url).href;
export const legend2 = new URL('/@/assets/img/legend2.png', import.meta.url).href;
export const legend3 = new URL('/@/assets/img/legend3.png', import.meta.url).href;
export const legend4 = new URL('/@/assets/img/legend4.png', import.meta.url).href;
export const legend5 = new URL('/@/assets/img/legend5.png', import.meta.url).href;
export const legend6 = new URL('/@/assets/img/legend6.png', import.meta.url).href;
export const legendList = [
{ img: legend1, text: '油田医院' },
{ img: legend2, text: '医疗点' },
{ img: legend3, text: '救护车' },
{ img: legend4, text: '合作医院' },
{ img: legend5, text: '地方医院' },
{ img: legend6, text: '直升机' },
];
/**
* @description 秒转小时
* */
export function convertSeconds(seconds: number) {
let hours = Math.floor(seconds / 3600);
let minutes = Math.floor((seconds % 3600) / 60);
let remainingSeconds = seconds % 60;
return {
hours: hours,
minutes: minutes,
seconds: remainingSeconds,
};
}
export function getTimeStr(time: number): string {
let str = '';
const { hours, minutes } = convertSeconds(time);
if (hours) {
str += hours + '小时';
}
if (minutes) {
str += minutes + '分钟';
}
return str;
}
export function convertMetersToKilometers(meters: number): number {
let kilometers = meters / 1000;
return Math.round(kilometers * 100) / 100;
}
export function getKmStr(distance: number): string {
if (!distance) return '';
let d = convertMetersToKilometers(distance);
return d >= 1 ? d + '公里' : d * 100 + '米';
}