waimaiMap.vue 5.1 KB

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