my_tran.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-x class="bg-white nav">
  4. <view class="flex text-center">
  5. <view class="cu-item flex-sub" :class="0==TabCur?'text-orange cur':''" @tap="tabSelect" data-id="0">
  6. <text class="cuIcon-deliver"></text> 货源信息
  7. </view>
  8. <view class="cu-item flex-sub" :class="1==TabCur?'text-orange cur':''" @tap="tabSelect" data-id="1">
  9. <text class="cuIcon-group"></text> 承运信息
  10. </view>
  11. </view>
  12. </scroll-view>
  13. <swiper :current="TabCur" class="swiper-box" duration="300" @change="tabSelect">
  14. <swiper-item class="tab-content" data-id="1">
  15. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
  16. <block v-if="TabCur==0">
  17. <view class="guess-section">
  18. <view
  19. v-for="(item, index) in tranInfo" :key="index"
  20. class="guess-item"
  21. @click="navToDetailPage(item)"
  22. >
  23. <view class="flex justify-between padding-xs ">
  24. <view class="flex-sub padding-xs">
  25. <view class="cu-capsule radius">
  26. <view class="cu-tag bg-blue">
  27. {{item.startPlace }}
  28. </view>
  29. <view class="cu-tag line-blue">
  30. {{item.endPlace }}
  31. </view>
  32. </view>
  33. </view>
  34. <view class=" padding-xs">
  35. <view v-if="item.status == 30" class="cu-capsule radius">
  36. <view class="cu-tag bg-green">
  37. 可承运
  38. </view>
  39. <view class="cu-tag line-green">
  40. <text class="text-price">{{item.price }}</text>
  41. </view>
  42. </view>
  43. <view v-else class="cu-capsule radius">
  44. <view class="cu-tag bg-red">
  45. 已结束
  46. </view>
  47. <view class="cu-tag line-red">
  48. <text class="text-price">{{item.price }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="flex justify-between padding-xs">
  54. <view class="flex-sub padding-xs">
  55. <view class="cu-capsule radius">
  56. <view class="cu-tag bg-orange">
  57. {{item.goodsName}}
  58. </view>
  59. <view v-if='item.total' class="cu-tag line-orange">
  60. {{item.total - item.tranCount }}吨
  61. </view>
  62. </view>
  63. </view>
  64. <view class=" text-sm padding-xs">
  65. <view class=" text-sm padding-xs">
  66. <text class="text-gray text-sm text-right padding-xs-tmp ">{{item.gmtUpdate}}</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view v-show="isLoadMore">
  72. <uni-load-more :status="loadStatus" ></uni-load-more>
  73. </view>
  74. </view>
  75. </block>
  76. </scroll-view>
  77. </swiper-item>
  78. <swiper-item class="tab-content" data-id="0">
  79. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
  80. <block v-if="TabCur==1">
  81. <view class="guess-section">
  82. <view
  83. v-for="(item, index) in carInfo" :key="index"
  84. class="guess-item"
  85. @click="navToDetailPage(item)"
  86. >
  87. <view class="flex justify-between padding-xs ">
  88. <view class="flex-sub padding-xs">
  89. <view class="cu-capsule radius">
  90. <view class="cu-tag bg-blue">
  91. {{item.startPlace }}
  92. </view>
  93. <view class="cu-tag line-blue">
  94. {{item.endPlace }}
  95. </view>
  96. </view>
  97. </view>
  98. <view class=" padding-xs">
  99. <view v-if="item.carStatus" class="cu-capsule radius">
  100. <view class="cu-tag bg-green">
  101. {{item.carStatus}}
  102. </view>
  103. <view class="cu-tag line-green">
  104. <text class="text-price">{{item.price }}</text>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="flex justify-between padding-xs">
  110. <view class="flex-sub padding-xs">
  111. <view class="cu-capsule radius">
  112. <view class="cu-tag bg-orange">
  113. {{item.carNo}}
  114. </view>
  115. <view v-if='item.driver' class="cu-tag line-orange">
  116. {{item.driver}}
  117. </view>
  118. </view>
  119. </view>
  120. <view class=" text-sm padding-xs">
  121. <view class=" text-sm padding-xs">
  122. <text class="text-gray text-sm text-right padding-xs-tmp ">{{item.gmtUpdate}}</text>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <view v-show="isLoadMore">
  128. <uni-load-more :status="loadStatus" ></uni-load-more>
  129. </view>
  130. </view>
  131. </block>
  132. </scroll-view>
  133. </swiper-item>
  134. </swiper>
  135. </view>
  136. </template>
  137. <script>
  138. import {
  139. mapState
  140. } from 'vuex';
  141. export default {
  142. name: "my",
  143. data() {
  144. return {
  145. tranInfo: [],
  146. carInfo:[],
  147. pages:1,//页数
  148. limit:10 ,//每次取条目数
  149. loadStatus:'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  150. isLoadMore:false ,//是否加载中
  151. PageCur: "tran",
  152. TabCur: 0
  153. };
  154. },
  155. computed: {
  156. ...mapState(['hasLogin','userInfo'])
  157. },
  158. onShow() {
  159. this.PageCur = "my"
  160. uni.setStorageSync('PageCur', this.PageCur);
  161. this.loadData()
  162. },
  163. //下拉刷新
  164. onPullDownRefresh() {
  165. this.pages = 1
  166. this.isLoadMore = false
  167. this.loadStatus = 'loading'
  168. this.loadData()
  169. },
  170. onLoad(options) {
  171. this.TabCur = options.TabCur
  172. },
  173. // onPageScroll(e) {
  174. // //兼容iOS端下拉时顶部漂移
  175. // if (e.scrollTop >= 0) {
  176. // this.headerPosition = "fixed";
  177. // } else {
  178. // this.headerPosition = "absolute";
  179. // }
  180. // },
  181. onReachBottom(){ //上拉触底函数
  182. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  183. this.isLoadMore=true
  184. this.pages += 1
  185. if(this.TabCur == 0){
  186. this.getIndexTranData()
  187. }
  188. else{
  189. this.getIndexCarData()
  190. }
  191. }
  192. },
  193. methods: {
  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', 'getMyTranListInfo',{
  202. page: this.pages,
  203. limit:this.limit,
  204. phone:this.userInfo.phone
  205. }, failres => {
  206. that.$api.msg(failres.errmsg)
  207. this.isLoadMore = false
  208. this.loadStatus = 'nomore'
  209. if(this.pages>1){this.pages=1}
  210. uni.hideLoading()
  211. uni.stopPullDownRefresh()
  212. }).then(res => {
  213. let data = res.data
  214. console.log(data.tranInfo)
  215. //销售信息
  216. if(data.tranInfo){
  217. that.tranInfo = data.tranInfo
  218. }
  219. uni.hideLoading()
  220. uni.stopPullDownRefresh()
  221. })
  222. }
  223. else{
  224. that.$api.request('tran', 'getMyCarListInfo',{
  225. page: this.pages,
  226. limit:this.limit,
  227. phone:this.userInfo.phone
  228. }, failres => {
  229. that.$api.msg(failres.errmsg)
  230. this.isLoadMore = false
  231. this.loadStatus = 'nomore'
  232. if(this.pages>1){this.pages=1}
  233. uni.hideLoading()
  234. uni.stopPullDownRefresh()
  235. }).then(res => {
  236. let data = res.data
  237. //销售信息
  238. if(data.carInfo){
  239. that.carInfo = data.carInfo
  240. }
  241. uni.hideLoading()
  242. uni.stopPullDownRefresh()
  243. })
  244. }
  245. if (!this.hasLogin||this.userInfo.phone == undefined) {
  246. uni.showModal({
  247. title: '登录提示',
  248. content: '您尚未登录,是否立即登录?',
  249. showCancel: true,
  250. confirmText: '登录',
  251. success: (e) => {
  252. if (e.confirm) {
  253. uni.navigateTo({
  254. url: '/pages/public/login'
  255. })
  256. }
  257. },
  258. fail: () => {},
  259. complete: () => {}
  260. })
  261. }
  262. },
  263. tabSelect(e) {
  264. if(e.currentTarget.dataset.id){
  265. this.TabCur = e.currentTarget.dataset.id;
  266. }
  267. else{
  268. this.TabCur = e.target.current;
  269. }
  270. this.pages = 1
  271. this.loadData()
  272. },
  273. //详情
  274. navToDetailPage(item) {
  275. let id = item.id;
  276. let sendCarNo = item.sendCarNo;
  277. if(this.TabCur == 0){
  278. uni.navigateTo({
  279. url: `/pages/tran/my_tran_detail?id=${id}`
  280. })
  281. }
  282. else{
  283. uni.navigateTo({
  284. url: `/pages/tran/my_car_detail?sendCarNo=${sendCarNo}`
  285. })
  286. }
  287. },
  288. onReachBottomTmp(){ //上拉触底函数
  289. if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
  290. this.isLoadMore=true
  291. this.pages += 1
  292. if(this.TabCur == 0){
  293. this.getIndexTranData()
  294. }
  295. else{
  296. this.getIndexCarData()
  297. }
  298. }
  299. },
  300. getIndexTranData(){
  301. const that = this
  302. var pages=that.pages
  303. var limit=that.limit
  304. uni.showLoading({
  305. title: '正在加载',
  306. mask:true
  307. })
  308. that.$api.request('tran', 'getMyTranListInfo', {
  309. page: pages,
  310. limit:limit,
  311. phone:this.userInfo.phone
  312. },failres => {
  313. that.$api.msg(failres.errmsg)
  314. that.isLoadMore=false
  315. that.loadStatus = 'nomore'
  316. if(that.pages>1){that.pages-=1}
  317. uni.hideLoading()
  318. }).then(res => {
  319. let data = res.data
  320. //销售信息
  321. if(data.tranInfo.length > 0){
  322. that.tranInfo = that.tranInfo.concat(data.tranInfo)
  323. that.isLoadMore=false
  324. }
  325. else{
  326. if(that.pages>1){that.pages-=1}
  327. that.isLoadMore=true
  328. that.loadStatus = 'nomore'
  329. }
  330. uni.hideLoading()
  331. })
  332. },
  333. getIndexCarData(){
  334. const that = this
  335. var pages=that.pages
  336. var limit=that.limit
  337. uni.showLoading({
  338. title: '正在加载',
  339. mask:true
  340. })
  341. that.$api.request('tran', 'getMyCarListInfo', {
  342. page: pages,
  343. limit:limit,
  344. phone:this.userInfo.phone
  345. },failres => {
  346. that.$api.msg(failres.errmsg)
  347. that.isLoadMore=false
  348. that.loadStatus = 'nomore'
  349. if(that.pages>1){that.pages-=1}
  350. uni.hideLoading()
  351. }).then(res => {
  352. let data = res.data
  353. //销售信息
  354. if(data.carInfo.length > 0){
  355. that.carInfo = that.carInfo.concat(data.carInfo)
  356. that.isLoadMore=false
  357. }
  358. else{
  359. if(that.pages>1){that.pages-=1}
  360. that.isLoadMore=true
  361. that.loadStatus = 'nomore'
  362. }
  363. uni.hideLoading()
  364. })
  365. }
  366. },
  367. }
  368. </script>
  369. <style lang='scss' scoped>
  370. page,
  371. .content {
  372. background: $page-color-base;
  373. height: 100%;
  374. }
  375. .container{
  376. padding-bottom: 100upx;
  377. }
  378. .cu-form-group input {
  379. text-align: right;
  380. }
  381. .cu-form-group textarea {
  382. text-align: right;
  383. }
  384. .place{
  385. font-size: 40rpx;
  386. line-height: 1;
  387. padding-right: 10upx;
  388. }
  389. .place-center{
  390. font-size: 28rpx;
  391. }
  392. .guess-item{
  393. /* margin-top: 50rpx; */
  394. }
  395. .btn-size{
  396. font-size: 28rpx;
  397. }
  398. .place-bottom{
  399. margin-top: 20rpx;
  400. }
  401. .swiper-box {
  402. height: 94vh;
  403. }
  404. .list-scroll-content {
  405. height: 100%;
  406. }
  407. .uni-swiper-item {
  408. height: auto;
  409. }
  410. </style>