scanRecord.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <!-- <text>扫码位置</text> -->
  3. <view class="scanRecord">
  4. <map id="map" :longitude="longitude" :latitude="latitude" scale="14" :markers="markers" v-if="!not"></map>
  5. <view class="scan">
  6. <view class="scanDate" v-for="(item,index) in scan" :key="index" v-bind:data-idx="index" @click="current">
  7. <text >扫码时间:{{item.time}}</text>
  8. </view>
  9. </view>
  10. <view class="noData" v-if="not">
  11. <image src="http://resource.weilaibike.com/none.png"></image>
  12. <view>暂无相关数据~</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. var app=getApp()
  18. export default{
  19. data(){
  20. return{
  21. scan: [],
  22. longitude: '',
  23. latitude: '',
  24. markers: [],
  25. not:false,
  26. }
  27. },
  28. onLoad(options) {
  29. uni.showLoading({
  30. title: '加载中...',
  31. })
  32. let data = {
  33. bike_id: options.id
  34. }
  35. app.request('bike/sweepCodeLocation', data, 'POST').then(res => {
  36. uni.hideLoading();
  37. if (res.statusCode == 200) {
  38. if (res.data.length == 0) {
  39. this.setData({
  40. not:true
  41. })
  42. } else {
  43. let arr = res.data;
  44. for (var i = 0; i < arr.length; i++) {
  45. arr[i].iconPath = 'http://resource.weilaibike.com/common/start-location-mark-old.png';
  46. arr[i].width = 30;
  47. arr[i].height = 30;
  48. arr[i].zIndex = 1111;
  49. arr[i].latitude = arr[i].location[1];
  50. arr[i].longitude = arr[i].location[0];
  51. }
  52. this.markers=arr,
  53. this.scan=res.data,
  54. this.longitude=arr[0].location[0],
  55. this.latitude=arr[0].location[1]
  56. }
  57. }
  58. })
  59. },
  60. methods:{
  61. //获取当前扫码位置
  62. current(e) {
  63. let nowPosition = this.markers
  64. let idx = e.currentTarget.dataset.idx;
  65. for (var i = 0; i < nowPosition.length; i++) {
  66. nowPosition[i].iconPath =
  67. "http://resource.weilaibike.com/common/start-location-mark-old.png";
  68. }
  69. nowPosition[idx].iconPath = "http://resource.weilaibike.com/common/end-location-mark-old.png";
  70. this.markers=nowPosition
  71. },
  72. }
  73. }
  74. </script>
  75. <style>
  76. page {
  77. background: #eee;
  78. }
  79. map {
  80. width: 100%;
  81. height: 45%;
  82. position: fixed;
  83. }
  84. .scan {
  85. padding-top: 600rpx;
  86. }
  87. .scan .scanDate {
  88. background: #fff;
  89. width:92%;
  90. margin:14rpx auto;
  91. height:90rpx;
  92. line-height:90rpx;
  93. border-radius: 10rpx;
  94. }
  95. .scan .scanDate text{
  96. margin-left:25rpx;
  97. font-size:28rpx;
  98. color:#4d4d4d;
  99. }
  100. </style>