order-detail.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view style="padding-bottom: 190rpx;">
  3. <view class="mlr-36 mt-30" style="box-shadow: 0px 0px 13px 0px rgba(18, 0, 98, 0.2);">
  4. <sfItem :item="info" type="2" :button="false"></sfItem>
  5. <!-- -1=已取消,1=待接单,2=待确认,3=待出发,4=行驶中,5=已完成 -->
  6. <!-- 待确认--总费用 -->
  7. <view class="bt ptb-20" v-if="info.status==2">
  8. <view class=" size-32 text-center">
  9. 订单总费用
  10. </view>
  11. <u-field v-model="price" label-width="0" placeholder="请输入金额"></u-field>
  12. </view>
  13. </view>
  14. <view class="plr-36 size-26 gray-2 mtb-30" v-if="info.status==2">
  15. 注:请尽快与乘客联系,协商好订单总费用后填写费用再发送给乘客
  16. </view>
  17. <!-- 待出发--预留座位 -->
  18. <view v-for="(item,i) in info.chil_order" :key="i" v-if="info.order_type==2">
  19. <view class="bg-blue white pd-30 size-28 mlr-36">
  20. <view class="flex">
  21. <view class="">
  22. 预留座位:{{item.people_num}}人
  23. </view>
  24. <view class="">
  25. ¥{{item.car_price}}
  26. </view>
  27. </view>
  28. <view class="flex mt-10" @click="call(item.tel)">
  29. <view class="">
  30. 联系方式:{{item.tel}}
  31. </view>
  32. <view class="img">
  33. <image src="../../static/phone-white.png" mode=""></image>
  34. </view>
  35. </view>
  36. <view class="flex mt-10">
  37. <view class="">
  38. 上车地点:{{item.start_address}}
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 行程中--线下结算 -->
  43. <view class="bg-grey mlr-36" v-if="info.status==4&&item.pay_status==0">
  44. <u-button type="default" @click="offline(item.id)">确认线下结算</u-button>
  45. </view>
  46. </view>
  47. <!-- 按钮 -->
  48. <view class="fixed-bottom bg-white pb-50 pt-20">
  49. <view class="mlr-36 mt-20" v-if="info.status==-1">
  50. <u-button type="primary" @click="toHome">重新接单</u-button>
  51. </view>
  52. <view class="cancel mlr-36" v-if="info.status==2">
  53. <u-button type="primary" @click="cancle">取消订单</u-button>
  54. </view>
  55. <view class="mlr-36 mt-20" v-if="info.status==2">
  56. <u-button type="primary" @click="confirm">确认发送订单价格给乘客</u-button>
  57. </view>
  58. <view class="mlr-36 mt-20" v-if="info.status==1||info.status==3">
  59. <u-button type="primary" @click="go">开始出发</u-button>
  60. </view>
  61. <view class="cancel mlr-36" v-if="info.status==4&&info.order_type==1&&info.pay_status==0">
  62. <u-button type="primary" @click="offline('')">确认线下结算</u-button>
  63. </view>
  64. <view class="mlr-36 mt-20" v-if="info.status==4">
  65. <u-button type="primary" @click="over">行程结束</u-button>
  66. </view>
  67. <view class="mlr-36 mt-20" v-if="info.status==5">
  68. <u-button type="primary" @click="toHome">已完成,继续接单</u-button>
  69. </view>
  70. </view>
  71. <u-modal v-model="show" :content="content" :show-title="false" :confirm-style="{background:'#286ceb'}" confirm-color="#fff"></u-modal>
  72. <u-modal @confirm="confirmOff" :show-cancel-button="true" v-model="showOff" :content="contentOff" :show-title="false"
  73. :confirm-style="{background:'#286ceb'}" confirm-color="#fff"></u-modal>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. id: '',
  81. cid:'', //子单id
  82. info: {}, //-1=已取消,1=待接单,2=待确认,3=待出发,4=行驶中,5=已完成
  83. price: '',
  84. content: '乘客还未支付,请乘客支付后再进行此操作',
  85. contentOff: '请先确认收到乘客线下付款,否则一切损失平台概不负责',
  86. show: false,
  87. showOff: false,
  88. timer:null,
  89. //乘客发布:待确认,待出发:轮询顾客是否取消
  90. arr:[2,3], //order_type 1用户发 2 司机发
  91. };
  92. },
  93. onLoad(option) {
  94. this.id = option.id
  95. clearInterval(this.timer)
  96. this.timer = null
  97. this.init()
  98. },
  99. onUnload() {
  100. clearInterval(this.timer)
  101. this.timer = null
  102. },
  103. onHide() {
  104. clearInterval(this.timer)
  105. this.timer = null
  106. },
  107. methods: {
  108. init() {
  109. this.$http('/addons/ddrive/sforder/info', {
  110. order_id: this.id
  111. }, "POST").then((data) => {
  112. this.info = data
  113. uni.setNavigationBarTitle({
  114. title: this.info.statusText
  115. })
  116. //乘客发布:待接单,待确认,待出发:轮询顾客是否取消
  117. //司机发布:待出发:轮询顾客是否取消
  118. if((data.order_type==1&&this.arr.includes(data.status*1))||(data.order_type==2&&data.status==3)){
  119. if(!this.timer){
  120. this.timer = setInterval(()=>{
  121. this.init()
  122. },3000)
  123. }
  124. }else{
  125. clearInterval(this.timer)
  126. this.timer = null
  127. }
  128. })
  129. },
  130. toHome() {
  131. uni.reLaunch({
  132. url: '/pages/home/index'
  133. })
  134. },
  135. // 线下结算
  136. offline(id) {
  137. if (id) {
  138. //司机发布——子单
  139. this.cid = id
  140. this.showOff = true
  141. } else {
  142. //乘客发布
  143. this.showOff = true
  144. }
  145. },
  146. // 确认
  147. confirmOff() {
  148. this.$http('/addons/ddrive/sforder/offline_settlement', {
  149. order_id: this.cid?this.cid:this.id
  150. }, "POST").then(() => {
  151. uni.showToast({
  152. title: '付款成功'
  153. })
  154. setTimeout(() => {
  155. this.init()
  156. }, 1000)
  157. })
  158. },
  159. // 取消订单
  160. cancle() {
  161. this.$http('/addons/ddrive/sforder/cancel', {
  162. order_id: this.id
  163. }, "POST").then(() => {
  164. uni.showToast({
  165. title: '取消成功'
  166. })
  167. setTimeout(() => {
  168. uni.navigateBack();
  169. }, 1000)
  170. })
  171. },
  172. // 确认订单价格
  173. confirm() {
  174. if (!this.price) {
  175. uni.showToast({
  176. title: '请输入金额',
  177. icon: 'none'
  178. })
  179. } else {
  180. this.$http('/addons/ddrive/sforder/confirm', {
  181. order_id: this.id,
  182. order_money: this.price
  183. }, "POST").then(() => {
  184. uni.showToast({
  185. title: '发送成功'
  186. })
  187. setTimeout(() => {
  188. this.init()
  189. }, 1000)
  190. })
  191. }
  192. },
  193. // 开始出发
  194. go() {
  195. this.$http('/addons/ddrive/sforder/set_out', {
  196. order_id: this.id
  197. }, "POST").then(() => {
  198. this.init()
  199. })
  200. },
  201. // 结束行程
  202. over() {
  203. if (this.info.pay_status == 0) {
  204. this.show = true
  205. } else {
  206. this.$http('/addons/ddrive/sforder/order_complete', {
  207. order_id: this.id
  208. }, "POST").then(() => {
  209. this.init()
  210. })
  211. }
  212. },
  213. //打电话
  214. call(tel) {
  215. uni.makePhoneCall({
  216. phoneNumber: tel //仅为示例
  217. });
  218. },
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. /deep/.u-btn--primary {
  224. border-radius: 0;
  225. }
  226. /deep/.u-primary-hover {
  227. background-color: $blue !important;
  228. }
  229. /deep/.u-size-default {
  230. width: 100% !important;
  231. height: 88rpx !important;
  232. font-weight: 700 !important;
  233. }
  234. .img {
  235. image {
  236. width: 54rpx;
  237. height: 54rpx;
  238. }
  239. }
  240. .cancel {
  241. /deep/.u-btn--primary {
  242. color: $blue;
  243. background: none !important;
  244. border: 1rpx solid rgba(18, 0, 98, 0.2);
  245. }
  246. }
  247. </style>