item.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card :list="list" @timeup='timeup'></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. timeup(item){
  55. let order = this.$u.deepClone(item)
  56. order.payStatus = '取消付款'
  57. order.orderStatus = '取消付款'
  58. this.$api.goodsbills.submit(order).then(res => {
  59. if (res.success) {
  60. this.mescroll.resetUpScroll()
  61. }
  62. })
  63. },
  64. //初始化组件
  65. initMeScroll(mescroll) {
  66. this.mescroll = mescroll
  67. },
  68. //上拉回调
  69. upFn(mescroll) {
  70. let params={
  71. payId:this.vuex_userId,
  72. current:mescroll.num,
  73. size:mescroll.size
  74. }
  75. if (this.item.value==0) {
  76. params.createTime=this.$dateTime.format()
  77. }
  78. try{
  79. this.$api.goodsbills.list(params).then(res=>{
  80. let data=res.data.records
  81. let length=data.length
  82. let total=res.data.total
  83. mescroll.endBySize(length, total);
  84. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  85. this.list=this.list.concat(data); //追加新数据
  86. })
  87. }catch(e){
  88. mescroll.endErr();
  89. }
  90. },
  91. //下拉回调
  92. downFn(mescroll) {
  93. setTimeout(()=>{
  94. this.u.toast('刷新成功')
  95. this.mescroll.resetUpScroll()
  96. },1500)
  97. },
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. view{
  103. box-sizing: border-box;
  104. }
  105. </style>