tran.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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>
  98. </template>
  99. <script>
  100. import {
  101. mapState
  102. } from 'vuex';
  103. export default {
  104. name: "tran",
  105. data() {
  106. return {
  107. tranInfo: [],
  108. carInfo:[],
  109. pages:1,//页数
  110. limit:10 ,//每次取条目数
  111. loadStatus:'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  112. isLoadMore:false ,//是否加载中
  113. TabCur:0
  114. };
  115. },
  116. computed: {
  117. ...mapState(['hasLogin','userInfo'])
  118. },
  119. onShow() {
  120. uni.showTabBar()
  121. this.loadData()
  122. },
  123. //下拉刷新
  124. onPullDownRefresh() {
  125. this.pages = 1
  126. this.isLoadMore = false
  127. this.loadStatus = 'loading'
  128. this.loadData()
  129. },
  130. onLoad() {
  131. },
  132. onReachBottom(){ //上拉触底函数
  133. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  134. this.isLoadMore=true
  135. this.pages += 1
  136. if(this.TabCur == 0){
  137. this.getIndexTranData()
  138. }
  139. else{
  140. this.getIndexCarData()
  141. }
  142. }
  143. },
  144. methods: {
  145. numFilter (value) {
  146. if(!value){
  147. return 0
  148. }
  149. // 截取当前数据到小数点后两位
  150. let realVal = parseFloat(value).toFixed(2)
  151. return realVal
  152. },
  153. naviageToPage(page) {
  154. uni.navigateTo({
  155. url: page,
  156. fail() {
  157. uni.switchTab({
  158. url: page
  159. })
  160. }
  161. })
  162. },
  163. async loadData() {
  164. const that = this
  165. uni.showLoading({
  166. title: '正在加载',
  167. mask:true
  168. })
  169. if(this.TabCur == 0){
  170. that.$api.request('tran', 'getTranListInfo',{
  171. page: this.pages,
  172. limit:this.limit
  173. }, failres => {
  174. that.$api.msg(failres.errmsg)
  175. this.isLoadMore = false
  176. this.loadStatus = 'nomore'
  177. if(this.pages>1){this.pages=1}
  178. uni.hideLoading()
  179. uni.stopPullDownRefresh()
  180. }).then(res => {
  181. let data = res.data
  182. console.log(res)
  183. //销售信息
  184. if(res.data.tranInfo){
  185. console.log(res.data.tranInfo)
  186. that.tranInfo = res.data.tranInfo
  187. }
  188. uni.hideLoading()
  189. uni.stopPullDownRefresh()
  190. })
  191. }
  192. else{
  193. that.$api.request('tran', 'getCarListInfo',{
  194. page: this.pages,
  195. limit:this.limit
  196. }, failres => {
  197. that.$api.msg(failres.errmsg)
  198. this.isLoadMore = false
  199. this.loadStatus = 'nomore'
  200. if(this.pages>1){this.pages=1}
  201. uni.hideLoading()
  202. uni.stopPullDownRefresh()
  203. }).then(res => {
  204. let data = res.data
  205. //销售信息
  206. if(res.data.carInfo){
  207. that.carInfo = res.data.carInfo
  208. }
  209. uni.hideLoading()
  210. uni.stopPullDownRefresh()
  211. })
  212. }
  213. },
  214. tabSelect(e) {
  215. if(e.currentTarget.dataset.id){
  216. this.TabCur = e.currentTarget.dataset.id;
  217. }
  218. else{
  219. this.TabCur = e.target.current;
  220. }
  221. this.pages = 1
  222. console.log(this.TabCur)
  223. this.loadData()
  224. },
  225. //详情
  226. navToDetailPage(item) {
  227. let id = item;
  228. if(this.TabCur == 0){
  229. uni.navigateTo({
  230. url: `/pages/tran/tran_detail?id=${id}`
  231. })
  232. }
  233. else{
  234. uni.navigateTo({
  235. url: `/pages/tran/car_detail?id=${id}`
  236. })
  237. }
  238. },
  239. onReachBottomTmp(){ //上拉触底函数
  240. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  241. this.isLoadMore=true
  242. this.pages += 1
  243. if(this.TabCur == 0){
  244. this.getIndexTranData()
  245. }
  246. else{
  247. this.getIndexCarData()
  248. }
  249. }
  250. },
  251. getIndexTranData(){
  252. const that = this
  253. var pages=that.pages
  254. var limit=that.limit
  255. uni.showLoading({
  256. title: '正在加载',
  257. mask:true
  258. })
  259. that.$api.request('tran', 'getTranListInfo', {
  260. page: pages,
  261. limit:limit
  262. },failres => {
  263. that.$api.msg(failres.errmsg)
  264. that.isLoadMore=false
  265. that.loadStatus = 'nomore'
  266. if(that.pages>1){that.pages-=1}
  267. uni.hideLoading()
  268. }).then(res => {
  269. let data = res.data
  270. //销售信息
  271. if(data.tranInfo.length > 0){
  272. that.tranInfo = that.tranInfo.concat(data.tranInfo)
  273. that.isLoadMore=false
  274. }
  275. else{
  276. if(that.pages>1){that.pages-=1}
  277. that.isLoadMore=true
  278. that.loadStatus = 'nomore'
  279. }
  280. uni.hideLoading()
  281. })
  282. },
  283. getIndexCarData(){
  284. const that = this
  285. var pages=that.pages
  286. var limit=that.limit
  287. uni.showLoading({
  288. title: '正在加载',
  289. mask:true
  290. })
  291. that.$api.request('tran', 'getCarListInfo', {
  292. page: pages,
  293. limit:limit
  294. },failres => {
  295. that.$api.msg(failres.errmsg)
  296. that.isLoadMore=false
  297. that.loadStatus = 'nomore'
  298. if(that.pages>1){that.pages-=1}
  299. uni.hideLoading()
  300. }).then(res => {
  301. let data = res.data
  302. //销售信息
  303. if(data.carInfo.length > 0){
  304. that.carInfo = that.carInfo.concat(data.carInfo)
  305. that.isLoadMore=false
  306. }
  307. else{
  308. if(that.pages>1){that.pages-=1}
  309. that.isLoadMore=true
  310. that.loadStatus = 'nomore'
  311. }
  312. uni.hideLoading()
  313. })
  314. }
  315. },
  316. }
  317. </script>
  318. <style lang="scss" scoped>
  319. .cu-tag.badge {
  320. right: 26rpx;
  321. }
  322. .text-white text{
  323. position: relative;
  324. z-index: 2;
  325. background: linear-gradient(45deg, #3DC146, #B2D612);
  326. padding: 5px 10px;
  327. border-radius: 38rpx;
  328. }
  329. .guess-item-warp{
  330. padding:15px;
  331. border-radius: 5px;
  332. color:#000;
  333. box-shadow: 0 2px 2px rgba(0,0,0,0.1);
  334. margin:5px 0;
  335. }
  336. .cu-bar .search-form {
  337. background-color: #ffff;
  338. }
  339. .status{
  340. font-weight:900;
  341. display:inline-block;
  342. margin-right:15px;
  343. }
  344. .gmtUpdate{
  345. color:rgba(0,0,0,0.5);
  346. }
  347. .goods{
  348. display:inline-block;
  349. background:#F5F5F5;
  350. font-size:12px;
  351. padding:5px 10px;
  352. color:#585858;
  353. border-radius: 3px;
  354. }
  355. .text-price{
  356. color:#E63113;
  357. }
  358. .goods text{
  359. display: inline-block;
  360. padding:0 5px;
  361. }
  362. .goods text:first-child{
  363. border-right:1px solid #737373;
  364. }
  365. .carIcon{
  366. width: 68px;
  367. height: 14px;
  368. position: relative;
  369. top: 4px;
  370. }
  371. .guess-section{
  372. background:transparent;
  373. }
  374. page,
  375. .content {
  376. background: $page-color-base;
  377. height: 100%;
  378. }
  379. /* .container{
  380. padding-bottom: 100upx;
  381. } */
  382. .cu-form-group input {
  383. text-align: right;
  384. }
  385. .cu-form-group textarea {
  386. text-align: right;
  387. }
  388. .place{
  389. font-size: 40rpx;
  390. line-height: 1;
  391. padding-right: 10upx;
  392. }
  393. .place-center{
  394. font-size: 28rpx;
  395. }
  396. .btn-size{
  397. font-size: 28rpx;
  398. }
  399. .place-bottom{
  400. margin-top: 20rpx;
  401. }
  402. .swiper-box {
  403. height: 85vh;
  404. }
  405. .list-scroll-content {
  406. height: 100%;
  407. }
  408. .uni-swiper-item {
  409. height: auto;
  410. }
  411. </style>