index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <!-- 货源 -->
  2. <template>
  3. <view class="content">
  4. <view class="banner">
  5. <image class="banner-img" src="@/static/images/goodSource/banner@2x.png" mode='widthFix'></image>
  6. <view class="head flex s-row paddingr35">
  7. <view class="flex flex-space-between">
  8. <view class="flex s-row item1" @click="goCity(0)">
  9. <view class="fontsize-28 gray">装车</view>
  10. <view class="fontsize-46 fontweight-500 text">{{startPlace.selected}}</view>
  11. </view>
  12. <image class="change-btn item2" src="@/static/images/goodSource/change.png" mode='widthFix'
  13. @click="changeCity"></image>
  14. <view class="flex s-row item3" @click="goCity(1)">
  15. <view class="fontsize-28 gray text-align-right">卸车</view>
  16. <view class="fontsize-46 fontweight-500 text">{{endPlace.selected}}</view>
  17. </view>
  18. </view>
  19. <view>
  20. <u-button type="" class="btn-color fontsize-36 m-top20" @click="upCallback()"> 查询</u-button>
  21. </view>
  22. </view>
  23. </view>
  24. <view :class="scrollTop>1200?'fixed1':''"></view>
  25. <view class="tab-view">
  26. <u-tabs :list="tabList" @click="clickTab" :lineColor="scrollTop>1200?'white':'#303133'" :current='tabIndex'
  27. :inactiveStyle="{color: scrollTop>1200?'white':'',}" :activeStyle="{
  28. color: scrollTop>1200?'white':'',
  29. fontWeight: 'bold',
  30. transform: 'scale(1.05)'
  31. }" :class="scrollTop>1200?'fixed':''"></u-tabs>
  32. <view class="tab-right" @click="selectType">
  33. <view>{{pickerSelect}}</view>
  34. <u-icon name="arrow-down" size="20"></u-icon>
  35. </view>
  36. </view>
  37. <u-picker :show="show" :columns="columns" :closeOnClickOverlay='true' @close='selectTypeClose'
  38. @cancel='selectTypeClose' @confirm='confirmSelectType'></u-picker>
  39. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  40. <view :id="'good'+good.id" class="good-list" v-for="good in goods" :key="good.id"
  41. @click="toDetail(good.id)">
  42. <view style="padding: 0 35rpx 20rpx 35rpx;">
  43. <view class="flex flex-space-between">
  44. <view class="item1">
  45. <view class="ssx">辽</view>
  46. <view class="level2-title">{{good.sendCity}} {{good.sendArea}}</view>
  47. </view>
  48. <image class="jt-icon item2" src="@/static/images/goodSource/jt.png" mode='widthFix'></image>
  49. <view class="item3">
  50. <view class="ssx">京</view>
  51. <view class="level2-title">{{good.unloadCity}} {{good.unloadArea}}</view>
  52. </view>
  53. </view>
  54. <view class="right gray">
  55. 01.10
  56. </view>
  57. <view class="flex flex-space-between">
  58. <view class="left">
  59. <view class="flex">
  60. <view class="fontsize-25 gray mr20">货距 {{good.cargoDistance}}km</view>
  61. <view class="fontsize-25 gray ">运距 {{good.distance}}km</view>
  62. </view>
  63. <view class="flex fontsize-25 gray row">
  64. <view>{{good.goodsName}} | </view>
  65. <view>{{carLength(good)}} | {{carType(good)}} | {{carWeight(good)}}</view>
  66. </view>
  67. <view class="flex row">
  68. <view class="row-tips">{{good.taskDescription}}</view>
  69. </view>
  70. </view>
  71. <view class="right flex h-color">
  72. <view class="fontsize-46">
  73. {{good.freightPrice}}
  74. </view>
  75. <view class="flex dw">元/吨</view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="flex flex-space-between item-bottom">
  80. <view class="left flex row">
  81. <u--image :showLoading="true" :src="good.cargoOwnerPortrait" width="70rpx" height="70rpx"
  82. shape="circle">
  83. </u--image>
  84. <view class="name">{{good.cargoOwnerName}}</view>
  85. <!-- <view class="hp flex fontsize-24">
  86. <view class="gray">评分</view>
  87. <view class="number-color">99%</view>
  88. </view>
  89. <view class="sum flex fontsize-24">
  90. <view class="gray">发运次数</view>
  91. <view class="number-color">106</view>
  92. </view> -->
  93. </view>
  94. <view class="right">
  95. <view @click.stop="grabOrders(good)" class="qd">抢单</view>
  96. </view>
  97. </view>
  98. </view>
  99. </mescroll-body>
  100. <u-toast ref="uToast"></u-toast>
  101. </view>
  102. </template>
  103. <script>
  104. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  105. import {
  106. mapState
  107. } from 'vuex';
  108. import {
  109. apiGoods
  110. } from "@/api/mock.js"
  111. export default {
  112. mixins: [MescrollMixin], // 使用mixin
  113. data() {
  114. return {
  115. show: false,
  116. columns: [
  117. ['全部类型', '运费先付']
  118. ],
  119. startPlace: '1',
  120. endPlace: '2',
  121. goods: [], // 数据列表
  122. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  123. height: "", // 需要固定swiper的高度
  124. tabList: [
  125. // {
  126. // name: '全部'
  127. // },
  128. {
  129. name: '推荐'
  130. }, {
  131. name: '按时间'
  132. }, {
  133. name: '按距离'
  134. },
  135. // {
  136. // name: '运费先付'
  137. // },
  138. ],
  139. pickerSelect: '全部类型',
  140. tabIndex: 0,
  141. scrollTop: 0,
  142. count: 0
  143. }
  144. },
  145. onTabItemTap(e) {
  146. // tab 点击时执行,此处直接接收单击事件
  147. uni.pageScrollTo({
  148. scrollTop: 0,
  149. duration: 300
  150. });
  151. console.log(e)
  152. },
  153. created() {
  154. },
  155. computed: {
  156. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  157. },
  158. onShow() {
  159. debugger
  160. //获取上一次点击起装卸地
  161. console.log(uni.getStorageSync('fPlaceObj'))
  162. if (uni.getStorageSync('fPlaceObj')) {
  163. this.startPlace = uni.getStorageSync('fPlaceObj');
  164. } else {
  165. console.log(123)
  166. // this.getLngLat();
  167. }
  168. console.log(uni.getStorageSync('sPlaceObj'))
  169. if (uni.getStorageSync('sPlaceObj')) {
  170. this.endPlace = uni.getStorageSync('sPlaceObj');
  171. }
  172. },
  173. onLoad() {
  174. //#ifdef APP-PLUS
  175. // this.getLngLat();
  176. //#endif
  177. // let _isHave = this.$utils.getRoles('aaa')
  178. // console.log(_isHave)
  179. // var Ip=returnCitySN['cip']
  180. // var cityname=returnCitySN['cname']
  181. // localStorage.setItem('Ip', Ip)
  182. // console.log(localStorage.getItem('Ip', Ip))
  183. // localStorage.setItem('cityname', cityname)
  184. // console.log(localStorage.getItem('cityname', cityname))
  185. },
  186. onPageScroll(res) {
  187. this.scrollTop = res.scrollTop
  188. // console.log("页面滚动了", res.scrollTop)
  189. if (this.scrollTop > 1200) {
  190. uni.setTabBarItem({
  191. index: 0,
  192. text: '返回顶部',
  193. iconPath: 'static/images/common/top@2x.png',
  194. selectedIconPath: 'static/images/common/top@2x.png'
  195. })
  196. } else {
  197. uni.setTabBarItem({
  198. index: 0,
  199. text: '货源',
  200. iconPath: 'static/images/common/huoyuan@2x(1).png',
  201. selectedIconPath: 'static/images/common/huoyuan@2x.png'
  202. })
  203. }
  204. },
  205. methods: {
  206. carLength(good) {
  207. let length = ''
  208. if (good.carLengthSmall && good.carLength) {
  209. length = good.carLengthSmall + '~' + good.carLength + '米'
  210. } else if (good.carLengthSmall) {
  211. length = "大于" + good.carLengthSmall + '米'
  212. } else if (good.carLength) {
  213. length = "小于" + good.carLength + '米'
  214. }
  215. return length
  216. },
  217. carType(good) {
  218. let _val = '';
  219. if (good.carModel == 1) {
  220. _val = '不限'
  221. } else {
  222. if (good.carModel.includes(2)) {
  223. debugger
  224. _val += '高栏/'
  225. }
  226. if (good.carModel.includes(3)) {
  227. debugger
  228. _val += '集装箱/'
  229. }
  230. if (good.carModel.includes(4)) {
  231. debugger
  232. _val += '自卸车'
  233. }
  234. }
  235. return _val
  236. },
  237. carWeight(good) {
  238. good.loadWeightSmall
  239. good.loadWeight
  240. let weight = ''
  241. if (good.loadWeightSmall && good.loadWeight) {
  242. weight = good.loadWeightSmall + '~' + good.loadWeight + '吨'
  243. } else if (good.loadWeightSmall) {
  244. weight = "大于" + good.loadWeightSmall + '吨'
  245. } else if (good.loadWeight) {
  246. weight = "小于" + good.loadWeight + '吨'
  247. }
  248. return weight
  249. },
  250. getdate() {
  251. var date = new Date()
  252. var year = date.getFullYear() //获取完整的年份(4位)
  253. var mouth = date.getMonth() + 1 //获取当前月份(0-11,0代表1月)
  254. var datetime = date.getDate() //获取当前日(1-31)
  255. if (mouth < 10) {
  256. mouth = '0' + mouth
  257. }
  258. if (datetime < 10) {
  259. datetime = '0' + datetime
  260. }
  261. return String(year) + String(mouth) + String(datetime)
  262. },
  263. grabOrders(item) {
  264. let _obj = {
  265. driverCommonId: this.firstAuthentication.commonId,
  266. commonId: item.commonId,
  267. cargoOwnerName: item.cargoOwnerName,
  268. cargoOwner: item.cargoOwner,
  269. sendPrivate: item.sendPrivate,
  270. sendCity: item.sendCity,
  271. sendArea: item.sendArea,
  272. sendDetailedAddress: item.sendDetailedAddress,
  273. unloadPrivate: item.unloadPrivate,
  274. unloadCity: item.unloadCity,
  275. unloadArea: item.unloadArea,
  276. unloadDetailedAddress: item.unloadDetailedAddress,
  277. goodsName: item.goodsName,
  278. distance: item.distance,
  279. freightPrice: item.freightPrice,
  280. driverName: this.firstAuthentication.driverName,
  281. driverPhone: this.firstAuthentication.driverPhone,
  282. cargoOwnerPhone: item.cargoOwnerPhone
  283. }
  284. this.$request.baseRequest('post', '/publishTaskInfo/api/addOrder', _obj).then(res => {
  285. debugger
  286. if (res.code == 200) {
  287. }
  288. })
  289. .catch(res => {
  290. uni.$u.toast(res.message);
  291. });
  292. },
  293. confirmSelectType(val) {
  294. debugger
  295. console.log(val)
  296. this.pickerSelect = val.value[0]
  297. this.show = false
  298. },
  299. selectTypeClose() {
  300. this.show = false
  301. },
  302. selectType() {
  303. this.show = true
  304. },
  305. getLngLat() {
  306. console.log(11111111111111111111111111111111111111111111111111111)
  307. uni.getLocation({
  308. type: 'gcj02',
  309. geocode: true,
  310. success: res => {
  311. console.log('--------------------------------')
  312. console.log(res)
  313. if (res.latitude) {
  314. this.lat = res.latitude + ',' + res.longitude;
  315. this.startPlace = res.address.city
  316. // this.lng = res.longitude;
  317. } else {
  318. console.log(uni.getSystemInfoSync().platform)
  319. if (uni.getSystemInfoSync().platform == 'android') {
  320. var context = plus.android.importClass("android.content.Context");
  321. var locationManager = plus.android.importClass(
  322. "android.location.LocationManager");
  323. var main = plus.android.runtimeMainActivity();
  324. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  325. this.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  326. }
  327. if (this.bool === false) {
  328. uni.showModal({
  329. title: '提示',
  330. content: '请打开定位服务',
  331. success: ({
  332. confirm,
  333. cancel
  334. }) => {
  335. if (confirm) {
  336. if (uni.getSystemInfoSync().platform == 'android') {
  337. var Intent = plus.android.importClass(
  338. 'android.content.Intent');
  339. var Settings = plus.android.importClass(
  340. 'android.provider.Settings');
  341. var intent = new Intent(Settings
  342. .ACTION_LOCATION_SOURCE_SETTINGS);
  343. var main = plus.android.runtimeMainActivity();
  344. main.startActivity(intent); // 打开系统设置GPS服务页面
  345. }
  346. }
  347. }
  348. });
  349. }
  350. }
  351. }
  352. });
  353. },
  354. toDetail(id) {
  355. uni.$u.route('/pages/goodSource/shippingDetails', {
  356. id: id,
  357. });
  358. },
  359. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  360. upCallback(page) {
  361. debugger
  362. debugger
  363. let _pickerSelect;
  364. if (this.pickerSelect == '运费先付') {
  365. _pickerSelect = 1
  366. } else {
  367. _pickerSelect = 0
  368. }
  369. this.$request.baseRequest('get', '/publishTaskInfo/selectGoodsSource', {
  370. // searchKeyWord: this.tabIndex + 1,
  371. // searchType: _pickerSelect,
  372. loadingPlace: this.startPlace.selected,
  373. unLoadingPlace: this.endPlace.selected,
  374. pageSize: page.size,
  375. currentPage: page.num,
  376. // loadingPlaceCity: this.startPlace.fchoosecity,
  377. // unLoadingPlaceCity: this.endPlace.schoosecity
  378. }).then(res => {
  379. debugger
  380. if (res.code == 200) {
  381. this.goods = res.data.records
  382. this.mescroll.endBySize(res.data.records.length, res.data.total);
  383. }
  384. })
  385. .catch(res => {
  386. uni.$u.toast(res.message);
  387. this.mescroll.endErr();
  388. });
  389. // 此处可以继续请求其他接口
  390. // if(page.num == 1){
  391. // // 请求其他接口...
  392. // }
  393. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  394. // if(!this.isInitxx){
  395. // apiGetxx().then(res=>{
  396. // this.isInitxx = true
  397. // this.mescroll.resetUpScroll() // 重新触发upCallback
  398. // }).catch(()=>{
  399. // this.mescroll.endErr()
  400. // })
  401. // return // 此处return,先获取xx
  402. // }
  403. // //联网加载数据
  404. // apiGoods(page.num, page.size).then(res => {
  405. // //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  406. // //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
  407. // //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  408. // //this.mescroll.endByPage(res.list.length, totalPage); //必传参数(当前页的数据个数, 总页数)
  409. // //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  410. // this.mescroll.endBySize(res.list.length, totalSize); //必传参数(当前页的数据个数, 总数据量)
  411. // //方法三(推荐): 您有其他方式知道是否有下一页 hasNext
  412. // //this.mescroll.endSuccess(res.list.length, hasNext); //必传参数(当前页的数据个数, 是否有下一页true/false)
  413. // //方法四 (不推荐),会存在一个小问题:比如列表共有20条数据,每页加载10条,共2页.如果只根据当前页的数据个数判断,则需翻到第三页才会知道无更多数据
  414. // // this.mescroll.endSuccess(res.list.length);
  415. // //设置列表数据
  416. // if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  417. // this.goods = this.goods.concat(res.list); //追加新数据
  418. // }).catch(() => {
  419. // //联网失败, 结束加载
  420. // this.mescroll.endErr();
  421. // })
  422. },
  423. clickTab(val) {
  424. console.log(val)
  425. },
  426. changeCity() {
  427. if (this.endPlace == '全国') {
  428. this.$refs.uToast.show({
  429. type: 'error',
  430. message: "卸车地为全国不允许切换!",
  431. })
  432. return
  433. }
  434. [this.startPlace, this.endPlace] = [this.endPlace, this.startPlace];
  435. },
  436. goCity(type) {
  437. uni.$u.route('/pages/goodSource/selectCity', {
  438. startPlace: this.startPlace,
  439. endPlace: this.endPlace,
  440. type: type
  441. });
  442. console.log(type)
  443. },
  444. swiperChange(e) {
  445. this.tabIndex = e.detail.current
  446. }
  447. }
  448. }
  449. </script>
  450. <style scoped lang="scss">
  451. .banner {
  452. width: 100%;
  453. position: relative;
  454. }
  455. .fixed,
  456. .fixed1 {
  457. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  458. position: fixed;
  459. top: var(--status-bar-height);
  460. z-index: 999;
  461. // width: calc(100% - 40rpx);
  462. width: 100%;
  463. // margin:0 20rpx;
  464. }
  465. .fixed1 {
  466. top: 0;
  467. height: var(--status-bar-height);
  468. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  469. }
  470. .banner-img {
  471. width: 100%;
  472. }
  473. .head {
  474. position: absolute;
  475. width: calc(100% - 108rpx);
  476. bottom: 0;
  477. background: white;
  478. margin: 0 20rpx;
  479. border-radius: 20rpx;
  480. .item1,
  481. .item3 {
  482. width: 40%;
  483. .text {
  484. text-overflow: ellipsis;
  485. overflow: hidden;
  486. white-space: nowrap;
  487. }
  488. }
  489. .item1 .text {
  490. text-align: left;
  491. }
  492. .item3 .text {
  493. text-align: right;
  494. }
  495. }
  496. .change-btn {
  497. width: 86rpx;
  498. height: 86rpx;
  499. }
  500. .good-list {
  501. background-color: white;
  502. margin: 20rpx;
  503. padding: 20rpx 0rpx 0 0;
  504. border-radius: 20rpx;
  505. .item1,
  506. .item3 {
  507. width: 40%;
  508. display: flex;
  509. .text {
  510. text-overflow: ellipsis;
  511. overflow: hidden;
  512. white-space: nowrap;
  513. }
  514. }
  515. .item1 .text {
  516. text-align: left;
  517. }
  518. .item3 .text {
  519. text-align: right;
  520. }
  521. }
  522. .jt-icon {
  523. position: relative;
  524. top: 6rpx;
  525. width: 60rpx;
  526. margin: 0 20rpx;
  527. }
  528. .row {
  529. margin: 10rpx 0;
  530. align-items: center;
  531. }
  532. .item-bottom {
  533. background: #F0F5FF;
  534. padding: 0 30rpx;
  535. .name {
  536. font-size: 26rpx;
  537. font-weight: 700;
  538. color: #000000;
  539. margin-left: 30rpx;
  540. }
  541. .hp {
  542. margin: 30rpx;
  543. }
  544. .number-color {
  545. margin: 0 10rpx;
  546. }
  547. .qd {
  548. background: linear-gradient(97deg, #4FABFD 0%, #2772FB 100%);
  549. border-radius: 13px;
  550. font-size: 29rpx;
  551. font-weight: 400;
  552. color: #FFFFFF;
  553. padding: 10rpx 35rpx;
  554. }
  555. }
  556. .dw {
  557. align-items: center;
  558. }
  559. .place {
  560. height: var(--status-bar-height);
  561. }
  562. .tab-view {
  563. display: flex;
  564. align-items: center;
  565. justify-content: space-between;
  566. }
  567. .tab-right {
  568. display: flex;
  569. margin-right: 20rpx;
  570. align-items: center;
  571. }
  572. </style>