venueList.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  4. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  5. @refresherrestore="onRestore">
  6. <u-card :foot-border-top="false" padding="0" margin="10px" borderRadius="40" v-for="(item, index) in tableList" :key="index"
  7. class="card-container" @click="goToVenueDetail(item)">
  8. <view class="card-content" slot="body">
  9. <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px 10px 0 0 "></u-image>
  10. <view class="card-info-text">{{item.name}}</view>
  11. </view>
  12. </u-card>
  13. <u-divider v-if="isOver" bg-color="transparent">没有更多了</u-divider>
  14. </scroll-view>
  15. <u-top-tips ref="uTips"></u-top-tips>
  16. </view>
  17. </template>
  18. <script>
  19. import {
  20. mapGetters
  21. } from 'vuex'
  22. const NET = require('@/utils/request')
  23. const API = require('@/config/api')
  24. export default {
  25. computed: {
  26. ...mapGetters([
  27. 'mainColor'
  28. ])
  29. },
  30. data() {
  31. return {
  32. triggered: false,
  33. isOver: false,
  34. pageIndex: 1,
  35. tableList: [],
  36. }
  37. },
  38. onLoad() {
  39. this.getTableList()
  40. },
  41. onReady() {},
  42. methods: {
  43. // 下拉刷新
  44. onRefresh() {
  45. this.triggered = true
  46. this.isOver = false
  47. this.pageIndex = 1
  48. this.tableList = []
  49. this.getTableList()
  50. },
  51. // 重置下拉刷新状态
  52. onRestore() {
  53. this.triggered = 'restore'
  54. this.triggered = false
  55. },
  56. // 懒加载
  57. handleLoadMore() {
  58. if (!this.isOver) {
  59. this.pageIndex++
  60. this.getTableList()
  61. }
  62. },
  63. // 获取列表数据
  64. getTableList() {
  65. NET.request(API.getAllVenueList, {
  66. ...uni.getStorageSync('locationData'),
  67. page: this.pageIndex,
  68. size: 10,
  69. }, 'POST').then(res => {
  70. this.triggered = false
  71. this.tableList = this.tableList.concat(res.data.row)
  72. this.isOver = res.data.row.length != 10
  73. }).catch(error => {
  74. this.triggered = false
  75. this.$refs.uTips.show({
  76. title: error.message,
  77. type: 'warning',
  78. })
  79. })
  80. },
  81. // 跳转场馆详情
  82. goToVenueDetail(item) {
  83. uni.navigateTo({
  84. url: '/pagesEnroll/venueDetail?id=' + item.id
  85. });
  86. },
  87. },
  88. }
  89. </script>
  90. <style>
  91. page {
  92. width: 100%;
  93. height: 100%;
  94. background-color: #f7f7f7;
  95. }
  96. </style>
  97. <style lang="scss" scoped>
  98. @import "@/static/css/themes.scss";
  99. .content {
  100. width: 100%;
  101. float: left;
  102. .scroll-box {
  103. width: 100%;
  104. height: 100vh;
  105. box-sizing: border-box;
  106. padding-bottom: 10px;
  107. .card-container {
  108. width: 50%;
  109. float: left;
  110. .card-info-text {
  111. width: 100%;
  112. text-align: center;
  113. line-height: 18px;
  114. font-size: 12px;
  115. margin: 5px 0 10px 0;
  116. }
  117. }
  118. }
  119. }
  120. </style>