tran.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-x class="nav">
  4. <view class="flex text-center">
  5. <view class="cu-item flex-sub" :class="0==TabCur?'text-white':''" @tap="tabSelect" data-id="0">
  6. <text>货源找车</text>
  7. </view>
  8. <view class="cu-item flex-sub" :class="1==TabCur?'text-white':''" @tap="tabSelect" data-id="1">
  9. <text>
  10. 车队找粮</text>
  11. </view>
  12. </view>
  13. </scroll-view>
  14. <swiper :current="TabCur" class="swiper-box" duration="300" @change="tabSelect">
  15. <swiper-item class="tab-content" data-id="1">
  16. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
  17. <block v-if="TabCur==0">
  18. <view class="cu-bar search">
  19. <view class="search-form round" @click="naviageToPage('/pageA/product/search?TabCur=2')">
  20. <text class="cuIcon-search"></text>
  21. <input type="text" placeholder="搜索" confirm-type="search"></input>
  22. </view>
  23. </view>
  24. <view class="guess-section">
  25. <view
  26. v-for="(item , index) in tranInfo" :key="index"
  27. class="guess-item guess-item-warp bg-white"
  28. @click="navToDetailPage(item.id)"
  29. >
  30. <view style='margin:5px 0;diaplay:inline-block;font-weight:900;' class="flex justify-between">
  31. <text>{{item.startPlace }}</text>
  32. <image class='carIcon' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/car.png'></image>
  33. <text>{{item.endPlace }}</text>
  34. </view>
  35. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  36. <view>
  37. <text class='status' v-if="item.status == 30">可承运</text>
  38. <text class='status' v-if="item.status == 40">已结束</text>
  39. <view class='goods'><text>{{item.goodsName}}</text><text>{{numFilter(item.total - item.tranCount) }}吨</text></view>
  40. </view>
  41. <text v-if='item.price' class="text-price">{{item.price }}/吨</text>
  42. <text v-if='item.inPrice' class="text-price">{{item.inPrice }}/吨</text>
  43. </view>
  44. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  45. <text></text>
  46. <text class='gmtUpdate'>{{item.gmtUpdate}}</text>
  47. </view>
  48. </view>
  49. <view v-show="isLoadMore">
  50. <uni-load-more :status="loadStatus" ></uni-load-more>
  51. </view>
  52. </view>
  53. </block>
  54. </scroll-view>
  55. </swiper-item>
  56. <swiper-item class="tab-content" data-id="0">
  57. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
  58. <block v-if="TabCur==1">
  59. <view class="cu-bar search">
  60. <view class="search-form round" @click="naviageToPage('/pageA/product/search?TabCur=3')">
  61. <text class="cuIcon-search"></text>
  62. <input type="text" placeholder="搜索" confirm-type="search"></input>
  63. </view>
  64. </view>
  65. <view class="guess-section">
  66. <view
  67. v-for="(item, index) in carInfo" :key="index"
  68. class="guess-item guess-item-warp bg-white"
  69. @click="navToDetailPage(item.id)"
  70. >
  71. <view style='margin:5px 0;diaplay:inline-block;font-weight:900;' class="flex justify-between">
  72. <text>{{item.startPlace }}</text>
  73. <image class='carIcon' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/car.png'></image>
  74. <text>{{item.endPlace }}</text>
  75. </view>
  76. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  77. <view>
  78. <text class='status' v-if="item.status == 2">可委托</text>
  79. <text class='status' v-else>已承运</text>
  80. <view class='goods'><text>{{item.driver}}</text><text>{{item.carNo}}</text></view>
  81. </view>
  82. <text v-if='item.price' class="text-price">{{item.price }}/吨</text>
  83. </view>
  84. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  85. <text></text>
  86. <text class='gmtUpdate'>{{item.gmtUpdate}}</text>
  87. </view>
  88. </view>
  89. <view v-show="isLoadMore">
  90. <uni-load-more :status="loadStatus" ></uni-load-more>
  91. </view>
  92. </view>
  93. </block>
  94. </scroll-view>
  95. </swiper-item>
  96. </swiper>
  97. <!-- <view class="cu-bar tabbar bg-white shadow foot">
  98. <view :class="PageCur=='sale'?'action text-pink':'action text-gray'" @click="NavChange" data-cur="sale">
  99. <view><image style='width:21px;height:23px;' :src="PageCur=='sale'?'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/zixun_check.png':'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/zixun.png'"></image></view> 资讯
  100. </view>
  101. <view :class="PageCur=='buy'?'action text-pink':'action text-gray'" @click="NavChange" data-cur="buy">
  102. <view><image style='width:25px;height:25px;' :src="PageCur=='buy'?'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/jiaoyi_check.png':'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/jiaoyi.png'"></image></view>交易
  103. </view>
  104. <view :class="PageCur=='trust'?'action text-pink add-action':'action text-gray add-action'" @click="NavChange"
  105. data-cur="trust">
  106. <button :class="PageCur=='trust'?'cuIcon-group':'cu-btn cuIcon-group bg-white '">
  107. <view v-if="liangxinTip" class="cu-tag badge">{{liangxinTip}}</view>
  108. </button>
  109. 粮信
  110. </view>
  111. <view :class="PageCur=='tran'?'action text-pink':'action text-gray'" @click="NavChange" data-cur="tran">
  112. <view><image style='width:25px;height:20px;' :src="PageCur=='tran'?'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wuliu_check.png':'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wuliu.png'"></image></view> 物流
  113. </view>
  114. <view :class="PageCur=='my'?'action text-pink':'action text-gray'" @click="NavChange" data-cur="my">
  115. <view>
  116. <view v-if="myTip" class="cu-tag badge">{{myTip}}</view>
  117. <image style='width:21px;height:21px;' :src="PageCur=='my'?'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wode_check.png':'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wode.png'"></image>
  118. </view>
  119. 我的
  120. </view>
  121. </view> -->
  122. <u-tabbar v-model="current" :list="listTab" :mid-button="true"></u-tabbar>
  123. </view>
  124. </template>
  125. <script>
  126. import {
  127. mapState
  128. } from 'vuex';
  129. export default {
  130. name: "tran",
  131. data() {
  132. return {
  133. tranInfo: [],
  134. carInfo:[],
  135. pages:1,//页数
  136. limit:10 ,//每次取条目数
  137. loadStatus:'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  138. isLoadMore:false ,//是否加载中
  139. PageCur: "tran",
  140. TabCur: 0,
  141. listTab: [
  142. {
  143. iconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/zixun.png",
  144. selectedIconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/zixun_check.png",
  145. text: '资讯',
  146. count: 0 ,
  147. isDot: true,
  148. customIcon: false,
  149. pagePath:'/pages/sale/information'
  150. },
  151. {
  152. iconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/jiaoyi.png",
  153. selectedIconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/jiaoyi_check.png",
  154. text: '交易',
  155. customIcon: false,
  156. pagePath:'/pages/buy/transaction'
  157. },
  158. {
  159. iconPath: "chat",
  160. selectedIconPath: "chat",
  161. text: '粮信',
  162. midButton: true,
  163. customIcon: false,
  164. // pagePath:'/pages/home/home'
  165. },
  166. {
  167. iconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wuliu.png",
  168. selectedIconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wuliu_check.png",
  169. text: '物流',
  170. customIcon: false,
  171. pagePath:'/pages/tran/tran'
  172. },
  173. {
  174. iconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wode.png",
  175. selectedIconPath: "https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/wode_check.png",
  176. text: '我的',
  177. count: this.myTip,
  178. isDot: false,
  179. customIcon: false,
  180. pagePath:'/pages/user/user'
  181. },
  182. ],
  183. current: 3
  184. };
  185. },
  186. computed: {
  187. ...mapState(['hasLogin','userInfo'])
  188. },
  189. onShow() {
  190. uni.hideTabBar()
  191. this.PageCur = "tran"
  192. uni.setStorageSync('PageCur', this.PageCur);
  193. this.loadData()
  194. },
  195. //下拉刷新
  196. onPullDownRefresh() {
  197. this.pages = 1
  198. this.isLoadMore = false
  199. this.loadStatus = 'loading'
  200. this.loadData()
  201. },
  202. onLoad() {
  203. uni.hideTabBar()
  204. },
  205. // onPageScroll(e) {
  206. // //兼容iOS端下拉时顶部漂移
  207. // if (e.scrollTop >= 0) {
  208. // this.headerPosition = "fixed";
  209. // } else {
  210. // this.headerPosition = "absolute";
  211. // }
  212. // },
  213. onReachBottom(){ //上拉触底函数
  214. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  215. this.isLoadMore=true
  216. this.pages += 1
  217. if(this.TabCur == 0){
  218. this.getIndexTranData()
  219. }
  220. else{
  221. this.getIndexCarData()
  222. }
  223. }
  224. },
  225. methods: {
  226. numFilter (value) {
  227. // 截取当前数据到小数点后两位
  228. let realVal = parseFloat(value).toFixed(2)
  229. return realVal
  230. },
  231. naviageToPage(page) {
  232. uni.navigateTo({
  233. url: page,
  234. fail() {
  235. uni.switchTab({
  236. url: page
  237. })
  238. }
  239. })
  240. },
  241. async loadData() {
  242. const that = this
  243. uni.showLoading({
  244. title: '正在加载'
  245. })
  246. if(this.TabCur == 0){
  247. that.$api.request('tran', 'getTranListInfo',{
  248. page: this.pages,
  249. limit:this.limit
  250. }, failres => {
  251. that.$api.msg(failres.errmsg)
  252. this.isLoadMore = false
  253. this.loadStatus = 'nomore'
  254. if(this.pages>1){this.pages=1}
  255. uni.hideLoading()
  256. uni.stopPullDownRefresh()
  257. }).then(res => {
  258. let data = res.data
  259. console.log(res)
  260. //销售信息
  261. if(res.data.tranInfo){
  262. console.log(res.data.tranInfo)
  263. that.tranInfo = res.data.tranInfo
  264. }
  265. uni.hideLoading()
  266. uni.stopPullDownRefresh()
  267. })
  268. }
  269. else{
  270. that.$api.request('tran', 'getCarListInfo',{
  271. page: this.pages,
  272. limit:this.limit
  273. }, failres => {
  274. that.$api.msg(failres.errmsg)
  275. this.isLoadMore = false
  276. this.loadStatus = 'nomore'
  277. if(this.pages>1){this.pages=1}
  278. uni.hideLoading()
  279. uni.stopPullDownRefresh()
  280. }).then(res => {
  281. let data = res.data
  282. //销售信息
  283. if(res.data.carInfo){
  284. that.carInfo = res.data.carInfo
  285. }
  286. uni.hideLoading()
  287. uni.stopPullDownRefresh()
  288. })
  289. }
  290. // if (!this.hasLogin) {
  291. // uni.showModal({
  292. // title: '登录提示',
  293. // content: '您尚未登录,是否立即登录?',
  294. // showCancel: true,
  295. // confirmText: '登录',
  296. // success: (e) => {
  297. // if (e.confirm) {
  298. // uni.navigateTo({
  299. // url: '/pages/public/login'
  300. // })
  301. // }
  302. // },
  303. // fail: () => {},
  304. // complete: () => {}
  305. // })
  306. // }
  307. },
  308. NavChange: function(e) {
  309. var preCur = this.PageCur
  310. this.PageCur = e.currentTarget.dataset.cur
  311. uni.setStorageSync('PageCur', this.PageCur);
  312. switch (this.PageCur) {
  313. case "sale":
  314. uni.switchTab({
  315. url: '/pages/sale/information'
  316. });
  317. // uni.switchTab({
  318. // url: '/pages/sale/sale'
  319. // });
  320. break;
  321. case "buy":
  322. uni.switchTab({
  323. url: '/pages/buy/transaction'
  324. });
  325. break;
  326. case "tran":
  327. uni.switchTab({
  328. url: '/pages/tran/tran'
  329. });
  330. break;
  331. case "trust":
  332. // uni.showModal({
  333. // title: '温馨提示',
  334. // content: '此功能正在开发中',
  335. // showCancel: false,
  336. // confirmText: '确定',
  337. // success: (e) => {
  338. // },
  339. // fail: () => {},
  340. // complete: () => {}
  341. // })
  342. // this.PageCur = preCur
  343. // uni.setStorageSync('PageCur', this.PageCur);
  344. uni.setTabBarItem({
  345. index: 0,
  346. pagePath:'pages/home/home'
  347. })
  348. uni.switchTab({
  349. url: '/pages/home/home'
  350. });
  351. break;
  352. case "my":
  353. uni.switchTab({
  354. url: '/pages/user/user'
  355. });
  356. break;
  357. };
  358. },
  359. tabSelect(e) {
  360. if(e.currentTarget.dataset.id){
  361. this.TabCur = e.currentTarget.dataset.id;
  362. }
  363. else{
  364. this.TabCur = e.target.current;
  365. }
  366. this.pages = 1
  367. console.log(this.TabCur)
  368. this.loadData()
  369. },
  370. //详情
  371. navToDetailPage(item) {
  372. let id = item;
  373. if(this.TabCur == 0){
  374. uni.navigateTo({
  375. url: `/pages/tran/tran_detail?id=${id}`
  376. })
  377. }
  378. else{
  379. uni.navigateTo({
  380. url: `/pages/tran/car_detail?id=${id}`
  381. })
  382. }
  383. },
  384. onReachBottomTmp(){ //上拉触底函数
  385. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  386. this.isLoadMore=true
  387. this.pages += 1
  388. if(this.TabCur == 0){
  389. this.getIndexTranData()
  390. }
  391. else{
  392. this.getIndexCarData()
  393. }
  394. }
  395. },
  396. getIndexTranData(){
  397. const that = this
  398. var pages=that.pages
  399. var limit=that.limit
  400. uni.showLoading({
  401. title: '正在加载'
  402. })
  403. that.$api.request('tran', 'getTranListInfo', {
  404. page: pages,
  405. limit:limit
  406. },failres => {
  407. that.$api.msg(failres.errmsg)
  408. that.isLoadMore=false
  409. that.loadStatus = 'nomore'
  410. if(that.pages>1){that.pages-=1}
  411. uni.hideLoading()
  412. }).then(res => {
  413. let data = res.data
  414. //销售信息
  415. if(data.tranInfo.length > 0){
  416. that.tranInfo = that.tranInfo.concat(data.tranInfo)
  417. that.isLoadMore=false
  418. }
  419. else{
  420. if(that.pages>1){that.pages-=1}
  421. that.isLoadMore=true
  422. that.loadStatus = 'nomore'
  423. }
  424. uni.hideLoading()
  425. })
  426. },
  427. getIndexCarData(){
  428. const that = this
  429. var pages=that.pages
  430. var limit=that.limit
  431. uni.showLoading({
  432. title: '正在加载'
  433. })
  434. that.$api.request('tran', 'getCarListInfo', {
  435. page: pages,
  436. limit:limit
  437. },failres => {
  438. that.$api.msg(failres.errmsg)
  439. that.isLoadMore=false
  440. that.loadStatus = 'nomore'
  441. if(that.pages>1){that.pages-=1}
  442. uni.hideLoading()
  443. }).then(res => {
  444. let data = res.data
  445. //销售信息
  446. if(data.carInfo.length > 0){
  447. that.carInfo = that.carInfo.concat(data.carInfo)
  448. that.isLoadMore=false
  449. }
  450. else{
  451. if(that.pages>1){that.pages-=1}
  452. that.isLoadMore=true
  453. that.loadStatus = 'nomore'
  454. }
  455. uni.hideLoading()
  456. })
  457. }
  458. },
  459. }
  460. </script>
  461. <style lang="scss" scoped>
  462. .cu-tag.badge {
  463. right: 26rpx;
  464. }
  465. .text-white text{
  466. position: relative;
  467. z-index: 2;
  468. background: linear-gradient(45deg, #3DC146, #B2D612);
  469. padding: 5px 10px;
  470. border-radius: 38rpx;
  471. }
  472. .guess-item-warp{
  473. padding:15px;
  474. border-radius: 5px;
  475. color:#000;
  476. box-shadow: 0 2px 2px rgba(0,0,0,0.1);
  477. margin:5px 0;
  478. }
  479. .cu-bar .search-form {
  480. background-color: #ffff;
  481. }
  482. .status{
  483. font-weight:900;
  484. display:inline-block;
  485. margin-right:15px;
  486. }
  487. .gmtUpdate{
  488. color:rgba(0,0,0,0.5);
  489. }
  490. .goods{
  491. display:inline-block;
  492. background:#F5F5F5;
  493. font-size:12px;
  494. padding:5px 10px;
  495. color:#585858;
  496. border-radius: 3px;
  497. }
  498. .text-price{
  499. color:#E63113;
  500. }
  501. .goods text{
  502. display: inline-block;
  503. padding:0 5px;
  504. }
  505. .goods text:first-child{
  506. border-right:1px solid #737373;
  507. }
  508. .carIcon{
  509. width: 68px;
  510. height: 14px;
  511. position: relative;
  512. top: 4px;
  513. }
  514. .guess-section{
  515. background:transparent;
  516. }
  517. page,
  518. .content {
  519. background: $page-color-base;
  520. height: 100%;
  521. }
  522. /* .container{
  523. padding-bottom: 100upx;
  524. } */
  525. .cu-form-group input {
  526. text-align: right;
  527. }
  528. .cu-form-group textarea {
  529. text-align: right;
  530. }
  531. .place{
  532. font-size: 40rpx;
  533. line-height: 1;
  534. padding-right: 10upx;
  535. }
  536. .place-center{
  537. font-size: 28rpx;
  538. }
  539. .btn-size{
  540. font-size: 28rpx;
  541. }
  542. .place-bottom{
  543. margin-top: 20rpx;
  544. }
  545. .swiper-box {
  546. height: 85vh;
  547. }
  548. .list-scroll-content {
  549. height: 100%;
  550. }
  551. .uni-swiper-item {
  552. height: auto;
  553. }
  554. </style>