item.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="">
  3. <mescroll-uni :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  4. <card :list="list" @confirmReceipt="confirmReceipt"></card>
  5. </mescroll-uni>
  6. <toast ref="toast" ></toast>
  7. </view>
  8. </template>
  9. <script>
  10. import mescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
  11. import card from './card.vue'
  12. export default {
  13. components: {
  14. mescrollUni,
  15. card
  16. },
  17. props: {
  18. type: Number,
  19. i: Number,
  20. item: Object
  21. },
  22. data() {
  23. return {
  24. isInit: false, // 是否初始化
  25. list: [], // 列表数据
  26. mescroll: null, // mescroll 对象
  27. // 上拉配置参数
  28. up: {
  29. noMoreSize: 5,
  30. auto: false,
  31. page: {
  32. page: 0,
  33. size: 10
  34. }
  35. },
  36. // 下拉配置参数
  37. down: {
  38. use: false,
  39. auto: false
  40. }
  41. }
  42. },
  43. created() {
  44. },
  45. watch: {
  46. type(val) {
  47. if (!this.isInit && val === this.i) {
  48. this.mescroll.resetUpScroll()
  49. }
  50. }
  51. },
  52. mounted() {
  53. if (!this.isInit && this.i === 0) {
  54. this.mescroll.resetUpScroll()
  55. }
  56. },
  57. methods: {
  58. confirmReceipt(id){
  59. this.$dialog.showModal('确定收货?',true,this.vuex_theme.bgColor).then(res=>{
  60. let params={
  61. id,
  62. goodsStatus:'已完成'
  63. }
  64. this.$api.goodsorder.submit(params).then(res=>{
  65. if (res.data.success) {
  66. this.$refs.toast.info('操作成功')
  67. this.mescroll.resetUpScroll()
  68. }
  69. })
  70. })
  71. },
  72. //初始化组件
  73. initMeScroll(mescroll) {
  74. this.mescroll = mescroll
  75. },
  76. //上拉回调
  77. upFn(mescroll) {
  78. let params = {
  79. userId: this.vuex_userId,
  80. current: mescroll.num,
  81. size: mescroll.size,
  82. }
  83. if (this.item.value!='全部') {
  84. params.goodsStatus=this.item.value
  85. }
  86. try {
  87. this.$api.goodsorder.list(params).then(res => {
  88. let data = res.data.data.records
  89. let length = data.length
  90. let total = res.data.data.total
  91. mescroll.endBySize(length, total);
  92. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  93. this.list = this.list.concat(data); //追加新数据
  94. })
  95. } catch (e) {
  96. mescroll.endErr();
  97. }
  98. },
  99. //下拉回调
  100. downFn(mescroll) {
  101. setTimeout(() => {
  102. this.mescroll.resetUpScroll()
  103. }, 1500)
  104. },
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. view {
  110. box-sizing: border-box;
  111. }
  112. </style>