123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- const app = getApp()
- Page({
- data: {
- lockRecord: [],
- longitude:'',
- latitude:'',
- not:false
- },
- onLoad: function(options) {
- wx.showLoading({
- title: '加载中...',
- })
- let that = this;
- let data = {
- bike_id: options.id
- }
- app.request('bike/locksInfo', data, 'POST').then(res => {
- wx.hideLoading();
- 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
- })
- } 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)
- })
- },
- })
|