waimaiMap.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. this.$Request.get('/app/order/selectOrderById?orderId=' + this.orderId).then(res => {
  88. console.log(res)
  89. if (res.code == 0) {
  90. this.orderDetails = res.data
  91. this.riderUserId = res.data.riderUserId
  92. this.getLocation()
  93. // console.log(this.markers)
  94. }
  95. });
  96. },
  97. getLocation() {
  98. let data = {
  99. riderUserId: this.riderUserId,
  100. lat: this.lat,
  101. lng: this.lng
  102. }
  103. this.$Request.getT('/timedtask/selectRiderLocation', data).then(res => {
  104. if (res.code === 0) {
  105. this.latitude = res.data.riderLocation.lat;
  106. this.longitude = res.data.riderLocation.lng;
  107. this.rider = res.data
  108. this.rider.mDateTime = res.data.mDateTime.split(' ')
  109. if (this.rider.aDouble > 1000) {
  110. this.rider.aDouble = Number((this.rider.aDouble / 1000)).toFixed(2)+"km"
  111. }else{
  112. if(this.rider.aDouble==0){
  113. this.rider.aDouble = "0m";
  114. }else{
  115. this.rider.aDouble = Number(this.rider.aDouble).toFixed(1) +"m";
  116. }
  117. }
  118. let marker = {
  119. id: 2,
  120. latitude: res.data.riderLocation.lat,
  121. longitude: res.data.riderLocation.lng,
  122. iconPath: '../../static/images/order/rider.png',
  123. width: '40',
  124. height: '40',
  125. }
  126. this.markers.push(marker)
  127. }
  128. });
  129. },
  130. call() {
  131. uni.makePhoneCall({
  132. phoneNumber: this.orderDetails.riderPhone
  133. });
  134. },
  135. goNav() {
  136. uni.navigateTo({
  137. url: '/my/setting/chat'
  138. })
  139. }
  140. },
  141. }
  142. </script>
  143. <style>
  144. .controls-title {
  145. width: 90%;
  146. /* height: 220upx; */
  147. /* line-height: 220upx; */
  148. background: #FFFFFF;
  149. position: fixed;
  150. bottom: 0rpx;
  151. margin: 40upx;
  152. border-radius: 26upx;
  153. box-shadow: 0upx 30upx 40upx 0upx rgba(187, 170, 163, 0.20);
  154. /* margin: 0 40rpx; */
  155. margin-bottom: 50rpx;
  156. }
  157. .tabs_box {
  158. display: flex;
  159. justify-content: space-between;
  160. align-items: center;
  161. padding: 10rpx;
  162. margin: 20rpx;
  163. }
  164. .pay_tit {
  165. flex: 1;
  166. display: flex;
  167. flex-direction: column;
  168. justify-content: space-between;
  169. }
  170. .pay_img {
  171. width: 100rpx;
  172. height: 100rpx;
  173. border-radius: 10rpx;
  174. }
  175. .pay_img1 {
  176. width: 60rpx;
  177. height: 60rpx;
  178. border-radius: 10rpx;
  179. }
  180. .tabs_bottom {
  181. margin: 0 20rpx 20rpx;
  182. display: flex;
  183. }
  184. .pay_btn {
  185. padding: 5rpx 16rpx;
  186. border: solid 2rpx #999999;
  187. margin-right: 20rpx;
  188. display: flex;
  189. align-items: center;
  190. border-radius: 10rpx;
  191. }
  192. .pay_name {
  193. font-size: 32rpx;
  194. font-weight: bold;
  195. }
  196. .pay_line {
  197. height: 2rpx;
  198. background-color: #afafaf;
  199. margin: 10rpx 0;
  200. }
  201. </style>