index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class='bg-white' style="padding-bottom: 400rpx;">
  3. <u-tabs :list="list" :is-scroll="false" bar-width="0" active-color="#00C28E" :current="current" @change="change" style="box-shadow: 0px 0px 13px 0px rgba(0,194,142, 0.14);"></u-tabs>
  4. <view class="pd-36 center" v-if="info">
  5. <image :src="info.car_image" style="width: 260rpx;height: 180rpx;" mode=""></image>
  6. <view class="ml-30">
  7. <view>载重{{info.load}}</view>
  8. <view class="bold mtb-20">长宽高{{info.length}}*{{info.width}}*{{info.height}}米</view>
  9. <view class="gray-2">载货体积{{info.volume}}方</view>
  10. </view>
  11. </view>
  12. <!-- 起始点 -->
  13. <view class="plr-36 bg">
  14. <view class="flex_l ptb-30 bb" @click="getAddress(1)">
  15. <view class="bg-green radius mt-10" style="width: 16rpx;height: 16rpx;"></view>
  16. <view class="ml-30">
  17. <view class="">{{start.name}}</view>
  18. <view class="size-28 mt-10 gray-2">{{start.address}}</view>
  19. </view>
  20. </view>
  21. <view class="flex_l ptb-30 bb" v-for="(item,i) in hyaddress" :key="i">
  22. <view class="bg-orange radius mt-10" style="width: 16rpx;height: 16rpx;"></view>
  23. <view class="ml-30 u-flex-1 flex">
  24. <view v-if="item.address" class="u-flex-1 mr-20">
  25. <view class="">{{item.address.name}}</view>
  26. <view class="size-28 mt-10 gray-2">{{item.address.address}}</view>
  27. </view>
  28. <u-icon class="size-38" @click="delAddr(i)" name="close-circle" color="#"></u-icon>
  29. </view>
  30. </view>
  31. <view class="flex_l ptb-30 bb" v-if="hyaddress&&hyaddress.length==0">
  32. <view class="bg-red radius mt-10" style="width: 28rpx;height: 28rpx;"></view>
  33. <view class="ml-30">
  34. <view class="gray-2" @click="toAddress">请选择收货地址</view>
  35. </view>
  36. </view>
  37. <view class="gray-2 pd-25" v-else @click="toAddress">+添加收货地</view>
  38. </view>
  39. <view class="fixed-bottom bg-white">
  40. <view v-if="hylist&&hylist.length>0&&hylist[0]">
  41. <!-- 代驾 -2=已超时,-1=已取消,0=呼叫中,1=已接单,2=进行中,3=待支付,4=司机已到达,5=预约单待司机出发,99=已完成 -->
  42. <image src="../../static/hy-1.png" v-show="hylist[0].status==0" @click="toDetail" style="width: 100%;height: 120rpx;" mode=""></image>
  43. <image src="../../static/hy-2.png" v-show="hylist[0].status==1||hylist[0].status==5" @click="toDetail" style="width: 100%;height: 120rpx;" mode=""></image>
  44. <image src="../../static/hy-3.png" v-show="hylist[0].status==4" @click="toDetail" style="width: 100%;height: 120rpx;" mode=""></image>
  45. <image src="../../static/hy-4.png" v-show="hylist[0].status==2||hylist[0].status==3" @click="toDetail" style="width: 100%;height: 120rpx;" mode=""></image>
  46. </view>
  47. <view class="center pt-20">
  48. <view class="red bold">
  49. <text class="size-26">¥</text>
  50. <text class="size-40">{{price||'--'}}</text>
  51. </view>
  52. <view class="size-26 ml-20 green" @click="toCharge">费用标准</view>
  53. </view>
  54. <view class="flex pd-30">
  55. <view @click="toConfirm" class="u-flex-1 center white bg-green border-green text-center" style="height: 90rpx;">现在用车</view>
  56. <view class="u-flex-1 center green border-green ml-30" style="height: 90rpx;" @click="getTime">
  57. <image src="../../static/hy-time.png" style="width: 40rpx;height: 40rpx;" mode=""></image>
  58. <view class="ml-20">
  59. <view>{{time}}</view>
  60. <view @click="time='预约'" v-show="time!='预约'" style="width: 70rpx;" class="size-22 bg-green center white radius-10">重置</view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <!-- 时间 -->
  66. <u-popup v-model="showTime" mode="bottom" height="400" @close="showTime=false">
  67. <longDate type="day" :openStatus="true" :getDayNum="3" :chooesMaxDay="3" @select="onSelectTime">
  68. </longDate>
  69. </u-popup>
  70. </view>
  71. </template>
  72. <script>
  73. import {
  74. mapState
  75. } from 'vuex'
  76. import amapFile from '../../libs/amap-wx.js'
  77. import longDate from '../long-date/long-date.vue'
  78. export default {
  79. data() {
  80. return {
  81. list: [],
  82. carList: [],
  83. current: 0,
  84. time: '预约',
  85. showTime: false,
  86. price: '--',
  87. }
  88. },
  89. components: {
  90. longDate
  91. },
  92. props:["hylist"],
  93. computed: {
  94. ...mapState(["start", "hyaddress"]),
  95. info() {
  96. return this.carList[this.current]
  97. }
  98. },
  99. watch: {
  100. start(newVal) {
  101. if (this.hyaddress.length > 0&& this.list.length>0) {
  102. this.getPrice()
  103. }
  104. },
  105. hyaddress(newVal) {
  106. if (Object.keys(this.start).length > 0 ) {
  107. this.getPrice()
  108. }
  109. },
  110. current(newVal) {
  111. if (this.hyaddress.length > 0 && Object.keys(this.start).length > 0) {
  112. this.getPrice()
  113. }
  114. }
  115. },
  116. mounted() {
  117. this.$http('/addons/ddrive/freight/car_name').then(data => {
  118. this.list = data
  119. })
  120. this.$http('/addons/ddrive/freight/carInfo').then(data => {
  121. this.carList = data
  122. })
  123. uni.$on('price',()=>{
  124. this.current =0
  125. if (this.hyaddress.length > 0 && Object.keys(this.start).length > 0) {
  126. this.getPrice()
  127. }
  128. })
  129. },
  130. methods: {
  131. toDetail() {
  132. if (this.hylist.length == 1) {
  133. uni.navigateTo({
  134. url: '/pages/huoyun/order-detail?id=' + this.hylist[0].id
  135. })
  136. } else {
  137. uni.navigateTo({
  138. url: '/pages/huoyun/order'
  139. })
  140. }
  141. },
  142. getPrice() {
  143. this.$http('/addons/ddrive/hyorder/amount', {
  144. start_lat: this.start.latitude,
  145. start_lng: this.start.longitude,
  146. end_address: JSON.stringify(this.hyaddress),
  147. car_id: this.list[this.current].id
  148. }, "POST").then(data => {
  149. this.price = data.distance_price
  150. }).catch(() => {
  151. this.price = '--'
  152. })
  153. },
  154. change(index) {
  155. this.current = index;
  156. },
  157. toCharge() {
  158. uni.navigateTo({
  159. url: '/pages/huoyun/charge?tab=' + this.current
  160. })
  161. },
  162. toAddress() {
  163. uni.navigateTo({
  164. url: '/pages/huoyun/address'
  165. })
  166. },
  167. getAddress(type) {
  168. let location = this.start.longitude + ',' + this.start.latitude
  169. uni.navigateTo({
  170. url: '/pages/home/search?type=' + type + '&location=' + location
  171. })
  172. },
  173. delAddr(index) {
  174. this.$store.commit('delHyAddress', index)
  175. },
  176. // 选时间
  177. getTime() {
  178. this.showTime = true
  179. },
  180. // 确定时间
  181. onSelectTime(res) {
  182. console.log(res);
  183. if (res.tip) {
  184. uni.showToast({
  185. title: res.tip,
  186. icon: 'none'
  187. })
  188. } else {
  189. this.time = res.time
  190. this.showTime = false
  191. this.toConfirm()
  192. this.time = '预约'
  193. }
  194. },
  195. confirmTime(time) {
  196. console.log(time);
  197. },
  198. toConfirm() {
  199. if (this.hyaddress.length == 0) {
  200. uni.showToast({
  201. title: '请选择目的地',
  202. icon: 'none'
  203. })
  204. } else {
  205. uni.navigateTo({
  206. url: '/pages/huoyun/confirm-order?time=' + this.time + '&id=' + this.list[this.current].id + '&price=' + this.price
  207. })
  208. }
  209. }
  210. }
  211. }
  212. </script>
  213. <style scoped lang='scss'>
  214. </style>