list.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view>
  3. <scroll-list ref="list" :option="option" @load="load" @refresh="refresh" @loadSuccess="loadSuccess"
  4. @scrolltolower="scrolltolower">
  5. <view v-for="(item, index) in list" :key="index">
  6. </view>
  7. </scroll-list>
  8. </view>
  9. </template>
  10. <style lang="scss" scoped>
  11. .page-wrap {}
  12. .yyButton:active {
  13. background-color: #dedede;
  14. }
  15. .infoBody {
  16. background-color: #ffffff;
  17. padding: 20rpx 0;
  18. font-size: 30px;
  19. margin: 2rpx;
  20. box-shadow: 0px 2px 5px #e5e5e5;
  21. }
  22. </style>
  23. <script>
  24. export default {
  25. props: {
  26. apiUrl: {
  27. type: String,
  28. default: ''
  29. }
  30. },
  31. data() {
  32. return {
  33. option: {
  34. page: 1,
  35. size: 5,
  36. auto: true
  37. },
  38. page: 1,
  39. list: [],
  40. scrollList: [],
  41. total: 0
  42. }
  43. },
  44. onLoad() {
  45. },
  46. onShow() {
  47. this.$refs.list.refresh()
  48. },
  49. methods: {
  50. async back(item) {
  51. const {
  52. data: res
  53. } = await this.$httpRequest({
  54. url: '/app/backEventOrder?id=' + item.id,
  55. method: 'get',
  56. urlType: this.$getUrlType()
  57. });
  58. if (res.code === 200) {
  59. this.taskList({
  60. page: 1,
  61. size: 5
  62. })
  63. this.$showModal("取消成功")
  64. } else {
  65. this.$showModal(res.msg)
  66. }
  67. },
  68. handleTest(item) {
  69. setTimeout(() => {
  70. this.list = []
  71. }, 1000)
  72. uni.setStorageSync("eventId", item.eventId)
  73. uni.setStorageSync("isUpload", 1)
  74. uni.navigateTo({
  75. url: "more"
  76. })
  77. },
  78. async taskList(paging) {
  79. // 发送请求
  80. const {
  81. data: res
  82. } = await this.$httpRequest({
  83. url: this.apiUrl + '?pageNum=' + paging.page + '&pageSize=' + paging.size,
  84. method: 'get',
  85. urlType: this.$getUrlType()
  86. });
  87. if (res.code === 200) {
  88. if (paging.page === 1) {
  89. this.scrollList = res.rows
  90. this.total = res.total
  91. this.$refs.list.loadSuccess({
  92. list: res.rows,
  93. total: this.total
  94. });
  95. } else if (paging.page > 1) {
  96. for (var i = 0; i < res.rows.length; i++) {
  97. this.scrollList.push(res.rows[i])
  98. }
  99. this.$refs.list.loadSuccess({
  100. list: this.scrollList,
  101. total: this.total
  102. });
  103. }
  104. }
  105. },
  106. // 刷新刷剧
  107. refresh(paging) {
  108. this.taskList(paging)
  109. },
  110. scrolltolower(e) {
  111. console.log(e)
  112. },
  113. load(paging) {
  114. this.taskList(paging)
  115. },
  116. loadSuccess(list) {
  117. this.list = list
  118. }
  119. }
  120. }
  121. </script>