tran.vue 11 KB

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