waimaiMap.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view>
  3. <map id="map" style="width: 100%; height: 700px" :latitude="latitude" :longitude="longitude" :markers="markers" :show-location="true"></map>
  4. <cover-view class="controls-title">
  5. <cover-view class="tabs_box">
  6. <cover-image class="pay_img" src="../../static/images/order/avatar.png"></cover-image>
  7. <cover-view class="flex flex-sub margin-left-sm flex-direction justify-between">
  8. <cover-view class="pay_name">骑手预计{{ rider.mDateTime[1] }}送达</cover-view>
  9. <cover-view class="text-gray margin-top" style="margin-top: 5rpx">距离您{{ rider.aDouble }}</cover-view>
  10. </cover-view>
  11. <cover-view class="flex">
  12. <cover-image class="pay_img1 margin-right" @click="goNav" src="../../static/images/order/im.png"></cover-image>
  13. <cover-image class="pay_img1" @click="call" src="../../static/images/order/phone.png"></cover-image>
  14. </cover-view>
  15. </cover-view>
  16. </cover-view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. latitude: '',
  24. longitude: '',
  25. markers: [], //标记点
  26. orderId: '',
  27. riderUserId: '',
  28. orderDetails: {},
  29. rider: {},
  30. timer: '',
  31. lat: '',
  32. lng: ''
  33. }
  34. },
  35. onLoad(option) {
  36. this.orderId = option.orderId
  37. uni.getLocation({
  38. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  39. success: (res) => {
  40. this.lat = res.latitude
  41. this.lng = res.longitude
  42. this.getData()
  43. },
  44. fail(e) {
  45. uni.hideLoading()
  46. uni.showModal({
  47. title: '温馨提示',
  48. content: '您的定位权限未开启,请开启后再来操作吧!',
  49. showCancel: true,
  50. cancelText: '取消',
  51. confirmText: '确认',
  52. success: (res) => {
  53. if (res.confirm) {
  54. uni.openSetting({
  55. // 打开设置页
  56. success(rea) {
  57. console.log(rea.authSetting)
  58. }
  59. })
  60. }
  61. }
  62. })
  63. }
  64. })
  65. },
  66. onShow() {
  67. this.timer = setInterval(() => {
  68. this.getLocation()
  69. }, 10000)
  70. },
  71. onHide() {
  72. console.log(this.timer, '定时器')
  73. clearInterval(this.timer)
  74. },
  75. onBackPress(e) {
  76. console.log('监听返回按钮事件', this.timer)
  77. clearInterval(this.timer)
  78. // 此处一定姚要return为true,否则页面不会返回到指定路径
  79. return true
  80. },
  81. methods: {
  82. getData() {
  83. let data = {
  84. orderId: this.orderId
  85. }
  86. this.$Request.get('/app/order/selectOrderById', data).then((res) => {
  87. console.log(res)
  88. if (res.code == 0) {
  89. this.orderDetails = res.data
  90. this.riderUserId = res.data.riderUserId
  91. this.getLocation()
  92. // console.log(this.markers)
  93. }
  94. })
  95. },
  96. getLocation() {
  97. let data = {
  98. riderUserId: this.riderUserId,
  99. lat: this.lat,
  100. lng: this.lng
  101. }
  102. this.$Request.getT('/timedtask/selectRiderLocation', data).then((res) => {
  103. if (res.code === 0) {
  104. this.latitude = res.data.riderLocation.lat
  105. this.longitude = res.data.riderLocation.lng
  106. this.rider = res.data
  107. this.rider.mDateTime = res.data.mDateTime.split(' ')
  108. if (this.rider.aDouble > 1000) {
  109. this.rider.aDouble = Number(this.rider.aDouble / 1000).toFixed(2) + 'km'
  110. } else {
  111. if (this.rider.aDouble == 0) {
  112. this.rider.aDouble = '0m'
  113. } else {
  114. this.rider.aDouble = Number(this.rider.aDouble).toFixed(1) + 'm'
  115. }
  116. }
  117. let marker = {
  118. id: 2,
  119. latitude: res.data.riderLocation.lat,
  120. longitude: res.data.riderLocation.lng,
  121. iconPath: '../../static/images/order/rider.png',
  122. width: '40',
  123. height: '40'
  124. }
  125. this.markers.push(marker)
  126. }
  127. })
  128. },
  129. call() {
  130. uni.makePhoneCall({
  131. phoneNumber: this.orderDetails.riderPhone
  132. })
  133. },
  134. goNav() {
  135. uni.navigateTo({
  136. url: '/my/setting/chat'
  137. })
  138. }
  139. }
  140. }
  141. </script>
  142. <style>
  143. .controls-title {
  144. width: 90%;
  145. /* height: 220upx; */
  146. /* line-height: 220upx; */
  147. background: #ffffff;
  148. position: fixed;
  149. bottom: 0rpx;
  150. margin: 40upx;
  151. border-radius: 26upx;
  152. box-shadow: 0upx 30upx 40upx 0upx rgba(187, 170, 163, 0.2);
  153. /* margin: 0 40rpx; */
  154. margin-bottom: 50rpx;
  155. }
  156. .tabs_box {
  157. display: flex;
  158. justify-content: space-between;
  159. align-items: center;
  160. padding: 10rpx;
  161. margin: 20rpx;
  162. }
  163. .pay_tit {
  164. flex: 1;
  165. display: flex;
  166. flex-direction: column;
  167. justify-content: space-between;
  168. }
  169. .pay_img {
  170. width: 100rpx;
  171. height: 100rpx;
  172. border-radius: 10rpx;
  173. }
  174. .pay_img1 {
  175. width: 60rpx;
  176. height: 60rpx;
  177. border-radius: 10rpx;
  178. }
  179. .tabs_bottom {
  180. margin: 0 20rpx 20rpx;
  181. display: flex;
  182. }
  183. .pay_btn {
  184. padding: 5rpx 16rpx;
  185. border: solid 2rpx #999999;
  186. margin-right: 20rpx;
  187. display: flex;
  188. align-items: center;
  189. border-radius: 10rpx;
  190. }
  191. .pay_name {
  192. font-size: 32rpx;
  193. font-weight: bold;
  194. }
  195. .pay_line {
  196. height: 2rpx;
  197. background-color: #afafaf;
  198. margin: 10rpx 0;
  199. }
  200. </style>