placeOrders.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <view style="padding-bottom: 100rpx;">
  3. <!-- #ifdef H5 -->
  4. <u-sticky :h5-nav-height="0" @fixed="xdCheck" @unfixed="noXDCheck">
  5. <!-- #endif -->
  6. <!-- #ifndef H5 -->
  7. <u-sticky @fixed="xdCheck" @unfixed="noXDCheck">
  8. <!-- #endif -->
  9. <view style="background: #FFFFFF;">
  10. <u-dropdown :menu-icon='menuicon' ref="uDropdown" @open="open" @close="close" menu-icon-size="18">
  11. <u-dropdown-item v-model="value1" :title="mrtitle">
  12. <view class="slot-content padding" style="background: #FFFFFF;">
  13. <view class="addbox bg" @click="goCFAddress(2)">
  14. <view class="add_cont">
  15. <view class="orgin"></view>
  16. <view class="add_tit" v-if="addlists.city === ''">选择出发地城市</view>
  17. <view class="add_tit" v-else>{{addlists.city}}</view>
  18. </view>
  19. <view>
  20. <image src="../../static/image/go.png" style="width: 16rpx;height: 25rpx;">
  21. </image>
  22. </view>
  23. </view>
  24. <view class="addbox bg" @click="goCFAddress(2)">
  25. <view class="add_cont">
  26. <u-input v-model="addlists.address" type="text" placeholder="请输入出发地地址"
  27. :border="true" :clearable="true"
  28. style="border: none;width: 610rpx;height: 100%;" />
  29. </view>
  30. </view>
  31. <view class="flex justify-between">
  32. <view class="qc_btn" @tap="goQC(2)">清除</view>
  33. <view class="sx_btn" @tap="goCX">查询</view>
  34. </view>
  35. </view>
  36. </u-dropdown-item>
  37. <u-dropdown-item v-model="value2" :title="carname">
  38. <view class="slot-content padding" style="background: #FFFFFF;">
  39. <view class="addbox bg" @click="goCFAddress(1)">
  40. <view class="add_cont">
  41. <view class="orgin"></view>
  42. <view class="add_tit" v-if="addlist.city === ''">选择目的地城市</view>
  43. <view class="add_tit" v-else>{{addlist.city}}</view>
  44. </view>
  45. <view>
  46. <image src="../../static/image/go.png" style="width: 16rpx;height: 25rpx;">
  47. </image>
  48. </view>
  49. </view>
  50. <view class="addbox bg" @click="goCFAddress(1)">
  51. <view class="add_cont">
  52. <u-input v-model="addlist.address" type="text" placeholder="请输入目的地地址"
  53. :border="true" :clearable="true"
  54. style="border: none;width: 610rpx;height: 100%;" />
  55. </view>
  56. </view>
  57. <view class="flex justify-between">
  58. <view class="qc_btn" @tap="goQC(1)">清除</view>
  59. <view class="sx_btn" @tap="goCX">查询</view>
  60. </view>
  61. </view>
  62. </u-dropdown-item>
  63. </u-dropdown>
  64. </view>
  65. </u-sticky>
  66. <view class="myOrder_itemView" v-for="(item,index) in orderList" @tap="goDetail(item)">
  67. <view style="padding: 30rpx 40rpx 30rpx;">
  68. <view class="flex justify-between align-center">
  69. <view class="item_title">{{item.appointmentStartTime}}</view>
  70. <view style="color: #346EF6;font-weight: bold;">等待接单中...</view>
  71. </view>
  72. <view class="flex align-center add_name" style="margin: 30rpx 6rpx 10rpx;">
  73. <view class="green"></view>出发地点:{{item.shipCity}} {{item.shipAddress}}
  74. </view>
  75. <image src="/static/upload/up.png" class="order_up"></image>
  76. <view class="flex align-center add_name" style="margin-left: 6rpx;margin-top: 6rpx;">
  77. <view class="orgin"></view>到达地点:{{item.deliveryCity}} {{item.deliveryAddress}}
  78. </view>
  79. <view class="margin-top flex align-center justify-between">
  80. <view class="flex align-center">
  81. <image src="/static/upload/person.png" style="width: 30rpx;height: 31rpx;"></image>
  82. <view style="margin-left: 16rpx;width: fit-content;" class="item_addName">
  83. {{item.appointmentNum}}人乘坐
  84. </view>
  85. </view>
  86. <!-- <view class="item_juli">订单里程{{item.kmDistance}}km</view> -->
  87. </view>
  88. </view>
  89. <u-line color="#E6E6E6" />
  90. <view style="padding: 30rpx 40rpx 0rpx;display: flex;justify-content: space-between;">
  91. <view class="item_money">一口价:<text style="font-size: 32rpx;">¥</text><text>{{item.driveMoney}}</text>
  92. </view>
  93. <view class="item_btn" @tap="save(item)">立即接单</view>
  94. </view>
  95. </view>
  96. <empty v-if="orderList.length == 0"></empty>
  97. </view>
  98. </template>
  99. <script>
  100. import empty from '@/components/empty'
  101. export default {
  102. components: {
  103. empty
  104. },
  105. data() {
  106. return {
  107. addlists: {
  108. city: '',
  109. address: ''
  110. },
  111. addlist: {
  112. city: '',
  113. address: ''
  114. },
  115. itemDetail: {},
  116. mrtitle: '筛选出发地',
  117. carname: '筛选目的地',
  118. menuicon: 'arrow-down-fill',
  119. value1: 1,
  120. value2: 2,
  121. page: 1,
  122. limit: 10,
  123. orderList: [],
  124. indentNumber: '',
  125. openLists: [],
  126. showpay: false,
  127. isDrop: false, //是否打开下拉筛选
  128. openWay: 1
  129. }
  130. },
  131. onLoad(d) {
  132. this.page = 1;
  133. this.getMyOrderList();
  134. this.getCityList();
  135. },
  136. onShow() {
  137. let userId = uni.getStorageSync('userId')
  138. if (!userId) {
  139. uni.navigateTo({
  140. url: '/pages/login/login'
  141. })
  142. }
  143. },
  144. methods: {
  145. open(index) {
  146. this.$refs.uDropdown.highlight();
  147. this.isDrop = true
  148. },
  149. close(index) {
  150. console.log('close', index)
  151. // 关闭的时候,给当前项加上高亮
  152. // 当然,您也可以通过监听dropdown-item的@change事件进行处理
  153. this.$refs.uDropdown.highlight(index);
  154. this.isDrop = false
  155. },
  156. goQC(index) {
  157. if (index == 1) {
  158. let addlist = {
  159. city: '',
  160. address: ''
  161. }
  162. this.addlist = addlist
  163. }
  164. if (index == 2) {
  165. let addlists = {
  166. city: '',
  167. address: ''
  168. }
  169. this.addlists = addlists
  170. }
  171. if (this.isDrop) {
  172. this.$refs.uDropdown.close();
  173. }
  174. this.page = 1;
  175. this.getMyOrderList();
  176. },
  177. goCX() {
  178. if (this.isDrop) {
  179. this.$refs.uDropdown.close();
  180. }
  181. this.page = 1;
  182. this.getMyOrderList();
  183. },
  184. goCFAddress(index) {
  185. let that = this
  186. uni.chooseLocation({
  187. success: function(res) {
  188. console.log('位置名称:' + res.name);
  189. console.log('详细地址:' + res.address);
  190. console.log('纬度:' + res.latitude);
  191. console.log('经度:' + res.longitude);
  192. if (index == 1) {
  193. that.addlist.address = res.name
  194. that.addlist.lng = res.longitude
  195. that.addlist.lat = res.latitude
  196. let data = {
  197. lat: res.latitude,
  198. lng: res.longitude
  199. }
  200. that.$Request.getT('/app/Login/selectCity', data).then(res => {
  201. if (res.code === 0) {
  202. that.addlist.province = res.data.province
  203. that.addlist.city = res.data.city
  204. that.addlist.district = res.data.district
  205. }
  206. });
  207. } else if (index == 2) {
  208. that.addlists.address = res.name
  209. that.addlists.lng = res.longitude
  210. that.addlists.lat = res.latitude
  211. let data = {
  212. lat: res.latitude,
  213. lng: res.longitude
  214. }
  215. that.$Request.getT('/app/Login/selectCity', data).then(res => {
  216. if (res.code === 0) {
  217. that.addlists.province = res.data.province
  218. that.addlists.city = res.data.city
  219. that.addlists.district = res.data.district
  220. }
  221. });
  222. }
  223. }
  224. });
  225. },
  226. getCityList() {
  227. this.$Request.getT('/app/fixedStroke/selectShipCityList').then(res => {
  228. if (res.code == 0) {
  229. }
  230. });
  231. this.$Request.getT('/app/fixedStroke/selectDeliveryCityList').then(res => {
  232. if (res.code == 0) {
  233. }
  234. });
  235. },
  236. save(item) {
  237. let userId = this.$queue.getData('userId');
  238. let that = this;
  239. uni.showModal({
  240. title: '提示',
  241. content: '确定抢单吗?',
  242. success: function(res) {
  243. if (res.confirm) {
  244. // console.log('用户点击确定');
  245. that.$Request.postT(
  246. '/app/orders/takingOrders?ordersId=' +
  247. item.ordersId + '&userId=' + userId)
  248. .then(res => {
  249. if (res.code == 0) {
  250. uni.showToast({
  251. title: '接单成功',
  252. icon: 'none'
  253. })
  254. that.page = 1;
  255. that.getMyOrderList();
  256. setTimeout(function() {
  257. uni.switchTab({
  258. url: '/pages/order/order'
  259. })
  260. }, 1000)
  261. } else {
  262. uni.showToast({
  263. title: res.msg,
  264. icon: 'none',
  265. duration: 1500
  266. })
  267. }
  268. });
  269. } else if (res.cancel) {
  270. // console.log('用户点击取消');
  271. }
  272. }
  273. });
  274. },
  275. getMyOrderList() {
  276. this.$queue.showLoading('加载中...')
  277. let userId = this.$queue.getData('userId');
  278. this.$Request.getT('/app/orders/selectOrdersList?isFixedStroke=1&page=' + this.page + '&limit=' + this
  279. .limit + '&shipCity=' + this.addlists.city + '&shipAddress=' + this.addlists.address +
  280. '&deliveryCity=' + this.addlist.city + '&deliveryAddress=' + this.addlist.address + '&driverUserId=' + userId + '&status=2').then(res => {
  281. if (res.code == 0 && res.data) {
  282. if (this.page == 1) {
  283. this.orderList = res.data.list
  284. } else {
  285. this.orderList = [...this.orderList, ...res.data.list]
  286. }
  287. uni.hideLoading();
  288. uni.stopPullDownRefresh();
  289. }
  290. });
  291. }
  292. },
  293. // 上拉加载
  294. onReachBottom: function() {
  295. this.page = this.page + 1;
  296. this.getMyOrderList();
  297. },
  298. onPullDownRefresh: function() {
  299. this.page = 1;
  300. this.getMyOrderList();
  301. }
  302. }
  303. </script>
  304. <style lang="scss">
  305. page {
  306. background: #F5F5F5;
  307. }
  308. .qc_btn {
  309. margin: 0 10rpx 10rpx;
  310. width: 320rpx;
  311. padding: 0 30rpx;
  312. height: 90rpx;
  313. border-radius: 50rpx;
  314. text-align: center;
  315. line-height: 90rpx;
  316. background: #346EF6;
  317. font-family: PingFang SC;
  318. font-weight: 500;
  319. font-size: 30rpx;
  320. color: #FFFFFF;
  321. }
  322. .sx_btn {
  323. margin: 0 10rpx 10rpx;
  324. width: 320rpx;
  325. padding: 0 30rpx;
  326. height: 90rpx;
  327. border-radius: 50rpx;
  328. text-align: center;
  329. line-height: 90rpx;
  330. background: #346EF6;
  331. font-family: PingFang SC;
  332. font-weight: 500;
  333. font-size: 30rpx;
  334. color: #FFFFFF;
  335. }
  336. .addbox {
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. margin: 0 10rpx 30rpx;
  341. padding: 0 30rpx;
  342. height: 110rpx;
  343. border-radius: 16rpx;
  344. }
  345. .add_cont {
  346. display: flex;
  347. align-items: center;
  348. }
  349. .add_tit {
  350. font-size: 30rpx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #333333;
  354. margin-left: 10rpx;
  355. }
  356. .bg {
  357. background: #F5F5F5;
  358. }
  359. .box_money {
  360. font-family: PingFang SC;
  361. font-weight: 500;
  362. font-size: 28rpx;
  363. color: #030303;
  364. margin-bottom: 30rpx;
  365. margin-top: 10rpx;
  366. text {
  367. font-size: 40rpx;
  368. color: #FF2020;
  369. font-weight: bold;
  370. }
  371. }
  372. .box_item {
  373. padding: 0 20rpx;
  374. display: flex;
  375. align-items: center;
  376. width: 520rpx;
  377. height: 100rpx;
  378. background: #F7F7F7;
  379. border-radius: 16rpx;
  380. justify-content: space-between;
  381. }
  382. .add_tit {
  383. font-size: 30rpx;
  384. font-family: PingFang SC;
  385. font-weight: bold;
  386. color: #333333;
  387. margin-left: 10rpx;
  388. }
  389. .myOrder_itemView {
  390. width: 686rpx;
  391. // height: 549rpx;
  392. background: #FFFFFF;
  393. border-radius: 32rpx;
  394. margin: 0 auto;
  395. margin-top: 20rpx;
  396. padding-bottom: 40rpx;
  397. }
  398. .item_title {
  399. font-family: Source Han Sans CN;
  400. font-weight: 600;
  401. font-size: 32rpx;
  402. color: #242424;
  403. }
  404. .order_up {
  405. width: 6rpx;
  406. height: 24rpx;
  407. margin-left: 12rpx;
  408. }
  409. .add_name {
  410. font-family: PingFang SC;
  411. font-weight: 500;
  412. font-size: 28rpx;
  413. color: #101010;
  414. }
  415. .green {
  416. width: 16rpx;
  417. height: 16rpx;
  418. background: #1FC657;
  419. border-radius: 50%;
  420. margin-right: 20rpx;
  421. }
  422. .item_money {
  423. font-family: PingFang SC;
  424. font-weight: 500;
  425. font-size: 28rpx;
  426. color: #101010;
  427. text {
  428. font-size: 42rpx;
  429. color: #FF2020;
  430. font-weight: bold;
  431. }
  432. }
  433. .item_btn {
  434. width: 150rpx;
  435. height: 58rpx;
  436. background: #346EF6;
  437. border-radius: 30rpx;
  438. text-align: center;
  439. line-height: 58rpx;
  440. font-family: PingFang SC;
  441. font-weight: 500;
  442. font-size: 24rpx;
  443. color: #FFFFFF;
  444. }
  445. .orgin {
  446. width: 16rpx;
  447. height: 16rpx;
  448. background: #FBAC04;
  449. border-radius: 50%;
  450. margin-right: 20rpx;
  451. }
  452. </style>