提交 e6f01a89 作者: 翁进城

打包前优化

上级 f2e35d4e
......@@ -14,15 +14,6 @@ export function useUser() {
useEffect(() => {
setUserAccountId(Number(window.localStorage.getItem('userId')));
window.setUserId = (id) => {
setUserAccountId(id);
window.localStorage.setItem('userId', id);
};
//退出登录
window.logout = () => {
window.setUserId('');
}
try {
let userInfo = JSON.parse(window.localStorage.getItem('userInfo') || '') || null;
......
......@@ -6,106 +6,102 @@ import api, { Flying, SkillsType, RegionResp } from "../../../api";
interface BrushQuestionZoneType {
}
export default function index() {
const [secondDistrictInfo, setSecondDistrictInfo] = useState(
Array<RegionResp>
);
const [skills, setSkills] = useState(
Array<RegionResp>
);
const [flightSkillsList, setFlightSkillsList] = useState(Array<SkillsType>);
export default function BrushQuestionZone() {
const [secondDistrictInfo, setSecondDistrictInfo] = useState(
Array<RegionResp>
);
const [skills, setSkills] = useState(Array<RegionResp>);
const [flightSkillsList, setFlightSkillsList] = useState(Array<SkillsType>);
const [list,setList] = useState<Array<BrushQuestionZoneType>>()
const [list, setList] = useState<Array<BrushQuestionZoneType>>();
const handleChange = (value: string) => {
console.log(`selected ${value}`);
};
useEffect(() => {
setList([{},{},{},{},{},{}])
api.region().then((res) => {
setSecondDistrictInfo(res.result || []);
});
api.PilotLicense().then((res) => {
setSkills(res.result || []);
});
api.IndustryFlightSkills().then((res) => {
const list = res.result?.map((item)=>{
item.label = item.skillsName
item.value = item.id
return item
})
setFlightSkillsList(list || []);
});
}, []);
const handleChange = (value: string) => {
console.log(`selected ${value}`);
};
useEffect(() => {
setList([{}, {}, {}, {}, {}, {}]);
api.region().then((res) => {
setSecondDistrictInfo(res.result || []);
});
api.PilotLicense().then((res) => {
setSkills(res.result || []);
});
api.IndustryFlightSkills().then((res) => {
const list = res.result?.map((item) => {
item.label = item.skillsName;
item.value = item.id;
return item;
});
setFlightSkillsList(list || []);
});
}, []);
return (
<Box>
<div className="title">
<Cascader
allowClear
placeholder="地域"
className="selectItem"
size="large"
fieldNames={{
label: "name",
value: "id",
children: "childInfo",
}}
options={secondDistrictInfo}
// onChange={onChange}
changeOnSelect
/>
<Cascader
allowClear
placeholder="考证"
className="selectItem"
size="large"
fieldNames={{
label: "licenseType",
value: "id",
children: "childLicenses",
}}
options={skills}
// onChange={onChange}
changeOnSelect
/>
<Select
className="selectItem"
popupMatchSelectWidth={false}
placeholder="技能"
size="large"
// onChange={(value) => onProvinceChange(value, "技能")}
options={flightSkillsList}
fieldNames={{ value: "id", label: "skillsName" }}
allowClear
/>
<Cascader
allowClear
placeholder="选择课程"
className="selectItem"
style={{width:200}}
size="large"
fieldNames={{
label: "name",
value: "id",
children: "childInfo",
}}
options={secondDistrictInfo}
// onChange={onChange}
changeOnSelect
/>
</div>
<div className="content">
{
list?.map(item=>(
<div className='item'>
<div className='img-box'></div>
<div className='item-content'>
第一章 第1节 习题练习习题练习习题练习
</div>
</div>
))
}
</div>
<div className="title">
<Cascader
allowClear
placeholder="地域"
className="selectItem"
size="large"
fieldNames={{
label: "name",
value: "id",
children: "childInfo",
}}
options={secondDistrictInfo}
// onChange={onChange}
changeOnSelect
/>
<Cascader
allowClear
placeholder="考证"
className="selectItem"
size="large"
fieldNames={{
label: "licenseType",
value: "id",
children: "childLicenses",
}}
options={skills}
// onChange={onChange}
changeOnSelect
/>
<Select
className="selectItem"
popupMatchSelectWidth={false}
placeholder="技能"
size="large"
// onChange={(value) => onProvinceChange(value, "技能")}
options={flightSkillsList}
fieldNames={{ value: "id", label: "skillsName" }}
allowClear
/>
<Cascader
allowClear
placeholder="选择课程"
className="selectItem"
style={{ width: 200 }}
size="large"
fieldNames={{
label: "name",
value: "id",
children: "childInfo",
}}
options={secondDistrictInfo}
// onChange={onChange}
changeOnSelect
/>
</div>
<div className="content">
{list?.map((item, i) => (
<div key={i} className="item">
<div className="img-box"></div>
<div className="item-content">
第一章 第1节 习题练习习题练习习题练习
</div>
</div>
))}
</div>
</Box>
)
);
}
......@@ -5,31 +5,28 @@ interface MockExamType {
}
export default function index() {
export default function MockExam() {
const [list, setList] = useState<Array<MockExamType>>();
const [list,setList] = useState<Array<MockExamType>>()
useEffect(()=>{
setList([{},{},{},{},{},{}])
},[])
useEffect(() => {
setList([{}, {}, {}, {}, {}, {}]);
}, []);
return (
<Box>
<div className="content">
{
list?.map(item=>(
<div className='item'>
<div className='img-box'></div>
<div className='item-content'>
<div className="top">云飞手行业认证考核</div>
<div className="bottom">
<div className="user-img"></div>
<div className="application">77人报名</div>
</div>
</div>
</div>
))
}
</div>
<div className="content">
{list?.map((item, i) => (
<div key={i} className="item">
<div className="img-box"></div>
<div className="item-content">
<div className="top">云飞手行业认证考核</div>
<div className="bottom">
<div className="user-img"></div>
<div className="application">77人报名</div>
</div>
</div>
</div>
))}
</div>
</Box>
)
);
}
......@@ -14,7 +14,7 @@ interface UserInfoType {
pageSize?:number
}
export default function index() {
export default function MoreServicePoints() {
const [mapItem, setMapItem] = useState(0);
const [userPositioning, setUserPositioning] = useState<UserInfoType>();
const [markerCol, setMarkerCol] = useState<any>([]);
......@@ -25,13 +25,13 @@ export default function index() {
const AMapLoader = await import(
/* webpackChunkName: "amap" */ "@amap/amap-jsapi-loader"
);
await AMapLoader.load({
await AMapLoader.load({
key: "87b424e68754efc3ba9d11ae07475091", // 申请好的Web端开发者Key,首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: [""], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then(async (AMap) => {
Amap = AMap
Amap = AMap;
MAP = new AMap.Map("container", {
// 设置地图容器id
viewMode: "3D", // 是否为3D地图模式
......@@ -39,40 +39,42 @@ export default function index() {
center: [113.93029, 22.53291], // 初始化地图中心点位置
});
//用户定位
AMap.plugin('AMap.Geolocation', function() {
AMap.plugin("AMap.Geolocation", function () {
const geolocation = new AMap.Geolocation({
enableHighAccuracy: true,//是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:5s
position:'RB', //定位按钮的停靠位置
offset: [10, 20], //定位按钮与设置的停靠位置的偏移量,默认:[10, 20]
zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点
enableHighAccuracy: true, //是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:5s
position: "RB", //定位按钮的停靠位置
offset: [10, 20], //定位按钮与设置的停靠位置的偏移量,默认:[10, 20]
zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点
});
MAP.addControl(geolocation);
geolocation.getCurrentPosition(function(status:string,result:any){
geolocation.getCurrentPosition(function (
status: string,
result: any
) {
console.log(result);
if(status=='complete'){
onComplete(result)
}else{
onError(result)
}
if (status == "complete") {
onComplete(result);
} else {
onError(result);
}
});
});
//解析定位结果
async function onComplete(data:any) {
console.log('定位成功');
setUserPositioning(data.position)
});
//解析定位结果
async function onComplete(data: any) {
console.log("定位成功");
setUserPositioning(data.position);
// return await mapEntiy(0,data.position);
}
//解析定位错误信息
async function onError(data:any) {
}
//解析定位错误信息
async function onError(data: any) {
// message.error(`定位失败
// 失败原因排查信息:${data.message}
// 浏览器返回信息:${data.originMessage}
// `)
}
await mapEntiy(0)
}
await mapEntiy(0);
})
.catch((e) => {
console.log(e);
......@@ -81,7 +83,7 @@ export default function index() {
console.log(error);
}
};
const showPositioningInfo = async (index:number,data?:UserInfoType) => {
const showPositioningInfo = async (index: number, data?: UserInfoType) => {
const res = await api.listPositioningInfo({
lon: userPositioning?.lon || data?.lon || 113.93029,
lat: userPositioning?.lat || data?.lat || 22.53291,
......@@ -96,96 +98,103 @@ export default function index() {
const EntiyValue = addEntiy(item.jd, item.wd, item.dizhi);
markerList.push(EntiyValue);
});
setServicePoints(list)
if(markerList.length) MAP?.add(markerList);setMarkerCol([...markerList]);
setServicePoints(list);
if (markerList.length) MAP?.add(markerList);
setMarkerCol([...markerList]);
}
}
const showFlyerBitmap = async (index:number,data?:UserInfoType,pageSize?:number) => {
};
const showFlyerBitmap = async (
index: number,
data?: UserInfoType,
pageSize?: number
) => {
const res = await api.listFlyerBitmap({
lon: userPositioning?.lon || data?.lon || 113.93029,
lat: userPositioning?.lat || data?.lat || 22.53291,
pageNo:1,
pageSize: pageSize || 40
lon: userPositioning?.lon || data?.lon || 113.93029,
lat: userPositioning?.lat || data?.lat || 22.53291,
pageNo: 1,
pageSize: pageSize || 40,
});
const list = res.result?.list
const list = res.result?.list;
const markerList: any = [];
if (list?.length) {
list?.map((item) => {
const EntiyValue = addEntiy(item.lon, item.lat, item.flyerName);
markerList.push(EntiyValue);
});
setServicePoints(list)
if(markerList.length) MAP?.add(markerList);setMarkerCol(markerList)
setServicePoints(list);
if (markerList.length) MAP?.add(markerList);
setMarkerCol(markerList);
}
}
const showUavBitmap = async (index:number,data?:UserInfoType) => {
};
const showUavBitmap = async (index: number, data?: UserInfoType) => {
console.log(MAP.panTo);
const res = await api.listUavBitmap({
lon: userPositioning?.lon || data?.lon || 113.93029,
lat: userPositioning?.lat || data?.lat || 22.53291,
pageNo:1,
pageSize: 40
lon: userPositioning?.lon || data?.lon || 113.93029,
lat: userPositioning?.lat || data?.lat || 22.53291,
pageNo: 1,
pageSize: 40,
});
const list = res.result?.list
const list = res.result?.list;
const markerList: any = [];
if (list?.length) {
list?.map((item) => {
const EntiyValue = addEntiy(item.lon, item.lat, item.uavName);
markerList.push(EntiyValue);
});
setServicePoints(list)
if(markerList.length) MAP?.add(markerList);setMarkerCol(markerList)
setServicePoints(list);
if (markerList.length) MAP?.add(markerList);
setMarkerCol(markerList);
}
};
//添加点位
const mapEntiy = async (index: number, data?: UserInfoType) => {
MAP?.remove(markerCol);
if (userPositioning) {
MAP?.setCenter([userPositioning.lon, userPositioning.lat]);
}
if (index === 0) {
showPositioningInfo(index, data);
} else if (index === 1) {
showFlyerBitmap(index, data, 30);
} else if (index === 2) {
showUavBitmap(index, data);
} else {
showFlyerBitmap(index, data, 30);
}
}
//添加点位
const mapEntiy = async (index: number,data?:UserInfoType) => {
MAP?.remove(markerCol);
if (userPositioning) {
MAP?.setCenter([userPositioning.lon, userPositioning.lat]);
}
if (index === 0) {
showPositioningInfo(index,data)
}else if (index === 1) {
showFlyerBitmap(index,data,30)
} else if(index === 2) {
showUavBitmap(index,data)
}else{
showFlyerBitmap(index,data,30)
}
setMapItem(index);
};
const addEntiy = ( lon: any, lat: any, name: string) => {
if (!Amap) return;
const icons = new Amap.Icon({
size: new Amap.Size(60, 60), // 图标尺寸
image: icon.src, // Icon的图像
imageSize: new Amap.Size(60, 60) // 根据所设置的大小拉伸或压缩图片
setMapItem(index);
};
const addEntiy = (lon: any, lat: any, name: string) => {
if (!Amap) return;
const icons = new Amap.Icon({
size: new Amap.Size(60, 60), // 图标尺寸
image: icon.src, // Icon的图像
imageSize: new Amap.Size(60, 60), // 根据所设置的大小拉伸或压缩图片
});
const marker = new Amap.Marker({
position: new Amap.LngLat(lon, lat),
offset: new Amap.Pixel(-10, -10),
icon: icons, // 添加 Icon 实例
title: name,
zoom: 13
});
return marker;
};
const marker = new Amap.Marker({
position: new Amap.LngLat(lon, lat),
offset: new Amap.Pixel(-10, -10),
icon: icons, // 添加 Icon 实例
title: name,
zoom: 13,
});
return marker;
};
const moveTo = (item: any) => {
console.log(markerCol);
const moveTo = (item:any) => {
console.log(markerCol);
if (item.dizhi) {
return MAP?.setCenter([item.jd, item.wd]);
}else if (item.flyerName || item.uavName) {
return MAP?.setCenter([item.lon, item.lat]);
}
return message.warning("暂无位置信息")
if (item.dizhi) {
return MAP?.setCenter([item.jd, item.wd]);
} else if (item.flyerName || item.uavName) {
return MAP?.setCenter([item.lon, item.lat]);
}
return message.warning("暂无位置信息");
};
useEffect(() => {
(async () => {
await init();
await init();
})();
return MAP && MAP.destroy();
}, []);
......@@ -193,23 +202,46 @@ export default function index() {
return (
<Layout>
<Box>
<div className='title'>
<div onClick={() => mapEntiy(0)} className={`item ${mapItem === 0 ? "active" : ""}`}>服务网点</div>
<div onClick={() => mapEntiy(1)} className={`item ${mapItem === 1 ? "active" : ""}`}>租赁网点</div>
<div onClick={() => mapEntiy(2)} className={`item ${mapItem === 2 ? "active" : ""}`}>培训网点</div>
<div onClick={() => mapEntiy(3)} className={`item ${mapItem === 3 ? "active" : ""}`}>机构网点</div>
<div className="title">
<div
onClick={() => mapEntiy(0)}
className={`item ${mapItem === 0 ? "active" : ""}`}
>
服务网点
</div>
<div
onClick={() => mapEntiy(1)}
className={`item ${mapItem === 1 ? "active" : ""}`}
>
租赁网点
</div>
<div
onClick={() => mapEntiy(2)}
className={`item ${mapItem === 2 ? "active" : ""}`}
>
培训网点
</div>
<div
onClick={() => mapEntiy(3)}
className={`item ${mapItem === 3 ? "active" : ""}`}
>
机构网点
</div>
</div>
<div className='content'>
<div className="content">
<div className="left">
<div className="left-title">服务网点</div>
<div className="left-content">
{
servicePoints.map((item:any)=>(
<div onClick={()=>moveTo(item)} className="left-content-item" title={item.dizhi || item.flyerName || item.uavName}>
{item.dizhi || item.flyerName || item.uavName}
</div>
))
}
{servicePoints.map((item: any) => (
<div
key={item.id}
onClick={() => moveTo(item)}
className="left-content-item"
title={item.dizhi || item.flyerName || item.uavName}
>
{item.dizhi || item.flyerName || item.uavName}
</div>
))}
</div>
</div>
<div className="right">
......@@ -218,5 +250,5 @@ export default function index() {
</div>
</Box>
</Layout>
)
);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论