item.vue 2.1 KB

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