item.vue 2.0 KB

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