item.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card :list="dataList" :current="i"></card>
  4. </MeScroll>
  5. </template>
  6. <script>
  7. import MeScroll from '@/components/mescroll-body/mescroll-uni.vue'
  8. import card from './card.vue'
  9. var app=getApp()
  10. export default {
  11. components:{
  12. MeScroll,card
  13. },
  14. props: {
  15. type: Number,
  16. i: Number,
  17. item:Object,
  18. params:Object
  19. },
  20. data() {
  21. return {
  22. tenantId:'',
  23. isInit: false, // 是否初始化
  24. dataList: [], // 列表数据
  25. mescroll: null, // mescroll 对象
  26. // 上拉配置参数
  27. up: {
  28. noMoreSize: 2,
  29. auto: false,
  30. page: {
  31. page: 0,
  32. size: 10
  33. }
  34. },
  35. // 下拉配置参数
  36. down: {
  37. use: true,
  38. auto: false
  39. }
  40. }
  41. },
  42. created() {
  43. this.tenantId=this.$cache.get('agencyTenantId')
  44. },
  45. watch:{
  46. type(val) {
  47. if(!this.isInit && val === this.i) {
  48. this.mescroll.resetUpScroll()
  49. }
  50. }
  51. },
  52. mounted() {
  53. if(!this.isInit && this.i === 0) {
  54. this.mescroll.resetUpScroll()
  55. }
  56. },
  57. methods: {
  58. /**
  59. * @param {Object} mescroll 初始化组件
  60. */
  61. initMeScroll(mescroll) {
  62. this.mescroll = mescroll
  63. },
  64. /**
  65. * @param {Object} mescroll 上拉回调
  66. */
  67. async upFn(mescroll) {
  68. let that=this
  69. let params={
  70. current:mescroll.num,
  71. size:mescroll.size,
  72. // tenantId:this.tenantId,
  73. carNo:this.params.carNo
  74. }
  75. let res=null
  76. try{
  77. if (this.i==0) {
  78. //入场记录
  79. res=await this.$api.car.enterPage(params)
  80. }else if (this.i==1) {
  81. //出场记录
  82. res=await this.$api.car.outPage(params)
  83. }
  84. let data=res.data.records
  85. this.mescroll.endBySize(data.length, res.total)
  86. if (mescroll.num==1) this.dataList=[]
  87. this.dataList=this.dataList.concat(data)
  88. }catch(e){
  89. this.mescroll.endErr();
  90. }
  91. },
  92. /**
  93. * 下拉回调
  94. * */
  95. downFn(mescroll) {
  96. setTimeout(()=>{
  97. this.$u.toast('刷新成功')
  98. this.mescroll.resetUpScroll()
  99. },1500)
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. view{
  106. box-sizing: border-box;
  107. }
  108. </style>