index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view class="widthBox">
  3. <view class="cardBox" v-for="item in data" :key="item.id" @click.stop="jumpDetails(item)">
  4. <view class="cardBox-img">
  5. <image style="width: 100%;height: 100%;" :src="item.url" mode=""></image>
  6. </view>
  7. <view class="cardBox-text">
  8. <view class="cardBox-textTitle">{{item.activityName}}</view>
  9. <view class="cardBox-textText">
  10. <u--text :lines="2" :text="item.activityDescription"></u--text>
  11. </view>
  12. </view>
  13. </view>
  14. <u-empty v-if="data.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  15. <u-loadmore v-if="page.total !== 0 && data.length != 0" :status="status" />
  16. </view>
  17. </template>
  18. <script>
  19. import {activityList} from '@/api/tabBar/activity.js'
  20. export default {
  21. data() {
  22. return {
  23. page: {
  24. current: 1,
  25. size: 10,
  26. total: 0,
  27. },
  28. data:[],
  29. status: 'loadmore',
  30. }
  31. },
  32. onLoad() {
  33. this.activityListfun()
  34. },
  35. onShow() {
  36. },
  37. onReachBottom() {
  38. this.status = 'loading'
  39. if (this.data.length < this.page.total) {
  40. this.page.current++
  41. this.activityListfun()
  42. } else {
  43. this.status = 'nomore'
  44. }
  45. },
  46. methods: {
  47. // 跳转详情
  48. jumpDetails(row){
  49. uni.navigateTo({
  50. url:'/pages/tabBar/activity/details?id=' + row.id
  51. })
  52. },
  53. // 获取列表数据
  54. activityListfun(){
  55. uni.showLoading({
  56. title: '加载中',
  57. mask: true
  58. });
  59. activityList({
  60. current:this.page.current,
  61. size:this.page.size,
  62. status:1
  63. }).then(res=>{
  64. this.data = this.data.concat(res.data.records)
  65. this.page.total = res.data.total
  66. if (this.data.length == res.data.total) {
  67. this.status = 'nomore'
  68. }
  69. uni.hideLoading();
  70. }).catch(err => {
  71. uni.hideLoading();
  72. })
  73. },
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .widthBox {
  79. width: 94%;
  80. margin: 20rpx auto;
  81. }
  82. .cardBox {
  83. background: #fff;
  84. border-radius: 10rpx;
  85. padding: 20rpx;
  86. box-sizing: border-box;
  87. display: flex;
  88. .cardBox-img {
  89. flex: 1;
  90. width: 200rpx;
  91. height: 180rpx;
  92. }
  93. .cardBox-text {
  94. flex: 2;
  95. margin-left: 10rpx;
  96. .cardBox-textTitle {
  97. font-size: 36rpx;
  98. font-weight: bold;
  99. margin-bottom: 10rpx;
  100. }
  101. .cardBox-textText {
  102. font-size: 30rpx;
  103. color: #8b8b8b;
  104. }
  105. }
  106. }
  107. </style>