logisticsDetails.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <!-- 物流详情 -->
  3. <view>
  4. <u-navbar title="物流详情" autoBack placeholder></u-navbar>
  5. <view style="width: 100%;">
  6. <map style="width: 100%;height: 500rpx;" id="container" :latitude="latitude" :longitude="longitude"
  7. :scale="scale" :polyline="polylineList" :markers="markersList">
  8. <view slot="loading">
  9. <view class="loading-icon">加载中...</view>
  10. </view>
  11. </map>
  12. </view>
  13. <view class="card_logistics">
  14. <view class="title_logistics">物流详情</view>
  15. <view class="card_steps" :key="Math.random()" v-if="activitiesList.length > 0">
  16. <!-- <uni-steps direction="column" :options="activitiesList" :active="active"></uni-steps> -->
  17. <x-steps :infoList="activitiesList"></x-steps>
  18. </view>
  19. <view v-else style="padding-bottom: 20rpx;">
  20. <u-empty mode="data" text="暂无物流信息"></u-empty>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. orderList: {},
  30. trackList: [],
  31. map: null,
  32. longitude: 106.6282014,
  33. latitude: 26.64669,
  34. scale: 14,
  35. activitiesList: [],
  36. active: 0,
  37. statusList: [{
  38. id: 1,
  39. title: '待派单',
  40. }, {
  41. id: 2,
  42. title: '待装车',
  43. }, {
  44. id: 3,
  45. title: '待入库',
  46. }, {
  47. id: 4,
  48. title: '已装车',
  49. }, {
  50. id: 5,
  51. title: '已入库',
  52. }, {
  53. id: 6,
  54. title: '已下车',
  55. }, {
  56. id: 7,
  57. title: '已出库',
  58. }, {
  59. id: 8,
  60. title: '已签收',
  61. }],
  62. polylineList: [],
  63. markersList: [],
  64. }
  65. },
  66. mounted() {
  67. var orderList = this.$cache.getCache('orderDetails')
  68. this.orderList = orderList
  69. this.$nextTick(() => {
  70. setTimeout(() => {
  71. this.getList()
  72. })
  73. })
  74. },
  75. methods: {
  76. getList() {
  77. this.$api.get('/api/waybill-logistics', {
  78. waybillNo: this.orderList.waybillNo,
  79. }).then(res => {
  80. if (res.code == 200) {
  81. var arrList = res.data.list
  82. arrList.forEach(async (item) => {
  83. item.backgroundColor = '#ffffff'
  84. item.text = ''
  85. let arr = this.statusList.filter((i) => {
  86. return item.status == i.id;
  87. });
  88. let yonTitle = ''
  89. let phone = ''
  90. if (item.car.id) {
  91. yonTitle = item.car.carNo
  92. phone = item.car.user.phone
  93. } else if (item.warehouse.id) {
  94. yonTitle = item.warehouse.name
  95. phone = item.warehouse.user.phone
  96. }
  97. // const trapeze = await this.reverseGeocode(item.lng, item.lat)
  98. item.phone = phone
  99. item.text = item.address + '【' + yonTitle + '】'
  100. item.text1 = '您的货物' + arr[0].title
  101. })
  102. arrList[0].backgroundColor = '#2979ff'
  103. this.activitiesList = arrList.reverse()
  104. this.getTrack()
  105. }
  106. })
  107. },
  108. // 获取轨迹
  109. getTrack() {
  110. this.$api.get('/api/waybill-task/locus', {
  111. waybillNo: this.orderList.waybillNo,
  112. }).then(res => {
  113. if (res.code == 200) {
  114. let arr = res.data
  115. let arrList = []
  116. arr.forEach(item => {
  117. const arr1 = item.T_site.split(',')
  118. const list = {
  119. latitude: arr1[1],
  120. longitude: arr1[0],
  121. }
  122. arrList.push(list)
  123. })
  124. let polyline = [{
  125. width: 10,
  126. points: arrList,
  127. color: '#3591FC',
  128. arrowLine: true,
  129. arrowIconPath: '/static/task/arrows.png',
  130. }]
  131. this.polylineList = polyline
  132. const markers0 = {
  133. latitude: arrList[0].latitude,
  134. longitude: arrList[0].longitude,
  135. id: 0,
  136. iconPath: '/static/task/startpoint.png',
  137. width: 40,
  138. height: 43
  139. }
  140. const markers1 = {
  141. latitude: arrList[length].latitude,
  142. longitude: arrList[length].longitude,
  143. id: 1,
  144. iconPath: '/static/task/endpoint.png',
  145. width: 40,
  146. height: 43
  147. }
  148. this.markersList[0] = markers0
  149. this.markersList[1] = markers1
  150. this.latitude = arrList[length].latitude
  151. this.longitude = arrList[length].longitude
  152. // console.log(this.polylineList, this.markersList, 266)
  153. this.$forceUpdate()
  154. }
  155. })
  156. },
  157. reverseGeocode(longitude, latitude) {
  158. return new Promise((resolve, reject) => {
  159. new AMap.plugin("AMap.Geocoder", () => {
  160. let position = [longitude, latitude] //位置的经纬度
  161. const geocoder = new AMap.Geocoder({
  162. // city: "0851" ,
  163. cityCode: '0851',
  164. });
  165. geocoder.getAddress(position, (status, result) => {
  166. if (status === "complete" && result.info === "OK") {
  167. const title = result.regeocode.addressComponent.city
  168. resolve(title)
  169. }
  170. });
  171. });
  172. })
  173. },
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .loading-icon {
  179. color: #333;
  180. font-size: 28rpx;
  181. padding: 10px;
  182. background-color: rgba(255, 255, 255, 0.8);
  183. border-radius: 5px;
  184. text-align: center;
  185. }
  186. ::v-deep .u-navbar__content {
  187. z-index: 9999999;
  188. }
  189. .card_logistics {
  190. width: calc(100% - 40rpx);
  191. margin: 20rpx;
  192. height: auto;
  193. background-color: #fff;
  194. border-radius: 10rpx;
  195. }
  196. .title_logistics {
  197. font-weight: 600;
  198. padding: 20rpx 20rpx 0rpx 20rpx;
  199. }
  200. .card_steps {
  201. padding: 20rpx;
  202. }
  203. </style>