lockRecord.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const app = getApp()
  2. Page({
  3. data: {
  4. lockRecord: [],
  5. longitude:'',
  6. latitude:'',
  7. not:false
  8. },
  9. onLoad: function(options) {
  10. wx.showLoading({
  11. title: '加载中...',
  12. })
  13. let that = this;
  14. let data = {
  15. bike_id: options.id
  16. }
  17. app.request('bike/locksInfo', data, 'POST').then(res => {
  18. wx.hideLoading();
  19. console.log(res, '开关锁记录')
  20. if (
  21. res.data.close_bike.length == 0 &&
  22. res.data.close_pause_bike.length == 0 &&
  23. res.data.open_bike.length == 0 &&
  24. res.data.open_pause_bike.length == 0
  25. ) {
  26. this.setData({
  27. not:true
  28. })
  29. } else {
  30. let close_bike = res.data.close_bike;
  31. let open_bike = res.data.open_bike;
  32. let open_pause_bike = res.data.open_pause_bike;
  33. let close_pause_bike = res.data.close_pause_bike;
  34. // 开锁记录
  35. for (var i = 0; i < close_bike.length; i++) {
  36. close_bike[i].iconPath = 'http://resource.weilaibike.com/common/open.app.png';
  37. close_bike[i].width = 24;
  38. close_bike[i].height =24;
  39. close_bike[i].zIndex = 1111;
  40. close_bike[i].latitude = close_bike[i].location[1];
  41. close_bike[i].longitude = close_bike[i].location[0];
  42. }
  43. that.setData({
  44. markers: close_bike
  45. })
  46. //关锁记录
  47. for (var i = 0; i < open_bike.length; i++) {
  48. open_bike[i].iconPath = 'http://resource.weilaibike.com/common/close.app.png';
  49. open_bike[i].width = 24;
  50. open_bike[i].height = 24;
  51. open_bike[i].zIndex = 1111;
  52. open_bike[i].latitude = open_bike[i].location[1];
  53. open_bike[i].longitude = open_bike[i].location[0];
  54. }
  55. that.setData({
  56. markers: that.data.markers.concat(open_bike)
  57. })
  58. //临时开锁
  59. for (var i = 0; i < open_pause_bike.length; i++) {
  60. open_pause_bike[i].iconPath = 'http://resource.weilaibike.com/common/temOpen.app.png';
  61. open_pause_bike[i].width = 22;
  62. open_pause_bike[i].height = 30;
  63. open_pause_bike[i].zIndex = 1111;
  64. open_pause_bike[i].latitude = open_pause_bike[i].location[1];
  65. open_pause_bike[i].longitude = open_pause_bike[i].location[0];
  66. }
  67. that.setData({
  68. markers: that.data.markers.concat(open_pause_bike)
  69. })
  70. //临时关锁
  71. for (var i = 0; i < close_pause_bike.length; i++) {
  72. close_pause_bike[i].iconPath = 'http://resource.weilaibike.com/common/temClose.app.png';
  73. close_pause_bike[i].width = 22;
  74. close_pause_bike[i].height = 30;
  75. close_pause_bike[i].zIndex = 1111;
  76. close_pause_bike[i].id = close_pause_bike[i].bike_no;
  77. close_pause_bike[i].latitude = close_pause_bike[i].location[1];
  78. close_pause_bike[i].longitude = close_pause_bike[i].location[0];
  79. }
  80. that.setData({
  81. markers: that.data.markers.concat(close_pause_bike),
  82. longitude: res.data.open_bike[0].location[0],
  83. latitude: res.data.open_bike[0].location[1]
  84. })
  85. //列表数据
  86. let arr = [];
  87. arr = arr.concat(
  88. res.data.close_bike,
  89. res.data.close_pause_bike,
  90. res.data.open_bike,
  91. res.data.open_pause_bike
  92. );
  93. console.log(this.data.markers);
  94. that.setData({
  95. lockRecord: arr
  96. })
  97. }
  98. }).catch(err => {
  99. console.log(err)
  100. })
  101. },
  102. })