mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-06-12 10:00:56 +08:00
优化代码
This commit is contained in:
parent
9bdc7edcfa
commit
0b0e3b1b83
@ -1,43 +1,43 @@
|
|||||||
/**
|
/**
|
||||||
业主详情页面
|
业主详情页面
|
||||||
**/
|
**/
|
||||||
(function(vc) {
|
(function (vc) {
|
||||||
vc.extends({
|
vc.extends({
|
||||||
data: {
|
data: {
|
||||||
inspectionTaskMapInfo: {
|
inspectionTaskMapInfo: {
|
||||||
datas: [],
|
datas: [],
|
||||||
map:{}
|
map: {}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_initMethod: function() {
|
_initMethod: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
_initEvent: function() {
|
_initEvent: function () {
|
||||||
vc.on('inspectionTaskMap','initMap',function(_data){
|
vc.on('inspectionTaskMap', 'initMap', function (_data) {
|
||||||
$that._queryInspectionTaskMap(_data);
|
$that._queryInspectionTaskMap(_data);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
_queryInspectionTaskMap:function(_route){
|
_queryInspectionTaskMap: function (_route) {
|
||||||
let param = {
|
let param = {
|
||||||
params: {
|
params: {
|
||||||
communityId: vc.getCurrentCommunity().communityId,
|
communityId: vc.getCurrentCommunity().communityId,
|
||||||
inspectionRouteId: _route.inspectionRouteId,
|
taskId: _route.taskId,
|
||||||
page: 1,
|
page: 1,
|
||||||
row: 1000
|
row: 1000
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//发送get请求
|
//发送get请求
|
||||||
vc.http.apiGet('/inspectionRoute.listInspectionRoutePoints',
|
vc.http.apiGet('/inspection.queryInspectionTaskDetail',
|
||||||
param,
|
param,
|
||||||
function (json) {
|
function (json) {
|
||||||
let _json = JSON.parse(json);
|
let _json = JSON.parse(json);
|
||||||
$that.inspectionTaskMapInfo.data = _json.inspectionPoints;
|
$that.inspectionTaskMapInfo.data = _json.data;
|
||||||
|
|
||||||
$that.initInspectionTaskMap(_json.inspectionPoints);
|
$that.initInspectionTaskMap(_json.data);
|
||||||
|
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
@ -45,7 +45,7 @@
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
initInspectionTaskMap:function(_pos) {
|
initInspectionTaskMap: function (_pos) {
|
||||||
let _lng = 116.307484;
|
let _lng = 116.307484;
|
||||||
let _lat = 39.984120;
|
let _lat = 39.984120;
|
||||||
// _pos.forEach(_m => {
|
// _pos.forEach(_m => {
|
||||||
@ -53,10 +53,16 @@
|
|||||||
|
|
||||||
// });
|
// });
|
||||||
|
|
||||||
if (_pos && _pos.length > 0) {
|
if (!_pos || _pos.length < 1) {
|
||||||
_lat = _pos[0].lat;
|
return;
|
||||||
_lng = _pos[0].lng;
|
|
||||||
}
|
}
|
||||||
|
_pos.forEach(_p => {
|
||||||
|
if (_p.lat) {
|
||||||
|
_lat = _p.lat;
|
||||||
|
_lng = _p.lng;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
let center = new TMap.LatLng(_lat, _lng)
|
let center = new TMap.LatLng(_lat, _lng)
|
||||||
//定义map变量,调用 TMap.Map() 构造函数创建地图
|
//定义map变量,调用 TMap.Map() 构造函数创建地图
|
||||||
@ -72,13 +78,13 @@
|
|||||||
$that.inspectionTaskMapInfo.map = map;
|
$that.inspectionTaskMapInfo.map = map;
|
||||||
$that._addTaskPointMachine(_pos);
|
$that._addTaskPointMachine(_pos);
|
||||||
},
|
},
|
||||||
_addTaskPointMachine:function(_pos) {
|
_addTaskPointMachine: function (_pos) {
|
||||||
let _geometriesMarker = [];
|
let _geometriesMarker = [];
|
||||||
let _geometriesLabel = [];
|
let _geometriesLabel = [];
|
||||||
let _path = [];
|
let _path = [];
|
||||||
|
|
||||||
_pos.forEach(_m => {
|
_pos.forEach(_m => {
|
||||||
try{
|
try {
|
||||||
let center = new TMap.LatLng(_m.lat, _m.lng);
|
let center = new TMap.LatLng(_m.lat, _m.lng);
|
||||||
_geometriesMarker.push({
|
_geometriesMarker.push({
|
||||||
"id": _m.inspectionId, //点标记唯一标识,后续如果有删除、修改位置等操作,都需要此id
|
"id": _m.inspectionId, //点标记唯一标识,后续如果有删除、修改位置等操作,都需要此id
|
||||||
@ -91,10 +97,10 @@
|
|||||||
'styleId': 'label', //样式id
|
'styleId': 'label', //样式id
|
||||||
'position': center, //标注点位置
|
'position': center, //标注点位置
|
||||||
// 'content': _m.staffName, //标注文本
|
// 'content': _m.staffName, //标注文本
|
||||||
'content':_m.inspectionName
|
'content': _m.inspectionName
|
||||||
});
|
});
|
||||||
_path.push(center);
|
_path.push(center);
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -115,7 +121,7 @@
|
|||||||
geometries: _geometriesMarker
|
geometries: _geometriesMarker
|
||||||
});
|
});
|
||||||
|
|
||||||
var label = new TMap.MultiLabel({
|
let label = new TMap.MultiLabel({
|
||||||
id: 'label-layer',
|
id: 'label-layer',
|
||||||
map: $that.inspectionTaskMapInfo.map, //设置折线图层显示到哪个地图实例中
|
map: $that.inspectionTaskMapInfo.map, //设置折线图层显示到哪个地图实例中
|
||||||
//文字标记样式
|
//文字标记样式
|
||||||
@ -133,7 +139,7 @@
|
|||||||
geometries: _geometriesLabel
|
geometries: _geometriesLabel
|
||||||
});
|
});
|
||||||
|
|
||||||
var polylineLayer = new TMap.MultiPolyline({
|
let polylineLayer = new TMap.MultiPolyline({
|
||||||
id: 'polyline-layer', //图层唯一标识
|
id: 'polyline-layer', //图层唯一标识
|
||||||
map: $that.inspectionTaskMapInfo.map,//设置折线图层显示到哪个地图实例中
|
map: $that.inspectionTaskMapInfo.map,//设置折线图层显示到哪个地图实例中
|
||||||
//折线样式定义
|
//折线样式定义
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user