var Constant = require('../utils/constant.js'); var app = getApp(); import Request from "../utils/api" Page({ data: { scrollHeight: wx.getSystemInfoSync().windowHeight, DrawerName: '', mapType: '2D', //地图类型 isShowMapLayer: 'true', //地图图层显示或者隐藏 isShowRightBtn: 'true', //地图右侧图层按钮显示活隐藏 isLoactionShow: 'true', //回到当前位置图标是否显示 isScaleShow: 'true', //地图缩放按钮图标是否显示 isLoad:false, //地图信息 mapInfo: { mapCenterLatitude: 31.09814, //地图中心经纬度 mapCenterLongitude: 120.437185, markers: [], //标记marker map Station: [], //泵站列表 scale: 10, //地图放大比例 pointsList: [], //所有marker的经纬度 DMA: [], //DMA marker: {}, map3D: false, //3d地图 overlooking: false, //俯视图 satellite: false, //卫星图 showLocation: true, //显示带有方向的当前定位点 enableZoom: true, //是否支持缩放 enableScroll: true, //是否支持拖动 traffic: false, //路况 }, //查询数据(地图) isShowsearchMarkList: false, searchMarkList: [], animationSearchBar: "", searchKeyWrd: "", currentCorpID: 1, currentUserID: 1, //当前用户ID stationID: '', //泵站id modalName: '', //模态框抓状态 stationIDs: [], //所有泵站id集合 link_box: false, //资产、监控、bim跳转条显/隐 tuceng_active: false, //图层按钮显示隐藏 marker_layer: { RepairForm: true, PressMeter: true, DmaArea: true, FlowMeter: true, Station: true, QualityMeter: true, }, mapId: 'detailMap', //地图id drawerMenuMoveData: { y: wx.getSystemInfoSync().windowHeight * 0.2 * -1 - 5, //当前底部抽屉拉出的高度 bottom: -(wx.getSystemInfoSync().windowHeight * 0.40 * wx.getSystemInfoSync().pixelRatio), //当前底部抽屉的最低高度 sysHeight: wx.getSystemInfoSync().windowHeight, //当前窗口的高度 pixelRatio: wx.getSystemInfoSync().pixelRatio, //px转rpx的倍数 icon: 'move', startTouchY: '', //点击拖动的Y status: '1', //抽屉当前的状态 0:完全收缩 ,1:正常拉出,2:完全拉出 height: wx.getSystemInfoSync().windowHeight * 0.57 * wx.getSystemInfoSync().pixelRatio }, meunList: [{ type: 1, name: '今日巡检', icon: 'icon-xunjiandian', color: 'green' }, { type: 2, name: '巡检记录', icon: 'icon-lishi2', color: 'yellow' }, { type: 3, name: '报修', icon: 'icon-zengjia', color: 'green' }, { type: 4, name: '报修记录', icon: 'icon-wangshangbaoming', color: 'blue' }, { type: 5, name: '更多', icon: 'icon-icon-test1', color: 'olive' }, ] }, onLoad: function (options) { // console.log(wx.getSystemInfoSync()) // console.log(wx.getSystemInfoSync().windowHeight * 0.2 * -1 - 10) var userInfo = app.globalData.userInfo; // console.log(userInfo) if (userInfo) { this.setData({ currentCorpID: userInfo.CorpID, currentUserID: userInfo.EmployeeID }); } else { wx.navigateTo({ url: '/login/login/index', }); return; } // console.log(userInfo) //获取地图信息 this.getRepairFormList()//获取工单 this.getPressMeterList() this.getFlowMeterList() this.getStationList() this.getDmaAreaList() // //使所有的标记都在视野中 this.setIncludePoints(); }, onReady: function () { }, //展示所有marker标点的视野 setIncludePoints() { var MapContext = wx.createMapContext('detailMap'); MapContext.includePoints({ points: this.data.mapInfo.pointsList, padding: [100, 100, 100, 100], success: function (res) { //console.log('获取所有标点成功',res) } }) }, //获取地图展示的基本信息 getMapInfo: function () { var that=this that.setData({ 'mapInfo.mapCenterLatitude': 31.121743, 'mapInfo.mapCenterLongitude': 120.287392, }) }, //获取工单列表 getRepairFormList: function () { var that = this; wx.showLoading({ title: '加载中...' }); Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetRepairList@V1.0", method: 'GET', header: { 'content-type': 'application/json' }, fail: function (err) { console.log(err) wx.hideLoading(); wx.showModal({ title: '', content: '通讯失败', }) }, //请求失败 success: function (res) { wx.hideLoading(); // console.log(res.data,"获取工单") var result = res.data; if (result.Code != 0) { wx.showModal({ title: '', content: result.Message, }); return; } //console.log(result) //return var markers = []; var pointsList = []; if (result.Data == null) { result.Data = [] } for (var i = 0; i < result.Data.length; i++) { var item = result.Data[i]; var mark = {}; var callout = {}; if(item.Position){ mark.longitude = item.Position.Point.X; mark.latitude = item.Position.Point.Y; mark.title = item.FormName; mark.id = parseInt(item.FormID); mark.content = item.Position.Address; mark.width = 32; mark.height = 32; mark.iconPath = "/images/map/gongdan_blue.png"; mark.markerInfo = item mark.zIndex = 10; if (item.ID == 3) { mark.zIndex = 100; } mark.markerType = 'RepairForm' callout.content = item.FormName; callout.display = 'ALWAYS'; callout.padding = 5; callout.borderRadius = 10; callout.borderWidth = 1; callout.borderColor = '#999'; mark.callout = callout; markers.push(mark); pointsList.push({ longitude: item.Position.Point.X, latitude: item.Position.Point.Y }); } } var oldMarkers = that.data.mapInfo.markers; var newMarkers = oldMarkers.concat(markers); var oldPointsList = that.data.mapInfo.pointsList; var newPointsList = oldPointsList.concat(pointsList); that.setData({ 'mapInfo.markers': newMarkers, 'mapInfo.pointsList': newPointsList, 'mapInfo.marker.RepairForm': markers, }); // console.log(newMarkers) } }); }, //获取压力计列表 getPressMeterList:function(){ var that = this; wx.showLoading({ title: '加载中...' }); Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetPressMeterList@V1.0", method: 'GET', header: { 'content-type': 'application/json' }, fail: function (err) { console.log(err) wx.hideLoading(); wx.showModal({ title: '', content: '通讯失败', }) }, //请求失败 success: function (res) { wx.hideLoading(); // console.log(res.data,"获取压力计") var result = res.data; if (result.Code != 0) { wx.showModal({ title: '', content: result.Message, }); return; } var markers = []; var pointsList = []; var PressMeter=[] if (result.Data == null) { result.Data = [] } for (var i = 0; i < result.Data.length; i++) { var item = result.Data[i]; var mark = {}; var callout = {}; mark.longitude = item.Position.Point.X; mark.latitude = item.Position.Point.Y; mark.title = item.Name; mark.id = parseInt(item.FlowMeterID); mark.content = item.Position.Address; mark.width = 32; mark.height = 32; mark.iconPath = "/images/map/press_blue.png"; mark.zIndex = 10; mark.markerType = 'PressMeter' mark.markerInfo = item callout.content = item.Name; callout.display = 'ALWAYS'; callout.padding = 5; callout.borderRadius = 10; callout.borderWidth = 1; callout.borderColor = '#999'; mark.callout = callout; markers.push(mark); PressMeter.push(mark); pointsList.push({ longitude: item.Position.Point.X, latitude: item.Position.Point.Y }); } var oldMarkers = that.data.mapInfo.markers; var newMarkers = oldMarkers.concat(markers); var oldPointsList = that.data.mapInfo.pointsList; var newPointsList = oldPointsList.concat(pointsList); that.setData({ 'mapInfo.markers': newMarkers, 'mapInfo.pointsList': newPointsList, 'mapInfo.marker.PressMeter': PressMeter, }); //console.log(newMarkers) } }); }, //获取流量计列表 getFlowMeterList:function(){ var that = this; wx.showLoading({ title: '加载中...' }); Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetFlowMeterList@V1.0", method: 'GET', header: { 'content-type': 'application/json' }, fail: function (err) { console.log(err) wx.hideLoading(); wx.showModal({ title: '', content: '通讯失败', }) }, //请求失败 success: function (res) { wx.hideLoading(); // console.log(res.data,"流量计") var result = res.data; if (result.Code != 0) { wx.showModal({ title: '', content: result.Message, }); return; } var markers = []; var pointsList = []; var FlowMeter=[] if (result.Data == null) { result.Data = [] } for (var i = 0; i < result.Data.length; i++) { var item = result.Data[i]; var mark = {}; var callout = {}; mark.longitude = item.Position.Point.X; mark.latitude = item.Position.Point.Y; mark.title = item.Name; mark.id = parseInt(item.FlowMeterID); mark.content = item.Position.Address; mark.width = 32; mark.height = 32; mark.iconPath = "/images/map/flow_blue.png"; mark.zIndex = 10; mark.markerType = 'FlowMeter' mark.markerInfo = item callout.content = item.Name; callout.display = 'ALWAYS'; callout.padding = 5; callout.borderRadius = 10; callout.borderWidth = 1; callout.borderColor = '#999'; mark.callout = callout; markers.push(mark); FlowMeter.push(mark); pointsList.push({ longitude: item.Position.Point.X, latitude: item.Position.Point.Y }); } var oldMarkers = that.data.mapInfo.markers; var newMarkers = oldMarkers.concat(markers); var oldPointsList = that.data.mapInfo.pointsList; var newPointsList = oldPointsList.concat(pointsList); that.setData({ 'mapInfo.markers': newMarkers, 'mapInfo.pointsList': newPointsList, 'mapInfo.marker.FlowMeter': FlowMeter, }); //console.log(newMarkers) } }); }, //获取泵站列表 getStationList:function(){ var that = this; wx.showLoading({ title: '加载中...' }); Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetStationList@V1.0", method: 'GET', header: { 'content-type': 'application/json' }, fail: function (err) { console.log(err) wx.hideLoading(); wx.showModal({ title: '', content: '通讯失败', }) }, //请求失败 success: function (res) { wx.hideLoading(); // console.log(res.data,"泵站") var result = res.data; if (result.Code != 0) { wx.showModal({ title: '', content: result.Message, }); return; } var markers = []; var pointsList = []; var Station=[] var stationIDs = [] if (result.Data == null) { result.Data = [] } for (var i = 0; i < result.Data.length; i++) { var item = result.Data[i]; var mark = {}; var callout = {}; mark.longitude = item.Position.Point.X; mark.latitude = item.Position.Point.Y; mark.title = item.Name; stationIDs.push(parseInt(item.StationID)); mark.id = parseInt(item.StationID); mark.content = item.Position.Address; mark.width = 32; mark.height = 32; mark.iconPath = "/images/map/pump_blue.png"; mark.zIndex = 10; mark.markerInfo = item mark.markerType = 'Station' callout.content = item.Name; callout.display = 'ALWAYS'; callout.padding = 5; callout.borderRadius = 10; callout.borderWidth = 1; callout.borderColor = '#999'; mark.callout = callout; markers.push(mark); Station.push(mark); pointsList.push({ longitude: item.Position.Point.X, latitude: item.Position.Point.Y }); } var oldMarkers = that.data.mapInfo.markers; var newMarkers = oldMarkers.concat(markers); var oldPointsList = that.data.mapInfo.pointsList; var newPointsList = oldPointsList.concat(pointsList); that.setData({ 'mapInfo.markers': newMarkers, 'mapInfo.pointsList': newPointsList, stationIDs: stationIDs, 'mapInfo.marker.Station': Station, }); //console.log(newMarkers) } }); }, //获取DMA列表 getDmaAreaList:function(){ var that = this; wx.showLoading({ title: '加载中...' }); Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetDmaAreaList@V1.0", method: 'GET', header: { 'content-type': 'application/json' }, fail: function (err) { console.log(err) wx.hideLoading(); wx.showModal({ title: '', content: '通讯失败', }) }, //请求失败 success: function (res) { wx.hideLoading(); // console.log(res.data,"DMA") var result = res.data; if (result.Code != 0) { wx.showModal({ title: '', content: result.Message, }); return; } var DMA = []; var DmaArea = []; if (result.Data == null) { result.Data = [] } for (var i = 0; i < result.Data.length; i++) { var item = result.Data[i]; var n = i % 5; var node = {}; var points = []; node.ID = item.DmaAreaID; node.Name = item.Name; node.strokeColor = item.Position.BorderColor; node.fillColor = item.Position.BackgroundColor + "" + (item.Position.BackgroundOpacity * 100).toString(16); node.strokeWidth = item.Position.BorderWidth; if (item.Position.Points == null) { item.Position.Points = [] } for (var j = 0; j < item.Position.Points.length; j++) { var item2 = item.Position.Points[j]; var node2 = {}; node2.latitude = item2.Y node2.longitude = item2.X points.push(node2) } node.points = points DMA.push(node) DmaArea.push(node) } that.setData({ 'mapInfo.marker.DmaArea': DmaArea, 'mapInfo.DMA': DMA, }); //console.log(newMarkers) } }); }, //点击地图marker tapMapMark: function (e) { // console.log(e,484) var id = e.detail.markerId; // console.log(id) //console.log(e) this.showMapTipInBottomPanel(id); var stationIDs = this.data.stationIDs var link_box = false; if (stationIDs.indexOf(id) == -1) { link_box = false; } else { link_box = true } this.setData({ modalName: 'bottomModal', link_box: link_box }) }, //显示marker信息面板 async showMapTipInBottomPanel(id, label) { // console.log(id) var markerTipInfo = null; var that = this; var markers = that.data.mapInfo.markers; that.setData({ isLoad:false }) that.setData({ isLoad:true }) var type=null for (var i = 0; i < markers.length; i++) { markerTipInfo = markers[i]; if(id==markers[i].id){ type=markers[i].markerType if(type=='Station'){ let stationLastRecord = await that.getGeneralLastRecordByStationID(id) markerTipInfo.markerInfo.Records = stationLastRecord } if(type=='FlowMeter'){ let flowMeterLastRecord = await that.getMonitorKpiInfoByFlowMeterID(id) markerTipInfo.markerInfo.Records = flowMeterLastRecord } if(type=='PressMeter'){ let infoByPressMeterLastRecord = await that.getMonitorKpiInfoByPressMeterID(id) markerTipInfo.markerInfo.Records = infoByPressMeterLastRecord } if(type=='RepairForm'){ var FormType=markerTipInfo.markerInfo.FormType var FormID=markerTipInfo.markerInfo.FormID let repairLastRecord = await that.getRepairStatusInfo(FormType,FormID) markerTipInfo.markerInfo = repairLastRecord } that.setData({ markerTipInfo: markerTipInfo, }) // console.log(markerTipInfo.markerInfo,613) break } } }, //获取泵站最近一条数据 getGeneralLastRecordByStationID(stationID){ return new Promise(function (resolve, reject){ Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetMonitorKpiInfoByStationID@V1.0", method: 'GET', data: { StationID :stationID, }, header: { 'content-type': 'application/json' }, success:res=>{ let result = res.data if(result.Code != 0){ result = [] resolve(result) return } resolve(result.Data || []) }, fail:err=>{ reject(err) } }) }) }, //获取流量计 最近一条数据 getMonitorKpiInfoByFlowMeterID(FlowMeterID){ return new Promise(function (resolve, reject){ Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetMonitorKpiInfoByFlowMeterID@V1.0", method: 'GET', data: { FlowMeterID :FlowMeterID , }, header: { 'content-type': 'application/json' }, success:res=>{ let result = res.data if(result.Code != 0){ result = [] resolve(result) return } resolve(result.Data || []) }, fail:err=>{ reject(err) } }) }) }, //获取压力计 最近一条数据 getMonitorKpiInfoByPressMeterID(PressMeterID ){ return new Promise(function (resolve, reject){ Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetMonitorKpiInfoByPressMeterID@V1.0", method: 'GET', data: { PressMeterID :PressMeterID , }, header: { 'content-type': 'application/json' }, success:res=>{ let result = res.data if(result.Code != 0){ result = [] resolve(result) return } resolve(result.Data || []) }, fail:err=>{ reject(err) } }) }) }, //获取工单 最近一条数据 getRepairStatusInfo(FormType,FormID){ return new Promise(function (resolve, reject){ Request({ url: Constant.BASE_SERVER_URL + "SZJT/Map/Mobile/GetRepairStatusInfo@V1.0", method: 'GET', data: { FormType :FormType , FormID :FormID }, header: { 'content-type': 'application/json' }, success:res=>{ let result = res.data if(result.Code != 0){ result = [] resolve(result) return } resolve(result.Data || []) }, fail:err=>{ reject(err) } }) }) }, //隐藏对话框 hideModal: function () { this.setData({ modalName: null }) }, //跳转到单个测点页面 gotoSinglePointPage(e) { var pointid = e.currentTarget.dataset.id; let pointName = e.currentTarget.dataset.name let pointUnit = e.currentTarget.dataset.unit // console.log(pointid) wx.navigateTo({ url: '/monitor/singlePoint/index?id=' + pointid + "&name=" + pointName +"&unit=" + pointUnit, }); }, //打开泵站监控页面 tapOpenStationMonitorPageInList: function (e) { var id = e.currentTarget.dataset.stationid; var name = e.currentTarget.dataset.stationname; // console.log(e.currentTarget); if (id == undefined) { wx.navigateTo({ url: '/monitor/station/index?id=1', }); return; } wx.navigateTo({ url: '/monitor/station/index?id=' + id + "&name=" + name, }); }, //打开泵站BIM页面 tapOpenStationBimPageInList: function (e) { var id = e.currentTarget.dataset.stationid; var name = e.currentTarget.dataset.stationname; //console.log(e.currentTarget); if (id == undefined) { wx.navigateTo({ url: '/bim/station/index?id=1', }); return; } wx.navigateTo({ url: '/bim/station/index?id=' + id + "&name=" + name, }); }, //资产 tapOpenProductInStationPageInList: function (e) { var id = e.currentTarget.dataset.stationid; var name = e.currentTarget.dataset.stationname; if (id == undefined) { return; } wx.navigateTo({ url: '/product/listInStation/index?id=' + id + '&name=' + name, }); }, //键盘输入时实时调用搜索方法 inputKeyWrd(e) { this.searchStationByKeyWrd(e.detail.value) }, //点击完成按钮时触发 confirmSearch(e) { this.searchStationByKeyWrd(e.detail.value) }, searchStationByKeyWrd(key) { var that = this; if (key == '') { //用户没有输入时全部为空 that.setData({ searchMarkList: [], isShowsearchMarkList: false }) return; } let markers = that.data.mapInfo.markers; var arr = []; //临时数组,用于存放匹配到的数组 for (let i in markers) { var mark = markers[i]; if (mark.title.indexOf(key) >= 0) { arr.push(mark) } else if (mark.content) { if(mark.content.indexOf(key) >= 0){ arr.push(mark) } } } if (arr.length == 0) { that.setData({ searchMarkList: [{ show: true, name: '没有相关数据!' }], isShowsearchMarkList: true }) } else { that.setData({ searchMarkList: arr, isShowsearchMarkList: true }) } }, //隐藏底部弹框 hideModal(e) { this.setData({ modalName: null }) }, //导航 onGuideDirty(e) { wx.showToast({ title: '功能未开放', icon: 'loading', duration: 2000 }) }, //显/隐 图层按钮 xianShiTuCeng(e) { var val = !this.data.tuceng_active; this.setData({ tuceng_active: val, DrawerName: e.currentTarget.dataset.target }) }, //显示图层 showMarkerLayer(e) { var _this = this; var type = e.currentTarget.dataset.type; var show = e.currentTarget.dataset.show; var marker_layer = this.data.marker_layer; marker_layer[type] = !show; var markers = JSON.parse(JSON.stringify(this.data.mapInfo.markers)); var val = this.data.mapInfo.marker[type]; var newMarkers = [] if ('DmaArea' == type) { var dma = JSON.parse(JSON.stringify(this.data.mapInfo.DMA)); var newdma = []; if (show) { newdma = [] } else { newdma = val } _this.setData({ 'mapInfo.DMA': newdma, marker_layer: marker_layer }) } else { if (show) { for (var i = 0; i < markers.length; i++) { var item = markers[i]; if (item.markerType != type) { newMarkers.push(item); } } } else { //console.log(type,1070) newMarkers = markers.concat(val) } _this.setData({ 'mapInfo.markers': newMarkers, marker_layer: marker_layer }) } }, //查询 tapSearchIcon: function () { var animation = this.data.animationSearchBar if (animation == 'animation') { animation = 'animation_out' } else { animation = 'animation' } this.setData({ animationSearchBar: animation }) }, //点击搜索的ITEM,定位内容位置 tapMapSearchItem(e) { var that = this; var value = e.currentTarget.dataset; var markers = that.data.mapInfo.markers; for (var i = 0; i < markers.length; i++) { var item = markers[i]; item.zIndex = 10; if (item.id == value.id) { item.zIndex = 100; break; } } console.log(value,941) that.setData({ 'mapInfo.mapCenterLatitude': value.latitude, 'mapInfo.mapCenterLongitude': value.longitude, 'mapInfo.scale': 14, 'mapInfo.markers': markers, searchMarkList: [], searchKeyWrd: '' }); // console.log(value); that.showMapTipInBottomPanel(value.id, "search"); //that.search(that.data.searchKeyWrd); return; }, //跳转到报表界面 tapOpenReportForm(e) { let id = e.currentTarget.dataset.stationid; let name = e.currentTarget.dataset.stationname; wx.navigateTo({ url: '/reportForm/index/index?id=' + id + "&name=" + name, }); }, //只显示泵站 tapOnlyShowStation() {}, //只显示小区 tapOnlyShowEstate() {}, //刷新测点的监测值 refreshMonitorRecords(ids) { // console.log(ids,733) if (ids == null || ids.length == 0) { return } var that = this; wx.showLoading({ title: '加载中...' }); Request({ url: Constant.BASE_SERVER_URL + "Monitor/MonitorPoint/Mobile/GetByProductID@V1.0", method: 'GET', data: { CorpID : Constant.CorpID, ProductID : ids }, header: { 'content-type': 'application/json' }, fail: function (err) { console.log(err) wx.hideLoading(); wx.showModal({ title: '', content: '通讯失败', }) }, //请求失败 success: function (res) { wx.hideLoading(); // console.log(res.data,792) var result = res.data; if (result.Code != 0) { wx.showModal({ title: '', content: result.Message, }); return; } // console.log(result) var markerInfo = that.data.markerTipInfo.markerInfo let records = [] if (records == null || records.length == 0) { records = [] } if (result.Data == null) { return } let montiorIDs = [] if (result.Data.length > 0) { for (var i = 0; i < result.Data.length; i++) { var node = result.Data[i]; records.push(node) montiorIDs.push(node.ID) } } that.setData({ 'markerTipInfo.markerInfo.Records': records }); that.getLastRecordByMonitor(montiorIDs) // console.log(that.data.markerTipInfo.markerInfo.Records,821) } }); }, getLastRecordByMonitor(ids){ let monitorIDs = ids.join(",") let that = this // console.log(monitorIDs,830) Request({ url: Constant.BASE_SERVER_URL + "Run/MonitorRecord/Mobile/GetLastRecordByMonitorPointIds@V1.0", method: 'GET', data: { CorpID : Constant.CorpID, MonitorPointIds : monitorIDs }, header: { 'content-type': 'application/json' }, fail: function (err) { console.log(err) wx.hideLoading(); wx.showModal({ title: '', content: '通讯失败', }) }, //请求失败 success: function (res) { wx.hideLoading(); // console.log(res.data,792) var result = res.data; if (result.Code != 0) { wx.showModal({ title: '', content: result.Message, }); return; } // console.log(result) var markerInfo = that.data.markerTipInfo.markerInfo // console.log(that.data.markerTipInfo.markerInfo.Records,864) let records = markerInfo.Records || [] if (records == null || records.length == 0) { records = [] } if (result.Data == null) { return } // console.log(records,871) if (result.Data.length > 0) { for (var i = 0; i < result.Data.length; i++) { var node = result.Data[i]; records.forEach(element => { if(element.SignalList[0].ID == node.SignalID){ element.SignalList[0].DataValue = node.DataValue if(element.SignalList[0].ValueType == 2){ element.SignalList[0].DataValue = element.SignalList[0].ValueSettings[node.DataValue] } } }); } } that.setData({ 'markerTipInfo.markerInfo.Records': records }); // console.log(that.data.markerTipInfo.markerInfo.Records,821) } }); }, //点击定位到用户当前位置 currentLoaction: function () { let that = this let mapId = that.data.mapId let MapContext = wx.createMapContext(mapId) MapContext.moveToLocation({ longitude: 120.287392, latitude: 31.121743, success: function (res) { that.setData({ 'mapInfo.mapCenterLatitude': 31.121743, 'mapInfo.mapCenterLongitude': 120.287392, 'mapInfo.scale': 12 }) }, fail: function (err) { // console.log(err) } }) }, //视野发生变化时的监听事件 mapViewChange: function (e) { // console.log(e) let that = this let mapId = that.data.mapId let MapContext = wx.createMapContext(mapId) if (e.type == 'end' && (e.causedBy == 'scale' || e.causedBy == 'drag')) { MapContext.getCenterLocation({ success: res => { //console.log(res) that.setData({ 'mapInfo.mapCenterLatitude': res.latitude, 'mapInfo.mapCenterLongitude': res.longitude, 'drawerMenuMoveData.bottom': -(wx.getSystemInfoSync().windowHeight * 0.55 * wx.getSystemInfoSync().pixelRatio), 'drawerMenuMoveData.icon': 'fold' }) }, fail: err => { // console.log(err) } }) } }, //在地图渲染更新完成时触发 onUpdate: function (e) { // console.log(e) }, //地图放大 jia: function () { let scaleCount = this.data.mapInfo.scale //console.log(scaleCount) if (scaleCount >= 20) { wx.showToast({ title: '已放大到最大范围', icon: 'none' }) return } else { this.setData({ 'mapInfo.scale': ++scaleCount }) } // console.log(this.data.mapInfo.scale) }, jian: function () { //console.log('减') let scaleCount = this.data.mapInfo.scale if (scaleCount <= 3) { wx.showToast({ title: '已缩小到最小范围', icon: 'none' }) return } else { this.setData({ 'mapInfo.scale': --scaleCount }) } //console.log(this.data.mapInfo.scale) }, //隐藏抽屉弹窗 hideDrawerModal: function () { this.setData({ DrawerName: null }) }, //地图类型的显示控制 changeMapType: function (e) { // console.log(e) let mapType = e.currentTarget.dataset.type // console.log(mapType) if (mapType == '2D') { this.setData({ 'mapInfo.map3D': false, 'mapInfo.overlooking': false, 'mapInfo.satellite': false }) } else if (mapType == '3D') { this.setData({ 'mapInfo.map3D': true, 'mapInfo.overlooking': true, 'mapInfo.satellite': false }) } else if (mapType == 'satellite') { this.setData({ 'mapInfo.map3D': false, 'mapInfo.overlooking': false, 'mapInfo.satellite': true }) } this.setData({ mapType: mapType }) }, //实时路况的显示隐藏 changeTraffic: function () { this.data.mapInfo.traffic = !this.data.mapInfo.traffic this.setData({ mapInfo: this.data.mapInfo }) }, //点击地图时触发的事件 mapClick: function (e) { // console.log('我被点击了') this.data.isShowMapLayer = !this.data.isShowMapLayer this.setData({ 'drawerMenuMoveData.bottom': -(wx.getSystemInfoSync().windowHeight * 0.55 * wx.getSystemInfoSync().pixelRatio), 'drawerMenuMoveData.icon': 'fold', isShowMapLayer: this.data.isShowMapLayer }) // console.log(this.data.drawerMenuMoveData) }, //底部抽屉移动时的监听事件 movaleChange: function (e) { // console.log(e.detail.y * -1) let sysHeight = this.data.drawerMenuMoveData.sysHeight //当前窗口的设备高度 let nowY = e.detail.y * -1 > 0 ? e.detail.y * -1 : '0' //当前拖动的y坐标的值 let isLoactionShow = this.data.isLoactionShow //回到当前位置图标是否显示 let isScaleShow = this.data.isScaleShow //地图缩放按钮图标是否显示 let isShowRightBtn = this.data.isShowRightBtn //地图右侧按钮图标显示状态 let icon = '' let lastY = this.data.drawerMenuMoveData.y //上一次拖动结束后的y坐标的值 if (nowY > sysHeight * 0.5) { isScaleShow = false isShowRightBtn = false isLoactionShow = false lastY = sysHeight * 0.8 * -1 icon = 'unfold' } else if (nowY > sysHeight * 0.4) { // console.log('我被调用了', 'nowY=' + nowY, sysHeight * 0.3) lastY = sysHeight * 0.23 * -1 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'move' } else if (nowY > 110) { // console.log('我被调用了', 'nowY=' + nowY, sysHeight * 0.3) lastY = sysHeight * 0.23 * -1 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'move' } else { lastY = 0 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'fold' } this.setData({ 'drawerMenuMoveData.y': lastY, 'drawerMenuMoveData.icon': icon, isLoactionShow: isLoactionShow, isShowRightBtn: isShowRightBtn, isScaleShow: isScaleShow }) // console.log(nowY, lastY) }, //扫描二维码 onScan: function () { // 允许从相机和相册扫码 wx.scanCode({ success(res) { console.log(res) } }) }, //抽屉开始移动 drawerTouchStart: function (e) { // console.log('开始移动', e) this.setData({ 'drawerMenuMoveData.startTouchY': e.changedTouches[0].clientY }) }, //抽屉移动 drawerTouchMove: function (e) { }, //抽屉移动结束 drawerTouchEnd: function (e) { let moveY = e.changedTouches[0].clientY let pixelRatio = this.data.drawerMenuMoveData.pixelRatio let bottom = -(wx.getSystemInfoSync().windowHeight * 0.40 * pixelRatio) let status = this.data.drawerMenuMoveData.status let isLoactionShow = this.data.isLoactionShow //回到当前位置图标是否显示 let isScaleShow = this.data.isScaleShow //地图缩放按钮图标是否显示 let isShowRightBtn = this.data.isShowRightBtn //地图右侧按钮图标显示状态 let icon = '' //图标 // console.log(moveY, 'moveY') if (status == 1) { if (moveY < 350) { bottom = 0 status = 2 isScaleShow = false isShowRightBtn = false isLoactionShow = false icon = 'unfold' } else if (moveY > 530) { // console.log('我被调用了') bottom = -(wx.getSystemInfoSync().windowHeight * 0.55 * pixelRatio) status = 0 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'fold' } else { bottom = -(wx.getSystemInfoSync().windowHeight * 0.40 * pixelRatio) status = 1 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'move' } } else if (status == 2) { if (moveY > 500) { bottom = -(wx.getSystemInfoSync().windowHeight * 0.55 * pixelRatio) status = 0 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'fold' } else if (moveY > 250) { bottom = -(wx.getSystemInfoSync().windowHeight * 0.40 * pixelRatio) status = 1 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'move' } else { bottom = 0 status = 2 isScaleShow = false isShowRightBtn = false isLoactionShow = false icon = 'unfold' } } else { if (moveY < 600) { bottom = -(wx.getSystemInfoSync().windowHeight * 0.40 * pixelRatio) status = 1 isScaleShow = true isShowRightBtn = true isLoactionShow = true icon = 'move' } else if (moveY < 180) { bottom = 0 status = 2 isScaleShow = false isShowRightBtn = false isLoactionShow = false icon = 'unfold' } } // console.log(startTouchY, moveY, bottom) this.setData({ 'drawerMenuMoveData.bottom': bottom, 'drawerMenuMoveData.status': status, 'drawerMenuMoveData.startTouchY': null, 'drawerMenuMoveData.icon': icon, isLoactionShow: isLoactionShow, isShowRightBtn: isShowRightBtn, isScaleShow: isScaleShow }) // console.log('移动结束', this.data.drawerMenuMoveData) }, isLoading (e) { this.setData({ isLoad: e.detail.value }) }, })