plan.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="plan">
  3. <!-- 每一个权益区域 -->
  4. <view class="box" v-for="item in dataList" :key="item.id" @click="goDetail(item)">
  5. <image class="box_img" :src="item.coverImage" mode="widthFix"></image>
  6. </view>
  7. <!-- 没有数据时展示的页面 -->
  8. <noData v-if="!dataList.length" />
  9. </view>
  10. </template>
  11. <script setup>
  12. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  13. import { ref } from 'vue'
  14. import { getQueryHeart } from '@/api/index.js'
  15. // 当前页
  16. const currentPage = ref(1)
  17. // 每页多少条
  18. const pageCount = ref(6)
  19. // 总条数
  20. const total = ref(0)
  21. // 数据数组
  22. const dataList = ref([])
  23. onLoad(() => {
  24. getData()
  25. })
  26. // 页面触底触发的回调
  27. onReachBottom(() => {
  28. if (total.value > dataList.value.length) {
  29. currentPage.value++
  30. getData()
  31. } else {
  32. uni.showToast({
  33. title: '没有更多数据了~~',
  34. icon: 'none'
  35. })
  36. }
  37. })
  38. // 获取校友权益卡数组
  39. const getData = async () => {
  40. let data = {
  41. currentPage: currentPage.value,
  42. pageCount: pageCount.value
  43. }
  44. const res = await getQueryHeart(data)
  45. // console.log(res)
  46. if (res.code == 200) {
  47. dataList.value = [...dataList.value, ...res.data.list]
  48. total.value = res.data.totalCount
  49. }
  50. }
  51. // 点击每一项权益的回调
  52. const goDetail = (item) => {
  53. let info = encodeURIComponent(JSON.stringify(item))
  54. uni.navigateTo({
  55. url: `/pages/planDetail/planDetail?info=${info}`
  56. })
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .plan {
  61. padding: 20rpx;
  62. .box {
  63. margin-bottom: 20rpx;
  64. // height: 260rpx;
  65. // box-shadow: 0 0 10rpx #d3d3d3;
  66. .box_img {
  67. width: 100%;
  68. }
  69. }
  70. }
  71. </style>