liveDetail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <view class="live-detail-container">
  3. <!-- 视频播放区 -->
  4. <view class="video-wrap">
  5. <video
  6. id="myVideo"
  7. src="https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20181126.mp4"
  8. controls
  9. autoplay
  10. class="video-player"
  11. ></video>
  12. </view>
  13. <!-- 详情与聊天切换 -->
  14. <view class="tab-header">
  15. <view class="tab-item" :class="{active: currentTab === 0}" @click="currentTab = 0">聊天互动</view>
  16. <view class="tab-item" :class="{active: currentTab === 1}" @click="currentTab = 1">主播介绍</view>
  17. </view>
  18. <scroll-view scroll-y class="content-area" :scroll-top="scrollTop">
  19. <!-- 聊天区 -->
  20. <view class="chat-list" v-if="currentTab === 0">
  21. <view class="chat-item system">
  22. <text class="content">系统公告:欢迎来到直播间,请文明发言。</text>
  23. </view>
  24. <view class="chat-item" v-for="(item, index) in chatList" :key="index">
  25. <view class="user-name">{{item.name}}:</view>
  26. <view class="user-content">{{item.content}}</view>
  27. </view>
  28. </view>
  29. <!-- 介绍区 -->
  30. <view class="intro-box" v-if="currentTab === 1">
  31. <view class="anchor-card">
  32. <image src="https://via.placeholder.com/60" class="avatar"></image>
  33. <view class="info">
  34. <text class="name">李医生</text>
  35. <text class="title">主任医师 | 20年临床经验</text>
  36. </view>
  37. <view class="follow-btn">关注</view>
  38. </view>
  39. <view class="desc">
  40. <text class="desc-title">直播简介</text>
  41. <text class="desc-content">本期直播主要讲解春季常见病的预防与中医调理方法,特别是针对脾胃虚弱的人群,提供食疗方案。</text>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. <!-- 底部输入框 -->
  46. <view class="bottom-bar" v-if="currentTab === 0">
  47. <input type="text" v-model="inputContent" placeholder="说点什么..." class="input-box" confirm-type="send" @confirm="sendMsg" />
  48. <view class="send-btn" @click="sendMsg">发送</view>
  49. <view class="icon-btn">
  50. <u-icon name="heart" size="24" color="#666"></u-icon>
  51. </view>
  52. <view class="icon-btn">
  53. <u-icon name="share" size="24" color="#666"></u-icon>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. currentTab: 0,
  63. scrollTop: 0,
  64. inputContent: '',
  65. chatList: [
  66. { name: '用户8892', content: '医生讲得真好!' },
  67. { name: '快乐每一天', content: '请问这个药方可以直接抓药吗?' },
  68. { name: 'HealthUser', content: '已关注,期待下期。' },
  69. { name: '小张', content: '声音有点小,可以大一点吗?' }
  70. ]
  71. }
  72. },
  73. onLoad(options) {
  74. if(options.id) {
  75. // Load detail by id
  76. console.log('Live ID:', options.id);
  77. }
  78. },
  79. methods: {
  80. sendMsg() {
  81. if (!this.inputContent.trim()) return;
  82. this.chatList.push({
  83. name: '我',
  84. content: this.inputContent
  85. });
  86. this.inputContent = '';
  87. // Scroll to bottom
  88. this.$nextTick(() => {
  89. this.scrollTop = 99999;
  90. });
  91. }
  92. }
  93. }
  94. </script>
  95. <style scoped lang="scss">
  96. .live-detail-container {
  97. display: flex;
  98. flex-direction: column;
  99. height: 100vh;
  100. background-color: #f8f8f8;
  101. }
  102. .video-wrap {
  103. width: 100%;
  104. height: 422rpx;
  105. background-color: #000;
  106. .video-player {
  107. width: 100%;
  108. height: 100%;
  109. }
  110. }
  111. .tab-header {
  112. display: flex;
  113. height: 88rpx;
  114. background-color: #fff;
  115. border-bottom: 1rpx solid #eee;
  116. .tab-item {
  117. flex: 1;
  118. display: flex;
  119. align-items: center;
  120. justify-content: center;
  121. font-size: 28rpx;
  122. color: #666;
  123. position: relative;
  124. &.active {
  125. color: #2583EB;
  126. font-weight: bold;
  127. &::after {
  128. content: '';
  129. position: absolute;
  130. bottom: 0;
  131. left: 50%;
  132. transform: translateX(-50%);
  133. width: 40rpx;
  134. height: 4rpx;
  135. background-color: #2583EB;
  136. border-radius: 2rpx;
  137. }
  138. }
  139. }
  140. }
  141. .content-area {
  142. flex: 1;
  143. height: 0;
  144. background-color: #f5f5f5;
  145. }
  146. .chat-list {
  147. padding: 20rpx;
  148. .chat-item {
  149. margin-bottom: 16rpx;
  150. display: flex;
  151. align-items: flex-start;
  152. font-size: 26rpx;
  153. &.system {
  154. background-color: rgba(37, 131, 235, 0.1);
  155. padding: 10rpx;
  156. border-radius: 8rpx;
  157. color: #2583EB;
  158. justify-content: center;
  159. margin-bottom: 20rpx;
  160. }
  161. .user-name {
  162. color: #999;
  163. white-space: nowrap;
  164. }
  165. .user-content {
  166. color: #333;
  167. line-height: 1.4;
  168. }
  169. }
  170. }
  171. .intro-box {
  172. padding: 30rpx;
  173. background-color: #fff;
  174. .anchor-card {
  175. display: flex;
  176. align-items: center;
  177. margin-bottom: 30rpx;
  178. padding-bottom: 30rpx;
  179. border-bottom: 1rpx solid #eee;
  180. .avatar {
  181. width: 80rpx;
  182. height: 80rpx;
  183. border-radius: 50%;
  184. margin-right: 20rpx;
  185. background-color: #eee;
  186. }
  187. .info {
  188. flex: 1;
  189. display: flex;
  190. flex-direction: column;
  191. .name {
  192. font-size: 30rpx;
  193. font-weight: bold;
  194. margin-bottom: 8rpx;
  195. }
  196. .title {
  197. font-size: 24rpx;
  198. color: #999;
  199. }
  200. }
  201. .follow-btn {
  202. padding: 8rpx 24rpx;
  203. background-color: #2583EB;
  204. color: #fff;
  205. font-size: 24rpx;
  206. border-radius: 30rpx;
  207. }
  208. }
  209. .desc {
  210. .desc-title {
  211. font-size: 30rpx;
  212. font-weight: bold;
  213. margin-bottom: 16rpx;
  214. display: block;
  215. }
  216. .desc-content {
  217. font-size: 26rpx;
  218. color: #666;
  219. line-height: 1.6;
  220. }
  221. }
  222. }
  223. .bottom-bar {
  224. background-color: #fff;
  225. padding: 16rpx 20rpx;
  226. display: flex;
  227. align-items: center;
  228. padding-bottom: constant(safe-area-inset-bottom);
  229. padding-bottom: env(safe-area-inset-bottom);
  230. border-top: 1rpx solid #eee;
  231. .input-box {
  232. flex: 1;
  233. background-color: #f5f5f5;
  234. height: 72rpx;
  235. border-radius: 36rpx;
  236. padding: 0 30rpx;
  237. font-size: 26rpx;
  238. margin-right: 20rpx;
  239. }
  240. .send-btn {
  241. padding: 0 24rpx;
  242. height: 60rpx;
  243. line-height: 60rpx;
  244. background-color: #2583EB;
  245. color: #fff;
  246. font-size: 24rpx;
  247. border-radius: 30rpx;
  248. margin-right: 20rpx;
  249. }
  250. .icon-btn {
  251. width: 60rpx;
  252. display: flex;
  253. justify-content: center;
  254. margin-left: 10rpx;
  255. }
  256. }
  257. </style>