item.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. },
  18. data() {
  19. return {
  20. isInit: false, // 是否初始化
  21. list: [], // 列表数据
  22. mescroll: null, // mescroll 对象
  23. // 上拉配置参数
  24. up: {
  25. noMoreSize: 5,
  26. auto: false,
  27. page: {
  28. page: 0,
  29. size: 10
  30. }
  31. },
  32. // 下拉配置参数
  33. down: {
  34. use: false,
  35. auto: false
  36. }
  37. }
  38. },
  39. created() {
  40. },
  41. watch:{
  42. type(val) {
  43. if(!this.isInit && val === this.i) {
  44. this.mescroll.resetUpScroll()
  45. }
  46. }
  47. },
  48. mounted() {
  49. if(!this.isInit && this.i === 0) {
  50. this.mescroll.resetUpScroll()
  51. }
  52. },
  53. methods: {
  54. //初始化组件
  55. initMeScroll(mescroll) {
  56. this.mescroll = mescroll
  57. },
  58. //上拉回调
  59. upFn(mescroll) {
  60. let params={
  61. payId:this.vuex_userId,
  62. current:mescroll.num,
  63. size:mescroll.size
  64. }
  65. if (this.item.value==0) {
  66. params.createTime=this.$dateTime.format()
  67. }
  68. try{
  69. this.$api.goodsbills.list(params).then(res=>{
  70. let data=res.data.records
  71. let length=data.length
  72. let total=res.data.total
  73. mescroll.endBySize(length, total);
  74. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  75. this.list=this.list.concat(data); //追加新数据
  76. })
  77. }catch(e){
  78. mescroll.endErr();
  79. }
  80. },
  81. //下拉回调
  82. downFn(mescroll) {
  83. setTimeout(()=>{
  84. this.u.toast('刷新成功')
  85. this.mescroll.resetUpScroll()
  86. },1500)
  87. },
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. view{
  93. box-sizing: border-box;
  94. }
  95. </style>