tran.vue 11 KB

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