const app = getApp() Page({ data: { lockRecord: [], longitude:'', latitude:'', not:false }, onLoad: function(options) { let that = this; let data = { bike_id: options.id } app.request('bike/locksInfo', data, 'POST').then(res => { console.log(res, '开关锁记录') if ( res.data.close_bike.length == 0 && res.data.close_pause_bike.length == 0 && res.data.open_bike.length == 0 && res.data.open_pause_bike.length == 0 ) { this.setData({ not:true }) // wx.showToast({ // title: '暂无相关数据~', // icon: 'none' // }) } else { let close_bike = res.data.close_bike; let open_bike = res.data.open_bike; let open_pause_bike = res.data.open_pause_bike; let close_pause_bike = res.data.close_pause_bike; // 开锁记录 for (var i = 0; i < close_bike.length; i++) { close_bike[i].iconPath = 'http://resource.weilaibike.com/common/open.app.png'; close_bike[i].width = 24; close_bike[i].height =24; close_bike[i].zIndex = 1111; close_bike[i].latitude = close_bike[i].location[1]; close_bike[i].longitude = close_bike[i].location[0]; } that.setData({ markers: close_bike }) //关锁记录 for (var i = 0; i < open_bike.length; i++) { open_bike[i].iconPath = 'http://resource.weilaibike.com/common/close.app.png'; open_bike[i].width = 24; open_bike[i].height = 24; open_bike[i].zIndex = 1111; open_bike[i].latitude = open_bike[i].location[1]; open_bike[i].longitude = open_bike[i].location[0]; } that.setData({ markers: that.data.markers.concat(open_bike) }) //临时开锁 for (var i = 0; i < open_pause_bike.length; i++) { open_pause_bike[i].iconPath = 'http://resource.weilaibike.com/common/temOpen.app.png'; open_pause_bike[i].width = 22; open_pause_bike[i].height = 30; open_pause_bike[i].zIndex = 1111; open_pause_bike[i].latitude = open_pause_bike[i].location[1]; open_pause_bike[i].longitude = open_pause_bike[i].location[0]; } that.setData({ markers: that.data.markers.concat(open_pause_bike) }) //临时关锁 for (var i = 0; i < close_pause_bike.length; i++) { close_pause_bike[i].iconPath = 'http://resource.weilaibike.com/common/temClose.app.png'; close_pause_bike[i].width = 22; close_pause_bike[i].height = 30; close_pause_bike[i].zIndex = 1111; close_pause_bike[i].id = close_pause_bike[i].bike_no; close_pause_bike[i].latitude = close_pause_bike[i].location[1]; close_pause_bike[i].longitude = close_pause_bike[i].location[0]; } that.setData({ markers: that.data.markers.concat(close_pause_bike), longitude: res.data.open_bike[0].location[0], latitude: res.data.open_bike[0].location[1] }) //列表数据 let arr = []; arr = arr.concat( res.data.close_bike, res.data.close_pause_bike, res.data.open_bike, res.data.open_pause_bike ); console.log(this.data.markers); that.setData({ lockRecord: arr }) } }).catch(err => { console.log(err) }) }, onReady: function() { }, onShow: function() { }, onHide: function() { }, onUnload: function() { }, onPullDownRefresh: function() { }, onReachBottom: function() { }, onShareAppMessage: function() { } })