live.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="live-container">
  3. <view class="header">
  4. <text class="title">健康直播</text>
  5. <view class="search-btn" @click="goSearch">
  6. <u-icon name="search" size="20" color="#666"></u-icon>
  7. <text>搜索直播</text>
  8. </view>
  9. </view>
  10. <scroll-view scroll-y class="content-scroll">
  11. <view class="banner">
  12. <view class="banner-item">
  13. <text class="banner-tag">正在直播</text>
  14. <text class="banner-title">名医讲坛:春季养生之道</text>
  15. <text class="banner-sub">张医师在线解答您的健康疑问</text>
  16. </view>
  17. </view>
  18. <view class="live-list">
  19. <view class="section-title">精彩直播</view>
  20. <view class="live-item" v-for="(item, index) in liveList" :key="index" @click="goDetail(item)">
  21. <view class="cover-box">
  22. <image :src="item.cover" mode="aspectFill" class="cover"></image>
  23. <view class="status-tag" :class="{living: item.status === 1}">
  24. <text class="dot" v-if="item.status === 1"></text>
  25. {{item.status === 1 ? '直播中' : '回放'}}
  26. </view>
  27. <view class="viewer-count">
  28. <u-icon name="eye" color="#fff" size="12"></u-icon>
  29. <text>{{item.viewers}}人观看</text>
  30. </view>
  31. </view>
  32. <view class="info">
  33. <text class="item-title ellipsis">{{item.title}}</text>
  34. <view class="anchor-info">
  35. <image :src="item.avatar" class="avatar"></image>
  36. <text class="name">{{item.anchor}}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. liveList: [
  49. {
  50. id: 1,
  51. title: '中医养生:如何调理脾胃',
  52. anchor: '李医生',
  53. avatar: 'https://via.placeholder.com/40',
  54. cover: 'https://via.placeholder.com/300x180/FF6B6B/FFFFFF?text=Live1',
  55. status: 1,
  56. viewers: 1205
  57. },
  58. {
  59. id: 2,
  60. title: '每日瑜伽:舒缓肩颈',
  61. anchor: 'Yoga Lisa',
  62. avatar: 'https://via.placeholder.com/40',
  63. cover: 'https://via.placeholder.com/300x180/4FACFE/FFFFFF?text=Live2',
  64. status: 1,
  65. viewers: 856
  66. },
  67. {
  68. id: 3,
  69. title: '糖尿病饮食指南',
  70. anchor: '王营养师',
  71. avatar: 'https://via.placeholder.com/40',
  72. cover: 'https://via.placeholder.com/300x180/43E97B/FFFFFF?text=Live3',
  73. status: 0,
  74. viewers: 3500
  75. },
  76. {
  77. id: 4,
  78. title: '儿童生长发育讲座',
  79. anchor: '陈专家',
  80. avatar: 'https://via.placeholder.com/40',
  81. cover: 'https://via.placeholder.com/300x180/FA709A/FFFFFF?text=Live4',
  82. status: 0,
  83. viewers: 2100
  84. }
  85. ]
  86. }
  87. },
  88. methods: {
  89. goSearch() {
  90. uni.navigateTo({
  91. url: '/pages/course/video/search'
  92. });
  93. },
  94. goDetail(item) {
  95. uni.navigateTo({
  96. url: '/pages/course/video/liveDetail?id=' + item.id
  97. });
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped lang="scss">
  103. .live-container {
  104. display: flex;
  105. flex-direction: column;
  106. height: 100vh;
  107. background-color: #f8f8f8;
  108. }
  109. .header {
  110. padding: 20rpx 30rpx;
  111. background-color: #fff;
  112. display: flex;
  113. align-items: center;
  114. justify-content: space-between;
  115. .title {
  116. font-size: 36rpx;
  117. font-weight: bold;
  118. }
  119. .search-btn {
  120. background-color: #f5f5f5;
  121. padding: 10rpx 24rpx;
  122. border-radius: 30rpx;
  123. display: flex;
  124. align-items: center;
  125. text {
  126. font-size: 24rpx;
  127. color: #999;
  128. margin-left: 10rpx;
  129. }
  130. }
  131. }
  132. .content-scroll {
  133. flex: 1;
  134. height: 0;
  135. padding: 20rpx;
  136. }
  137. .banner {
  138. margin: 20rpx 30rpx;
  139. height: 200rpx;
  140. background: linear-gradient(45deg, #2583EB, #4FACFE);
  141. border-radius: 16rpx;
  142. padding: 30rpx;
  143. display: flex;
  144. align-items: center;
  145. .banner-item {
  146. display: flex;
  147. flex-direction: column;
  148. color: #fff;
  149. .banner-tag {
  150. background-color: rgba(255,255,255,0.2);
  151. padding: 4rpx 12rpx;
  152. border-radius: 8rpx;
  153. font-size: 20rpx;
  154. align-self: flex-start;
  155. margin-bottom: 10rpx;
  156. }
  157. .banner-title {
  158. font-size: 32rpx;
  159. font-weight: bold;
  160. margin-bottom: 10rpx;
  161. }
  162. .banner-sub {
  163. font-size: 24rpx;
  164. opacity: 0.9;
  165. }
  166. }
  167. }
  168. .live-list {
  169. padding: 0 30rpx;
  170. .section-title {
  171. font-size: 32rpx;
  172. font-weight: bold;
  173. margin-bottom: 20rpx;
  174. }
  175. .live-item {
  176. background-color: #fff;
  177. border-radius: 16rpx;
  178. overflow: hidden;
  179. margin-bottom: 30rpx;
  180. box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);
  181. .cover-box {
  182. position: relative;
  183. height: 300rpx;
  184. .cover {
  185. width: 100%;
  186. height: 100%;
  187. }
  188. .status-tag {
  189. position: absolute;
  190. top: 20rpx;
  191. left: 20rpx;
  192. background-color: rgba(0,0,0,0.5);
  193. color: #fff;
  194. padding: 6rpx 16rpx;
  195. border-radius: 30rpx;
  196. font-size: 22rpx;
  197. display: flex;
  198. align-items: center;
  199. &.living {
  200. background-color: #FF6B6B;
  201. }
  202. .dot {
  203. width: 10rpx;
  204. height: 10rpx;
  205. background-color: #fff;
  206. border-radius: 50%;
  207. margin-right: 8rpx;
  208. }
  209. }
  210. .viewer-count {
  211. position: absolute;
  212. bottom: 20rpx;
  213. right: 20rpx;
  214. background-color: rgba(0,0,0,0.5);
  215. color: #fff;
  216. padding: 4rpx 12rpx;
  217. border-radius: 8rpx;
  218. font-size: 20rpx;
  219. display: flex;
  220. align-items: center;
  221. text {
  222. margin-left: 6rpx;
  223. }
  224. }
  225. }
  226. .info {
  227. padding: 20rpx;
  228. .item-title {
  229. font-size: 30rpx;
  230. font-weight: bold;
  231. margin-bottom: 16rpx;
  232. display: block;
  233. }
  234. .anchor-info {
  235. display: flex;
  236. align-items: center;
  237. .avatar {
  238. width: 40rpx;
  239. height: 40rpx;
  240. border-radius: 50%;
  241. margin-right: 12rpx;
  242. background-color: #eee;
  243. }
  244. .name {
  245. font-size: 24rpx;
  246. color: #666;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. </style>