tran.vue 12 KB

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