plan.vue 1.5 KB

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