index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="live-list-page">
  3. <view class="live-list">
  4. <LiveBox
  5. v-for="item in roomList"
  6. :key="item.roomid"
  7. class="live-item"
  8. :live-data="item"
  9. />
  10. </view>
  11. <view v-if="ifShow" class="emptyCart-box">
  12. <image class="emptyCart-img" src="../../static/images/origin/collectEmpty.png"></image>
  13. <label class="text font-color-999 fs26 mar-top-30">暂无直播~</label>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. const NET = require('@/utils/request')
  19. const API = require('@/config/api')
  20. import LiveBox from './components/liveBox.vue'
  21. export default {
  22. components: {
  23. LiveBox
  24. },
  25. data() {
  26. return {
  27. page: {
  28. page: 1,
  29. pageSize: 10
  30. },
  31. isLoading: false,
  32. roomList: [],
  33. ifShow: false
  34. }
  35. },
  36. onLoad() {
  37. this.getLiveRooms()
  38. },
  39. onReachBottom() {
  40. this.page.page++
  41. this.getLiveRooms()
  42. },
  43. methods: {
  44. // 获取直播间列表
  45. getLiveRooms() {
  46. if (this.isLoading) { return }
  47. this.isLoading = true
  48. NET.request(API.LiveRoomes, this.page, 'get').then((res) => {
  49. if (this.page.page === 1) { // 第一次查询
  50. this.roomList = res.data.list
  51. if (this.roomList.length === 0) {
  52. this.ifShow = true
  53. }
  54. } else { // 下拉继续查询
  55. this.roomList = this.roomList.concat(res.data.list)
  56. }
  57. this.isLoading = false
  58. })
  59. .catch((err) => {
  60. this.isLoading = false
  61. })
  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. .emptyCart-box{
  81. position: absolute;
  82. top: 0;
  83. bottom: 0;
  84. left: 0;
  85. right: 0;
  86. display: flex;
  87. flex-direction: column;
  88. justify-content: center;
  89. align-items: center;
  90. .emptyCart-img{
  91. width: 198upx;
  92. height: 183upx;
  93. }
  94. }
  95. }
  96. </style>