list.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <view>
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  4. <infomation :newList="list"></infomation>
  5. </mescroll-body>
  6. </view>
  7. </template>
  8. <script>
  9. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  10. import infomation from "@/components/infomation/infomation.vue"
  11. export default {
  12. mixins:[MescrollMixin],
  13. components:{
  14. infomation
  15. },
  16. data() {
  17. return {
  18. // 列表数据
  19. list: [],
  20. downOption: {
  21. use: true,
  22. auto: false
  23. },
  24. upOption: {
  25. page: {
  26. page: 0,
  27. size: 10
  28. },
  29. noMoreSize: 5,
  30. empty: {
  31. tip: '暂无相关数据'
  32. }
  33. },
  34. }
  35. },
  36. methods: {
  37. downCallback(){
  38. setTimeout(()=>{
  39. this.mescroll.resetUpScroll()
  40. },1500)
  41. },
  42. upCallback(mescroll) {
  43. let params={
  44. current:mescroll.num,
  45. size:mescroll.size,
  46. agencyId:this.$cache.get('agencyId')
  47. }
  48. try{
  49. this.$api.CMS.page(params).then(res=>{
  50. let data=res.data.records
  51. let length=data.length
  52. let total=res.data.total
  53. mescroll.endBySize(length, total);
  54. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  55. this.list=this.list.concat(data); //追加新数据
  56. })
  57. }catch(e){
  58. console.log(e);
  59. mescroll.endErr();
  60. }
  61. },
  62. }
  63. }
  64. </script>
  65. <style>
  66. </style>