detail.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="flex flex-column vh100 w100" v-if="info.status">
  3. <view class="u-flex-1 w100" style="height:10%">
  4. <map style="width: 100%; height: 100%;" :scale="12" :latitude="latitude" :longitude="longitude"
  5. :markers="covers" :polyline="polyline">
  6. <!-- <cover-image v-if="arr1.includes(info.status*1)&&info.status!=3" class="navigation" @click="toNav(info.status)" src="../../static/nav.png"></cover-image> -->
  7. </map>
  8. </view>
  9. <view :class="[info.status==3&&ispay?'datpay':'','w100']">
  10. <paidui class="w100" @update="update" @init="init" v-if="info.status==0||info.status==-2" :info="info"></paidui>
  11. <dtQuxiao class="w100" v-if="info.status==-1" :info="info"></dtQuxiao>
  12. <dtSiji class="w100" @pay="ispay=true" v-if="arr3.includes(info.status*1)&&!ispay" :info="info"></dtSiji>
  13. <dtPay class="w100" @update="update" @close="ispay=false" v-if="info.status==3&&ispay" :info="info"></dtPay>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import amapFile from '../../libs/amap-wx.js'
  19. export default {
  20. data() {
  21. return {
  22. id: '', //订单id
  23. info: {}, //-2超时,-1=已取消,0=呼叫中,1=已接单,2=进行中,3=待支付,4=司机已到达,5=预约单司机待出发,99=已完成'
  24. timer1: null, //排队超时
  25. arr1: [0, 1, 2, 4, 5, 3], //需要定时器
  26. arr2: [-2, -1, 99], //清除定时
  27. arr3: [1, 2, 3, 4, 5, 99], //显示司机组件
  28. ispay: false, //支付弹窗
  29. // 地图
  30. latitude: '',
  31. longitude: '',
  32. polyline: []
  33. }
  34. },
  35. computed: {
  36. covers() {
  37. return [{
  38. id: 1,
  39. latitude: this.latitude,
  40. longitude: this.longitude,
  41. iconPath: '../../static/now.png',
  42. title: '当前位置',
  43. width:25,
  44. height:25
  45. }, {
  46. id: 2,
  47. latitude: this.info.start_latitude,
  48. longitude: this.info.start_longitude,
  49. iconPath: '../../static/start.png',
  50. title: '起点位置',
  51. width:40,
  52. height:40
  53. }, {
  54. id: 3,
  55. latitude: this.info.end_latitude,
  56. longitude: this.info.end_longitude,
  57. iconPath: '../../static/end.png',
  58. title: '终点位置',
  59. width:40,
  60. height:40
  61. }]
  62. }
  63. },
  64. onLoad(option) {
  65. this.id = option.id
  66. },
  67. onShow() {
  68. this.init()
  69. },
  70. onUnload() {
  71. clearInterval(this.timer1)
  72. },
  73. onHide() {
  74. clearInterval(this.timer1)
  75. },
  76. methods: {
  77. init() {
  78. let _this = this
  79. this.$http('/addons/ddrive/order/info', {
  80. order_id: this.id
  81. }, "POST").then(data => {
  82. this.info = data
  83. uni.setNavigationBarTitle({
  84. title: data.status_text
  85. })
  86. if (this.arr1.includes(this.info.status * 1)) {
  87. this.timer1 = setInterval(() => {
  88. this.update()
  89. }, 5000)
  90. }
  91. uni.getLocation({
  92. type: 'gcj02',
  93. success: function(res) {
  94. console.log('当前位置的经度1:' + res.longitude);
  95. console.log('当前位置的纬度1:' + res.latitude);
  96. _this.longitude = res.longitude
  97. _this.latitude = res.latitude
  98. _this.polyline = []
  99. _this.getLine()
  100. }
  101. });
  102. })
  103. },
  104. update() {
  105. this.$http('/addons/ddrive/order/info', {
  106. order_id: this.id
  107. }, "POST").then(data => {
  108. this.info = data
  109. if (this.arr2.includes(this.info.status * 1)) {
  110. clearInterval(this.timer1)
  111. }
  112. })
  113. },
  114. getLine() {
  115. var that = this;
  116. var key = '4212e2ed80856520bc1a2e44153333fc';
  117. var myAmapFun = new amapFile.AMapWX({
  118. key: key
  119. });
  120. // 1 还没接到人 所在地到起点,起点到终点
  121. let arr = ['0', '1', '5', '4']
  122. if (arr.includes(this.info.status)) {
  123. this.lineData(myAmapFun, this.longitude + ',' + this.latitude, this.info.start_longitude + ',' + this.info.start_latitude,
  124. "#ff4b4e")
  125. this.lineData(myAmapFun, this.info.start_longitude + ',' + this.info.start_latitude, this.info.end_longitude + ',' +
  126. this.info.end_latitude,
  127. "#28d32e")
  128. }
  129. // 2 途中 所在地到终点
  130. if (this.info.status == 2) {
  131. this.lineData(myAmapFun, this.info.start_longitude + ',' + this.info.start_latitude, this.longitude + ',' + this.latitude,
  132. "#c6c6c5")
  133. this.lineData(myAmapFun, this.longitude + ',' + this.latitude, this.info.end_longitude + ',' + this.info.end_latitude,
  134. "#28d32e")
  135. }
  136. // 3 完成、取消、待支付:起点到终点
  137. let arr1 = ['-2', '-1', '3', '99']
  138. if (arr1.includes(this.info.status)) {
  139. this.lineData(myAmapFun, this.info.start_longitude + ',' + this.info.start_latitude, this.info.end_longitude + ',' +
  140. this.info.end_latitude,
  141. "#28d32e")
  142. }
  143. },
  144. lineData(myAmapFun, origin, destination, color) {
  145. let that = this
  146. myAmapFun.getDrivingRoute({
  147. origin,
  148. destination,
  149. success(data) {
  150. if (data.paths && data.paths[0] && data.paths[0].steps) {
  151. var steps = data.paths[0].steps;
  152. var points = [];
  153. for (var i = 0; i < steps.length; i++) {
  154. var poLen = steps[i].polyline.split(';');
  155. for (var j = 0; j < poLen.length; j++) {
  156. points.push({
  157. longitude: parseFloat(poLen[j].split(',')[0]),
  158. latitude: parseFloat(poLen[j].split(',')[1])
  159. })
  160. }
  161. }
  162. }
  163. that.polyline.push({
  164. points: points,
  165. color,
  166. width: 10,
  167. arrowLine: true,
  168. })
  169. },
  170. fail(info) {
  171. console.log(444444, info);
  172. }
  173. });
  174. },
  175. toNav(status) {
  176. let _this = this;
  177. uni.getSystemInfo({
  178. success(res) {
  179. console.log(res.platform);
  180. if(res.platform=='android'){
  181. if (status == 2) {
  182. plus.runtime.openURL("androidamap://navi?sourceApplication=ddcar&lat=" + _this.info.end_latitude + "&lon=" + _this.info
  183. .end_longitude + "&dev=0&style=2")
  184. } else {
  185. plus.runtime.openURL("androidamap://navi?sourceApplication=appname&lat=" + _this.info.start_latitude + "&lon=" +
  186. _this.info.start_longitude + "&dev=0&style=2")
  187. }
  188. }else if(res.platform=='ios'){
  189. if (status == 2) {
  190. plus.runtime.openURL("iosamap://navi?sourceApplication=ddcar&lat=" + _this.info.end_latitude + "&lon=" + _this.info
  191. .end_longitude + "&dev=0&style=2")
  192. } else {
  193. plus.runtime.openURL("iosamap://navi?sourceApplication=appname&lat=" + _this.info.start_latitude + "&lon=" +
  194. _this.info.start_longitude + "&dev=0&style=2")
  195. }
  196. }
  197. }
  198. })
  199. },
  200. toAnquan() {
  201. uni.navigateTo({
  202. url: '/pages/home/security'
  203. })
  204. },
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. .navigation {
  210. position: fixed;
  211. right: 10rpx;
  212. top: 100rpx;
  213. width: 100rpx;
  214. height: 100rpx;
  215. }
  216. .datpay{
  217. height: 300rpx;
  218. }
  219. </style>