tran.vue 12 KB

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