item.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <mescroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card :list="list" ></card>
  4. </mescroll>
  5. </template>
  6. <script>
  7. import mescroll from '@/components/mescroll-body/mescroll-uni.vue'
  8. import card from './card.vue'
  9. export default {
  10. components:{
  11. mescroll,card
  12. },
  13. props: {
  14. type: Number,
  15. i: Number,
  16. item:Object,
  17. refresh:Boolean
  18. },
  19. data() {
  20. return {
  21. isInit: false, // 是否初始化
  22. list: [], // 列表数据
  23. mescroll: null, // mescroll 对象
  24. // 上拉配置参数
  25. up: {
  26. noMoreSize: 5,
  27. auto: false,
  28. },
  29. // 下拉配置参数
  30. down: {
  31. use: false,
  32. auto: false
  33. }
  34. }
  35. },
  36. watch:{
  37. type(val) {
  38. if(!this.isInit && val === this.i) {
  39. this.mescroll.resetUpScroll()
  40. }
  41. },
  42. refresh(){
  43. this.mescroll.resetUpScroll()
  44. }
  45. },
  46. mounted() {
  47. if(!this.isInit && this.i === 0) {
  48. this.mescroll.resetUpScroll()
  49. }
  50. },
  51. methods: {
  52. initMeScroll(mescroll) {
  53. this.mescroll = mescroll
  54. },
  55. //上拉刷新
  56. upFn(mescroll) {
  57. let params={
  58. current:mescroll.num,
  59. size:mescroll.size,
  60. mallId:this.vuex_mallId,
  61. launchType:this.$global.sponsorType.shop,//审核商户的活动
  62. auditStatus:this.item.value
  63. }
  64. try{
  65. this.$api.activity.list(params).then(res=>{
  66. let data=res.data.records
  67. let length=data.length
  68. let total=res.data.total
  69. mescroll.endBySize(length, total);
  70. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  71. this.list=this.list.concat(data); //追加新数据
  72. })
  73. }catch(e){
  74. mescroll.endErr();
  75. }
  76. },
  77. //下拉加载
  78. downFn(mescroll) {
  79. setTimeout(()=>{
  80. this.$u.toast('刷新成功')
  81. this.mescroll.resetUpScroll()
  82. },1500)
  83. },
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. view{
  89. box-sizing: border-box;
  90. }
  91. </style>