order-detail.vue 8.0 KB

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