tran.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view class="content">
  3. <view :style="statusBarHeight" class="status_bar">
  4. </view>
  5. <scroll-view scroll-x class="nav" style="margin-top: 20rpx;">
  6. <view class="flex text-center">
  7. <view class="cu-item flex-sub" :class="0==TabCur?'text-white':''" @tap="tabSelect" data-id="0">
  8. <text>货源找车</text>
  9. </view>
  10. <view class="cu-item flex-sub" :class="1==TabCur?'text-white':''" @tap="tabSelect" data-id="1">
  11. <text>
  12. 车队找粮</text>
  13. </view>
  14. </view>
  15. </scroll-view>
  16. <swiper :current="TabCur" class="swiper-box" duration="300" @change="tabSelect">
  17. <swiper-item class="tab-content" data-id="1">
  18. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
  19. <block v-if="TabCur==0">
  20. <!-- <view class="cu-bar search">
  21. <view class="search-form round" @click="naviageToPage('/pageA/product/search?TabCur=2')">
  22. <text class="cuIcon-search"></text>
  23. <input type="text" placeholder="搜索" confirm-type="search"></input>
  24. </view>
  25. </view> -->
  26. <view class="guess-section">
  27. <view
  28. v-for="(item , index) in tranInfo" :key="index"
  29. class="guess-item guess-item-warp bg-white"
  30. @click="navToDetailPage(item.id)"
  31. >
  32. <view style='margin:5px 0;diaplay:inline-block;font-weight:900;' class="flex justify-between">
  33. <text>{{item.startPlace }}</text>
  34. <image class='carIcon' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/car.png'></image>
  35. <text>{{item.endPlace }}</text>
  36. </view>
  37. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  38. <view>
  39. <text class='status' v-if="item.status == 30">可承运</text>
  40. <text class='status' v-if="item.status == 40">已结束</text>
  41. <view class='goods'><text>{{item.goodsName}}</text><text>{{numFilter(item.total - item.tranCount) }}吨</text></view>
  42. </view>
  43. <text v-if='item.price' class="text-price">{{item.price }}/吨</text>
  44. <text v-if='item.inPrice' class="text-price">{{item.inPrice }}/吨</text>
  45. </view>
  46. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  47. <text></text>
  48. <text class='gmtUpdate'>{{item.gmtUpdate}}</text>
  49. </view>
  50. </view>
  51. <view v-show="isLoadMore">
  52. <uni-load-more :status="loadStatus" ></uni-load-more>
  53. </view>
  54. </view>
  55. </block>
  56. </scroll-view>
  57. </swiper-item>
  58. <swiper-item class="tab-content" data-id="0">
  59. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
  60. <block v-if="TabCur==1">
  61. <!-- <view class="cu-bar search">
  62. <view class="search-form round" @click="naviageToPage('/pageA/product/search?TabCur=3')">
  63. <text class="cuIcon-search"></text>
  64. <input type="text" placeholder="搜索" confirm-type="search"></input>
  65. </view>
  66. </view> -->
  67. <view class="guess-section">
  68. <view
  69. v-for="(item, index) in carInfo" :key="index"
  70. class="guess-item guess-item-warp bg-white"
  71. @click="navToDetailPage(item.id)"
  72. >
  73. <view style='margin:5px 0;diaplay:inline-block;font-weight:900;' class="flex justify-between">
  74. <text>{{item.startPlace }}</text>
  75. <image class='carIcon' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/car.png'></image>
  76. <text>{{item.endPlace }}</text>
  77. </view>
  78. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  79. <view>
  80. <text class='status' v-if="item.status == 2">可委托</text>
  81. <text class='status' v-else>已承运</text>
  82. <view class='goods'><text>{{item.driver}}</text><text>{{item.carNo}}</text></view>
  83. </view>
  84. <text v-if='item.price' class="text-price">{{item.price }}/吨</text>
  85. </view>
  86. <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
  87. <text></text>
  88. <text class='gmtUpdate'>{{item.gmtUpdate}}</text>
  89. </view>
  90. </view>
  91. <view v-show="isLoadMore">
  92. <uni-load-more :status="loadStatus" ></uni-load-more>
  93. </view>
  94. </view>
  95. </block>
  96. </scroll-view>
  97. </swiper-item>
  98. </swiper>
  99. </view>
  100. </template>
  101. <script>
  102. import {
  103. mapState
  104. } from 'vuex';
  105. export default {
  106. name: "tran",
  107. data() {
  108. return {
  109. tranInfo: [],
  110. carInfo:[],
  111. pages:1,//页数
  112. limit:10 ,//每次取条目数
  113. loadStatus:'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  114. isLoadMore:false ,//是否加载中
  115. TabCur:0,
  116. statusBarHeight:"height:"
  117. };
  118. },
  119. computed: {
  120. ...mapState(['hasLogin','userInfo'])
  121. },
  122. onShow() {
  123. uni.showTabBar()
  124. uni.hideKeyboard()
  125. this.loadData()
  126. var userInfo = uni.getStorageSync("userInfo")
  127. var that = this
  128. console.log("userInfo",userInfo)
  129. uni.removeTabBarBadge({
  130. index: 4
  131. })
  132. this.$api.doRequest('get', '/newNoticeTask/query/noticeTasks').then(res => {
  133. if (res.data.data) {
  134. let name = 'myTip';
  135. let value = res.data.data.total;
  136. that.$store.commit('$uStore', {
  137. name,
  138. value
  139. });
  140. if(value != 0&&value){
  141. uni.setTabBarBadge({
  142. index:4,
  143. text:value+""
  144. })
  145. }
  146. name = 'taskTip';
  147. value = res.data.data.total;
  148. that.$store.commit('$uStore', {
  149. name,
  150. value
  151. });
  152. // name = 'contractTip';
  153. // value = res.data.data.contractTip;
  154. // that.$store.commit('$uStore', {
  155. // name,
  156. // value
  157. // });
  158. }
  159. })
  160. },
  161. //下拉刷新
  162. onPullDownRefresh() {
  163. this.pages = 1
  164. this.isLoadMore = false
  165. this.loadStatus = 'loading'
  166. this.loadData()
  167. },
  168. onLoad() {
  169. var that = this
  170. uni.getSystemInfo({
  171. success: function(res) {
  172. console.log("statusBarHeight",res.statusBarHeight)
  173. that.statusBarHeight += res.statusBarHeight + "px"; //这就是状态栏的高度
  174. },
  175. });
  176. },
  177. onReachBottom(){ //上拉触底函数
  178. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  179. this.isLoadMore=true
  180. this.pages += 1
  181. if(this.TabCur == 0){
  182. this.getIndexTranData()
  183. }
  184. else{
  185. this.getIndexCarData()
  186. }
  187. }
  188. },
  189. methods: {
  190. numFilter (value) {
  191. if(!value){
  192. return 0
  193. }
  194. // 截取当前数据到小数点后两位
  195. let realVal = parseFloat(value).toFixed(2)
  196. return realVal
  197. },
  198. naviageToPage(page) {
  199. uni.navigateTo({
  200. url: page,
  201. fail() {
  202. uni.switchTab({
  203. url: page
  204. })
  205. }
  206. })
  207. },
  208. async loadData() {
  209. const that = this
  210. uni.showLoading({
  211. title: '正在加载',
  212. mask:true
  213. })
  214. if(this.TabCur == 0){
  215. that.$api.request('tran', 'getTranListInfo',{
  216. page: this.pages,
  217. limit:this.limit
  218. }, failres => {
  219. that.$api.msg(failres.errmsg)
  220. this.isLoadMore = false
  221. this.loadStatus = 'nomore'
  222. if(this.pages>1){this.pages=1}
  223. uni.hideLoading()
  224. uni.stopPullDownRefresh()
  225. }).then(res => {
  226. let data = res.data
  227. console.log(res)
  228. //销售信息
  229. if(res.data.tranInfo){
  230. console.log(res.data.tranInfo)
  231. that.tranInfo = res.data.tranInfo
  232. }
  233. uni.hideLoading()
  234. uni.stopPullDownRefresh()
  235. })
  236. }
  237. else{
  238. that.$api.request('tran', 'getCarListInfo',{
  239. page: this.pages,
  240. limit:this.limit
  241. }, failres => {
  242. that.$api.msg(failres.errmsg)
  243. this.isLoadMore = false
  244. this.loadStatus = 'nomore'
  245. if(this.pages>1){this.pages=1}
  246. uni.hideLoading()
  247. uni.stopPullDownRefresh()
  248. }).then(res => {
  249. let data = res.data
  250. //销售信息
  251. if(res.data.carInfo){
  252. that.carInfo = res.data.carInfo
  253. }
  254. uni.hideLoading()
  255. uni.stopPullDownRefresh()
  256. })
  257. }
  258. },
  259. tabSelect(e) {
  260. if(e.currentTarget.dataset.id){
  261. this.TabCur = e.currentTarget.dataset.id;
  262. }
  263. else{
  264. this.TabCur = e.target.current;
  265. }
  266. this.pages = 1
  267. console.log(this.TabCur)
  268. this.loadData()
  269. },
  270. //详情
  271. navToDetailPage(item) {
  272. let id = item;
  273. if(this.TabCur == 0){
  274. uni.navigateTo({
  275. url: `/pages/tran/tran_detail?id=${id}`
  276. })
  277. }
  278. else{
  279. uni.navigateTo({
  280. url: `/pages/tran/car_detail?id=${id}`
  281. })
  282. }
  283. },
  284. onReachBottomTmp(){ //上拉触底函数
  285. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  286. this.isLoadMore=true
  287. this.pages += 1
  288. if(this.TabCur == 0){
  289. this.getIndexTranData()
  290. }
  291. else{
  292. this.getIndexCarData()
  293. }
  294. }
  295. },
  296. getIndexTranData(){
  297. const that = this
  298. var pages=that.pages
  299. var limit=that.limit
  300. uni.showLoading({
  301. title: '正在加载',
  302. mask:true
  303. })
  304. that.$api.request('tran', 'getTranListInfo', {
  305. page: pages,
  306. limit:limit
  307. },failres => {
  308. that.$api.msg(failres.errmsg)
  309. that.isLoadMore=false
  310. that.loadStatus = 'nomore'
  311. if(that.pages>1){that.pages-=1}
  312. uni.hideLoading()
  313. }).then(res => {
  314. let data = res.data
  315. //销售信息
  316. if(data.tranInfo.length > 0){
  317. that.tranInfo = that.tranInfo.concat(data.tranInfo)
  318. that.isLoadMore=false
  319. }
  320. else{
  321. if(that.pages>1){that.pages-=1}
  322. that.isLoadMore=true
  323. that.loadStatus = 'nomore'
  324. }
  325. uni.hideLoading()
  326. })
  327. },
  328. getIndexCarData(){
  329. const that = this
  330. var pages=that.pages
  331. var limit=that.limit
  332. uni.showLoading({
  333. title: '正在加载',
  334. mask:true
  335. })
  336. that.$api.request('tran', 'getCarListInfo', {
  337. page: pages,
  338. limit:limit
  339. },failres => {
  340. that.$api.msg(failres.errmsg)
  341. that.isLoadMore=false
  342. that.loadStatus = 'nomore'
  343. if(that.pages>1){that.pages-=1}
  344. uni.hideLoading()
  345. }).then(res => {
  346. let data = res.data
  347. //销售信息
  348. if(data.carInfo.length > 0){
  349. that.carInfo = that.carInfo.concat(data.carInfo)
  350. that.isLoadMore=false
  351. }
  352. else{
  353. if(that.pages>1){that.pages-=1}
  354. that.isLoadMore=true
  355. that.loadStatus = 'nomore'
  356. }
  357. uni.hideLoading()
  358. })
  359. }
  360. },
  361. }
  362. </script>
  363. <style lang="scss" scoped>
  364. .cu-tag.badge {
  365. right: 26rpx;
  366. }
  367. .text-white text{
  368. position: relative;
  369. z-index: 2;
  370. background: linear-gradient(45deg, #3DC146, #B2D612);
  371. padding: 5px 10px;
  372. border-radius: 38rpx;
  373. }
  374. .guess-item-warp{
  375. padding:15px;
  376. border-radius: 5px;
  377. color:#000;
  378. box-shadow: 0 2px 2px rgba(0,0,0,0.1);
  379. margin:5px 0;
  380. }
  381. .cu-bar .search-form {
  382. background-color: #ffff;
  383. }
  384. .status{
  385. font-weight:900;
  386. display:inline-block;
  387. margin-right:15px;
  388. }
  389. .gmtUpdate{
  390. color:rgba(0,0,0,0.5);
  391. }
  392. .goods{
  393. display:inline-block;
  394. background:#F5F5F5;
  395. font-size:12px;
  396. padding:5px 10px;
  397. color:#585858;
  398. border-radius: 3px;
  399. }
  400. .text-price{
  401. color:#E63113;
  402. }
  403. .goods text{
  404. display: inline-block;
  405. padding:0 5px;
  406. }
  407. .goods text:first-child{
  408. border-right:1px solid #737373;
  409. }
  410. .carIcon{
  411. width: 68px;
  412. height: 14px;
  413. position: relative;
  414. top: 4px;
  415. }
  416. .guess-section{
  417. background:transparent;
  418. }
  419. page,
  420. .content {
  421. background: $page-color-base;
  422. height: 100%;
  423. }
  424. /* .container{
  425. padding-bottom: 100upx;
  426. } */
  427. .cu-form-group input {
  428. text-align: right;
  429. }
  430. .cu-form-group textarea {
  431. text-align: right;
  432. }
  433. .place{
  434. font-size: 40rpx;
  435. line-height: 1;
  436. padding-right: 10upx;
  437. }
  438. .place-center{
  439. font-size: 28rpx;
  440. }
  441. .btn-size{
  442. font-size: 28rpx;
  443. }
  444. .place-bottom{
  445. margin-top: 20rpx;
  446. }
  447. .swiper-box {
  448. height: 85vh;
  449. }
  450. .list-scroll-content {
  451. height: 100%;
  452. }
  453. .uni-swiper-item {
  454. height: auto;
  455. }
  456. .status_bar {
  457. width: 100%;
  458. }
  459. </style>