index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="h5-area-wrap">
  3. <div class="title">{{ route.query.name }}</div>
  4. <div class="live-room-list">
  5. <div
  6. v-for="(iten, indey) in liveRoomList"
  7. :key="indey"
  8. class="live-room"
  9. @click="goRoom(iten)"
  10. >
  11. <div
  12. class="cover"
  13. :style="{
  14. backgroundImage: `url('${
  15. iten?.cover_img || iten?.users?.[0].avatar
  16. }')`,
  17. }"
  18. >
  19. <PullAuthTip
  20. v-if="
  21. iten?.pull_is_should_auth === LiveRoomPullIsShouldAuthEnum.yes
  22. "
  23. ></PullAuthTip>
  24. <div
  25. v-if="iten?.live"
  26. class="living-ico"
  27. >
  28. <div class="live-txt">直播中</div>
  29. </div>
  30. <div
  31. v-if="
  32. iten?.cdn === LiveRoomUseCDNEnum.yes ||
  33. [
  34. LiveRoomTypeEnum.tencent_css,
  35. LiveRoomTypeEnum.tencent_css_pk,
  36. ].includes(iten.type!)
  37. "
  38. class="cdn-ico"
  39. >
  40. <div class="txt">CDN</div>
  41. </div>
  42. <div class="txt">{{ iten?.users?.[0]?.username }}</div>
  43. </div>
  44. <div class="desc">{{ iten?.name }}</div>
  45. </div>
  46. <div
  47. v-if="!liveRoomList.length"
  48. class="null"
  49. >
  50. {{ t('common.nonedata') }}
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script lang="ts" setup>
  56. import { onMounted, ref } from 'vue';
  57. import { useI18n } from 'vue-i18n';
  58. import { useRoute } from 'vue-router';
  59. import { fetchLiveRoomList } from '@/api/area';
  60. import router, { routerName } from '@/router';
  61. import {
  62. ILiveRoom,
  63. LiveRoomIsShowEnum,
  64. LiveRoomPullIsShouldAuthEnum,
  65. LiveRoomTypeEnum,
  66. LiveRoomUseCDNEnum,
  67. } from '@/types/ILiveRoom';
  68. const liveRoomList = ref<ILiveRoom[]>([]);
  69. const { t } = useI18n();
  70. const route = useRoute();
  71. function goRoom(item: ILiveRoom) {
  72. if (!item.live) {
  73. window.$message.info('该直播间没在直播~');
  74. return;
  75. }
  76. router.push({
  77. name: routerName.h5Room,
  78. params: { roomId: item.id },
  79. });
  80. }
  81. onMounted(() => {
  82. getData();
  83. });
  84. async function getData() {
  85. const res = await fetchLiveRoomList({
  86. id: Number(route.params.id),
  87. live_room_is_show: LiveRoomIsShowEnum.yes,
  88. });
  89. if (res.code === 200) {
  90. liveRoomList.value = res.data.rows;
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .h5-area-wrap {
  96. padding: 0 20px;
  97. .title {
  98. margin-bottom: 10px;
  99. }
  100. .live-room-list {
  101. display: flex;
  102. align-items: center;
  103. flex-wrap: wrap;
  104. justify-content: space-between;
  105. .live-room {
  106. display: inline-block;
  107. margin-bottom: 10px;
  108. width: 48%;
  109. .cover {
  110. position: relative;
  111. overflow: hidden;
  112. width: 100%;
  113. height: 100px;
  114. border-radius: 8px;
  115. background-position: center center;
  116. background-size: cover;
  117. .living-ico {
  118. position: absolute;
  119. top: 0px;
  120. left: 0px;
  121. z-index: 10;
  122. padding: 0 6px;
  123. border-radius: 8px 0 10px;
  124. background-color: $theme-color-gold;
  125. color: white;
  126. text-align: center;
  127. font-size: 12px;
  128. .live-txt {
  129. transform-origin: center !important;
  130. @include minFont(10);
  131. }
  132. }
  133. .cdn-ico {
  134. position: absolute;
  135. top: -12px;
  136. right: -12px;
  137. z-index: 2;
  138. width: 70px;
  139. height: 22px;
  140. background-color: #f87c48;
  141. transform: rotate(45deg);
  142. transform-origin: bottom;
  143. .txt {
  144. margin-left: 18px;
  145. background-image: initial !important;
  146. color: white;
  147. font-size: 10px;
  148. transform: scale(0.83333) translate(2px, 3px);
  149. }
  150. }
  151. .txt {
  152. position: absolute;
  153. bottom: 0;
  154. left: 0;
  155. box-sizing: border-box;
  156. padding: 4px 8px;
  157. width: 100%;
  158. border-radius: 0 0 4px 4px;
  159. background-image: linear-gradient(
  160. -180deg,
  161. rgba(0, 0, 0, 0),
  162. rgba(0, 0, 0, 0.6)
  163. );
  164. color: white;
  165. text-align: initial;
  166. font-size: 13px;
  167. @extend %singleEllipsis;
  168. }
  169. }
  170. .desc {
  171. margin-top: 4px;
  172. font-size: 14px;
  173. @extend %singleEllipsis;
  174. }
  175. }
  176. }
  177. }
  178. </style>