index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="live-list-page">
  3. <JHeader title="直播推荐" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="live-list">
  5. <LiveBox v-for="item in roomList" :key="item.roomid" class="live-item" :live-data="item" />
  6. </view>
  7. <view style="padding-bottom: 45upx;">
  8. <LoadingMore
  9. :status="!isEmpty && !roomList.length
  10. ? 'loading' : !isEmpty && roomList.length && (roomList.length >= roomTotal) ? 'no-more' : ''"
  11. >
  12. </LoadingMore>
  13. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">暂无直播~</tui-no-data>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { getCanvasSelectLiveListApi } from '../../../api/anotherTFInterface'
  19. import LiveBox from './components/liveBox.vue'
  20. export default {
  21. name: 'LivePage',
  22. components: {
  23. LiveBox
  24. },
  25. data() {
  26. return {
  27. queryInfo: {
  28. page: 1,
  29. pageSize: 10
  30. },
  31. roomList: [],
  32. isEmpty: false,
  33. roomTotal: 0
  34. }
  35. },
  36. onLoad() {
  37. this.getLiveRooms()
  38. },
  39. methods: {
  40. // 获取直播间列表
  41. getLiveRooms(isLoadmore) {
  42. uni.showLoading()
  43. getCanvasSelectLiveListApi(this.queryInfo).then((res) => {
  44. this.roomTotal = res.data.total
  45. if (isLoadmore) {
  46. this.roomList.push(...res.data.list)
  47. } else {
  48. this.roomList = res.data.list
  49. }
  50. this.isEmpty = this.roomList.length === 0
  51. uni.hideLoading()
  52. })
  53. .catch((e) => {
  54. uni.hideLoading()
  55. })
  56. }
  57. },
  58. onReachBottom() {
  59. if (this.roomList.length < this.roomTotal) {
  60. ++this.queryInfo.page
  61. this.getLiveRooms(true)
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .live-list-page {
  68. .live-list {
  69. width: 100%;
  70. display: flex;
  71. flex-wrap: wrap;
  72. .live-item {
  73. width: 48%;
  74. height: 460rpx;
  75. margin: 1%;
  76. border-radius: 8rpx;
  77. overflow: hidden;
  78. }
  79. }
  80. }
  81. </style>