scanRecord.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var app = getApp()
  2. Page({
  3. data: {
  4. scan: [],
  5. longitude: '',
  6. latitude: '',
  7. markers: [],
  8. not:false,
  9. },
  10. onLoad: function(options) {
  11. wx.showLoading({
  12. title: '加载中...',
  13. })
  14. let data = {
  15. bike_id: options.id
  16. }
  17. app.request('bike/sweepCodeLocation', data, 'POST').then(res => {
  18. wx.hideLoading();
  19. if (res.statusCode == 200) {
  20. if (res.data.length == 0) {
  21. this.setData({
  22. not:true
  23. })
  24. } else {
  25. let self = this;
  26. let arr = res.data;
  27. for (var i = 0; i < arr.length; i++) {
  28. arr[i].iconPath = 'http://resource.weilaigo.l4j.cn/common/start-location-mark-old.png';
  29. arr[i].width = 30;
  30. arr[i].height = 30;
  31. arr[i].zIndex = 1111;
  32. arr[i].latitude = arr[i].location[1];
  33. arr[i].longitude = arr[i].location[0];
  34. }
  35. self.setData({
  36. markers: arr,
  37. scan: res.data,
  38. longitude: arr[0].location[0],
  39. latitude: arr[0].location[1]
  40. })
  41. }
  42. }
  43. })
  44. },
  45. //获取当前扫码位置
  46. current(e) {
  47. let self = this;
  48. let nowPosition = self.data.markers
  49. let idx = e.currentTarget.dataset.idx;
  50. for (var i = 0; i < nowPosition.length; i++) {
  51. nowPosition[i].iconPath =
  52. "http://resource.weilaigo.l4j.cn/common/start-location-mark-old.png";
  53. }
  54. nowPosition[idx].iconPath = "http://resource.weilaigo.l4j.cn/common/end-location-mark-old.png";
  55. self.setData({
  56. markers:nowPosition
  57. })
  58. },
  59. })