onlineLecture.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <view class="container">
  3. <!-- 搜索栏 -->
  4. <view class="search-bar">
  5. <view class="search-input-wrapper">
  6. <!-- <text class="search-icon"></text> -->
  7. <u-icon name="search" size="24" color="#C8C9CC"></u-icon>
  8. <input
  9. class="search-input"
  10. v-model="keyword"
  11. placeholder="请输入关键字"
  12. @confirm="doSearch"
  13. placeholder-class="placeholder"
  14. />
  15. </view>
  16. </view>
  17. <!-- 标签栏 -->
  18. <view class="tabs-bar">
  19. <view class="tab-item"
  20. :class="{ active: currentTab === 'incomplete' }"
  21. @click="switchTab('incomplete')">
  22. 未完成
  23. </view>
  24. <view class="tab-item"
  25. :class="{ active: currentTab === 'completed' }"
  26. @click="switchTab('completed')">
  27. 已完成
  28. </view>
  29. </view>
  30. <!-- 讲座列表 -->
  31. <scroll-view class="content" scroll-y>
  32. <view class="lecture-card" v-for="(item, index) in lectureList" :key="index">
  33. <view class="card-thumbnail">
  34. <image class="thumbnail-img" :src="item.thumbnail" mode="aspectFill"></image>
  35. <view class="thumbnail-status" v-if="item.status === 'inProgress'">
  36. <image mode="aspectFill" src="@/static/image/icon_goon.png"></image>
  37. <view class="status">进行中</view>
  38. </view>
  39. <view class="thumbnail-date" v-else-if="item.scheduledTime">
  40. <image mode="aspectFill" src="@/static/image/icon_tobestart.png"></image>
  41. <text class="date-text">{{ item.scheduledTime }}</text>
  42. </view>
  43. </view>
  44. <view class="card-content">
  45. <view class="card-title">{{ item.title }}</view>
  46. <view class="card-tags">
  47. <view class="tag-item">{{ item.category }}</view>
  48. <view class="tag-item">{{ item.type }}</view>
  49. </view>
  50. <view class="card-points">{{ item.points }} 积分</view>
  51. <view class="card-views" v-if="currentTab === 'completed'">
  52. <text class="eye-icon">👁</text>
  53. <text>{{ item.viewCount }}</text>
  54. </view>
  55. <view class="card-action">
  56. <view class="action-btn"
  57. v-if="item.status === 'inProgress' || item.status === 'scheduled'"
  58. @click.stop="openChannelPicker(item)">
  59. {{ item.status === 'inProgress' ? '继续开播' : '去开播' }}
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="no-more">没有更多了~</view>
  65. </scroll-view>
  66. <!-- 选择开播渠道弹窗 -->
  67. <view class="channel-picker-popup" v-if="showChannelPicker" @click="showChannelPicker = false">
  68. <view class="channel-picker-content" @click.stop>
  69. <view class="picker-header">
  70. <view class="picker-title">选择开播渠道</view>
  71. <view class="picker-close" @click="showChannelPicker = false">
  72. <image class="w32 h32" src="@/static/image/icon_cross.png" mode=""></image>
  73. </view>
  74. </view>
  75. <!-- 电脑浏览器开播 -->
  76. <view class="channel-option">
  77. <view class="option-content">
  78. <view class="x-f mb20">
  79. <image class="w32 h32" mode="aspectFill" src="@/static/image/icon_live_pc.png"></image>
  80. <view class="option-title">电脑浏览器开播</view>
  81. </view>
  82. <view class="option-url-wrapper">
  83. <text class="option-url">{{ broadcastUrl }}</text>
  84. <view class="copy-btn" @click="copyUrl">复制链接</view>
  85. </view>
  86. <view class="option-tips">复制至谷歌浏览器,登录账号即可开播</view>
  87. </view>
  88. </view>
  89. <!-- 微信小程序开播 -->
  90. <view class="channel-option">
  91. <view class="option-content">
  92. <view class="x-f mb20">
  93. <image class="w32 h32" mode="aspectFill" src="@/static/image/icon_live_phone.png"></image>
  94. <view class="option-title">微信小程序开播</view>
  95. </view>
  96. <view class="option-action">
  97. <view class="enter-btn" @click="enterMiniProgram">立即进入</view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. import { getOnlineLectureList, getBroadcastUrl, enterMiniProgram } from '@/api-js/onlineLecture'
  107. export default {
  108. data() {
  109. return {
  110. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  111. keyword: '',
  112. currentTab: 'incomplete',
  113. showChannelPicker: false,
  114. broadcastUrl: 'https://www.test.coe.huahua...',
  115. currentLecture: null,
  116. lectureList: []
  117. }
  118. },
  119. onLoad() {
  120. this.loadData()
  121. },
  122. onReachBottom() {
  123. this.loadMore()
  124. },
  125. methods: {
  126. goBack() {
  127. uni.navigateBack()
  128. },
  129. doSearch() {
  130. this.loadData()
  131. },
  132. switchTab(tab) {
  133. this.currentTab = tab
  134. this.loadData()
  135. },
  136. async openChannelPicker(item) {
  137. this.currentLecture = item
  138. // try {
  139. // const res = await getBroadcastUrl({ lectureId: item.id })
  140. // if (res.code === 200 && res.data) {
  141. // this.broadcastUrl = res.data.url
  142. // }
  143. // } catch (e) {
  144. // console.error('获取开播链接失败', e)
  145. // }
  146. this.showChannelPicker = true
  147. },
  148. copyUrl() {
  149. uni.setClipboardData({
  150. data: this.broadcastUrl,
  151. success: () => {
  152. uni.showToast({
  153. icon: 'success',
  154. title: '链接已复制'
  155. })
  156. }
  157. })
  158. },
  159. async enterMiniProgram() {
  160. try {
  161. const res = await enterMiniProgram({ lectureId: this.currentLecture.id })
  162. if (res.code === 200 && res.data) {
  163. // 跳转到微信小程序
  164. uni.navigateToMiniProgram({
  165. appId: res.data.appId,
  166. path: res.data.path,
  167. success: () => {
  168. this.showChannelPicker = false
  169. }
  170. })
  171. }
  172. } catch (e) {
  173. uni.showToast({
  174. icon: 'none',
  175. title: '进入失败'
  176. })
  177. }
  178. },
  179. async loadData() {
  180. try {
  181. uni.showLoading({ title: '加载中...' })
  182. const res = await getOnlineLectureList({
  183. keyword: this.keyword,
  184. status: this.currentTab,
  185. page: 1,
  186. pageSize: 20
  187. })
  188. uni.hideLoading()
  189. if (res.code === 200 && res.data) {
  190. this.lectureList = res.data.list || this.getDefaultData()
  191. } else {
  192. this.lectureList = this.getDefaultData()
  193. }
  194. } catch (e) {
  195. uni.hideLoading()
  196. console.error('加载数据失败', e)
  197. this.lectureList = this.getDefaultData()
  198. }
  199. },
  200. async loadMore() {
  201. // 加载更多数据
  202. },
  203. getDefaultData() {
  204. if (this.currentTab === 'incomplete') {
  205. return [
  206. {
  207. id: 1,
  208. title: '康复医学概论',
  209. thumbnail: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20240516/b091048293f142608f99eaf1b0b1510a.png',
  210. category: '学术讲座',
  211. type: '单人讲座',
  212. points: '32.50',
  213. status: 'inProgress',
  214. scheduledTime: ''
  215. },
  216. {
  217. id: 2,
  218. title: '中医养生至冬病夏天治...',
  219. thumbnail: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20240516/b091048293f142608f99eaf1b0b1510a.png',
  220. category: '学术讲座',
  221. type: '单人讲座',
  222. points: '32.50',
  223. status: 'scheduled',
  224. scheduledTime: '05-12 12:00'
  225. },
  226. {
  227. id: 3,
  228. title: '康复医学概论',
  229. thumbnail: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20240516/b091048293f142608f99eaf1b0b1510a.png',
  230. category: '学术讲座',
  231. type: '单人讲座',
  232. points: '32.50',
  233. status: 'scheduled',
  234. scheduledTime: '05-24 16:00'
  235. }
  236. ]
  237. } else {
  238. return [
  239. {
  240. id: 4,
  241. title: '康复医学概论',
  242. thumbnail: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20240516/b091048293f142608f99eaf1b0b1510a.png',
  243. category: '学术讲座',
  244. type: '单人讲座',
  245. points: '32.50',
  246. viewCount: '123',
  247. scheduledTime: '05-12 12:00'
  248. },
  249. {
  250. id: 5,
  251. title: '康复医学概论',
  252. thumbnail: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20240516/b091048293f142608f99eaf1b0b1510a.png',
  253. category: '学术讲座',
  254. type: '单人讲座',
  255. points: '32.50',
  256. viewCount: '123',
  257. scheduledTime: '05-12 12:00'
  258. },
  259. {
  260. id: 6,
  261. title: '康复医学概论',
  262. thumbnail: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20240516/b091048293f142608f99eaf1b0b1510a.png',
  263. category: '学术讲座',
  264. type: '单人讲座',
  265. points: '32.50',
  266. viewCount: '123',
  267. scheduledTime: '05-12 12:00'
  268. }
  269. ]
  270. }
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="stylus">
  276. .placeholder{
  277. color: #C8C9CC !important;
  278. }
  279. </style>
  280. <style lang="scss" scoped>
  281. .container {
  282. min-height: 100vh;
  283. background: #f5f5f5;
  284. display: flex;
  285. flex-direction: column;
  286. }
  287. .status-bar {
  288. width: 100%;
  289. background: #fff;
  290. }
  291. .header {
  292. position: relative;
  293. height: 88rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. background: #fff;
  298. border-bottom: 1rpx solid #f0f0f0;
  299. .back-btn {
  300. position: absolute;
  301. left: 24rpx;
  302. width: 40rpx;
  303. height: 40rpx;
  304. image {
  305. width: 100%;
  306. height: 100%;
  307. }
  308. }
  309. .title {
  310. font-size: 36rpx;
  311. font-weight: bold;
  312. color: #333;
  313. }
  314. .header-right {
  315. position: absolute;
  316. right: 24rpx;
  317. display: flex;
  318. align-items: center;
  319. gap: 16rpx;
  320. .more-icon {
  321. font-size: 32rpx;
  322. color: #333;
  323. }
  324. }
  325. }
  326. .search-bar {
  327. padding: 24rpx;
  328. background: #fff;
  329. border-bottom: 1rpx solid #f0f0f0;
  330. .search-input-wrapper {
  331. display: flex;
  332. align-items: center;
  333. height: 72rpx;
  334. background: #F7F8FA;
  335. border-radius: 36rpx;
  336. padding: 0 24rpx;
  337. .search-icon {
  338. font-size: 32rpx;
  339. margin-right: 16rpx;
  340. color: #999;
  341. }
  342. .search-input {
  343. flex: 1;
  344. font-size: 28rpx;
  345. color: #333;
  346. }
  347. }
  348. }
  349. .tabs-bar {
  350. display: flex;
  351. background: #fff;
  352. border-bottom: 1rpx solid #f0f0f0;
  353. .tab-item {
  354. flex: 1;
  355. height: 88rpx;
  356. line-height: 88rpx;
  357. text-align: center;
  358. font-size: 28rpx;
  359. color: #666;
  360. position: relative;
  361. &.active {
  362. color: #388BFF;
  363. font-weight: bold;
  364. &::after {
  365. content: '';
  366. position: absolute;
  367. bottom: 0;
  368. left: 0;
  369. right: 0;
  370. height: 4rpx;
  371. background: #388BFF;
  372. }
  373. }
  374. }
  375. }
  376. .content {
  377. flex: 1;
  378. padding: 24rpx;
  379. box-sizing:border-box;
  380. }
  381. .lecture-card {
  382. display: flex;
  383. background: #fff;
  384. border-radius: 16rpx;
  385. padding: 24rpx;
  386. margin-bottom: 24rpx;
  387. .card-thumbnail {
  388. position: relative;
  389. width: 240rpx;
  390. height: 180rpx;
  391. border-radius: 12rpx;
  392. overflow: hidden;
  393. margin-right: 24rpx;
  394. flex-shrink: 0;
  395. .thumbnail-img {
  396. width: 100%;
  397. height: 100%;
  398. }
  399. .thumbnail-status {
  400. position: absolute;
  401. top: 0rpx;
  402. left: 0rpx;
  403. width: 112rpx;
  404. height: 32rpx;
  405. display: flex;
  406. align-items: center;
  407. background: rgba(0, 0, 0, 0.4);
  408. border-radius: 16rpx 0rpx 16rpx 0rpx;
  409. font-weight: 500;
  410. font-size: 20rpx;
  411. color: #FFFFFF;
  412. font-family: PingFang SC-Bold, PingFang SC;
  413. image {
  414. width: 36rpx;
  415. height: 32rpx;
  416. margin-right: 8rpx;
  417. };
  418. .status-text {
  419. font-size: 20rpx;
  420. color: #fff;
  421. }
  422. }
  423. .thumbnail-date {
  424. position: absolute;
  425. top: 0rpx;
  426. left: 0rpx;
  427. width: 166rpx;
  428. height: 32rpx;
  429. display: flex;
  430. align-items: center;
  431. background: rgba(0, 0, 0, 0.4);
  432. border-radius: 16rpx 0rpx 16rpx 0rpx;
  433. font-weight: 500;
  434. font-size: 20rpx;
  435. color: #FFFFFF;
  436. font-family: PingFang SC-Bold, PingFang SC;
  437. image {
  438. width: 36rpx;
  439. height: 32rpx;
  440. margin-right: 8rpx;
  441. };
  442. .date-text {
  443. font-size: 20rpx;
  444. color: #fff;
  445. }
  446. }
  447. }
  448. .card-content {
  449. flex: 1;
  450. display: flex;
  451. flex-direction: column;
  452. justify-content: space-between;
  453. .card-title {
  454. font-size: 30rpx;
  455. font-weight: bold;
  456. color: #333;
  457. margin-bottom: 12rpx;
  458. overflow: hidden;
  459. text-overflow: ellipsis;
  460. white-space: nowrap;
  461. }
  462. .card-tags {
  463. display: flex;
  464. align-items: center;
  465. gap: 12rpx;
  466. margin-bottom: 12rpx;
  467. .tag-item {
  468. padding: 4rpx 12rpx;
  469. background: #f5f5f5;
  470. border-radius: 4rpx;
  471. font-size: 22rpx;
  472. color: #666;
  473. }
  474. }
  475. .card-points {
  476. font-size: 26rpx;
  477. color: #333;
  478. margin-bottom: 12rpx;
  479. }
  480. .card-views {
  481. display: flex;
  482. align-items: center;
  483. gap: 4rpx;
  484. font-size: 24rpx;
  485. color: #999;
  486. margin-bottom: 12rpx;
  487. .eye-icon {
  488. font-size: 24rpx;
  489. }
  490. }
  491. .card-action {
  492. display: flex;
  493. justify-content: flex-end;
  494. .action-btn {
  495. display: flex;
  496. align-items: center;
  497. justify-content: center;
  498. width: 144rpx;
  499. height: 56rpx;
  500. background: #388BFF;
  501. border-radius: 34rpx 34rpx 34rpx 34rpx;
  502. font-family: PingFang SC, PingFang SC;
  503. font-weight: 500;
  504. font-size: 24rpx;
  505. color: #FFFFFF;
  506. }
  507. }
  508. }
  509. }
  510. .no-more {
  511. text-align: center;
  512. padding: 48rpx 0;
  513. font-size: 24rpx;
  514. color: #999;
  515. }
  516. .channel-picker-popup {
  517. position: fixed;
  518. top: 0;
  519. left: 0;
  520. right: 0;
  521. bottom: 0;
  522. background: rgba(0, 0, 0, 0.5);
  523. z-index: 999;
  524. display: flex;
  525. align-items: center;
  526. justify-content: center;
  527. }
  528. .channel-picker-content {
  529. width: 90%;
  530. max-width: 600rpx;
  531. background: #fff;
  532. border-radius: 24rpx;
  533. padding: 24rpx;
  534. .picker-header {
  535. display: flex;
  536. align-items: center;
  537. justify-content: center;
  538. // padding: 32rpx 24rpx;
  539. position: relative;
  540. margin-bottom: 32rpx;
  541. .picker-title {
  542. font-size: 32rpx;
  543. font-weight: bold;
  544. color: #333;
  545. }
  546. .picker-close {
  547. position: absolute;
  548. right: 0;
  549. top: 50%;
  550. transform: translateY(-50%);
  551. width: 48rpx;
  552. height: 48rpx;
  553. display: flex;
  554. align-items: center;
  555. justify-content: center;
  556. font-size: 40rpx;
  557. color: #999;
  558. }
  559. }
  560. .channel-option {
  561. display: flex;
  562. align-items: flex-start;
  563. margin-bottom: 32rpx;
  564. &:last-child {
  565. margin-bottom: 0;
  566. }
  567. .option-icon {
  568. width: 64rpx;
  569. height: 64rpx;
  570. display: flex;
  571. align-items: center;
  572. justify-content: center;
  573. font-size: 48rpx;
  574. margin-right: 24rpx;
  575. flex-shrink: 0;
  576. &.wechat {
  577. background: #07C160;
  578. border-radius: 8rpx;
  579. }
  580. }
  581. .option-content {
  582. flex: 1;
  583. .option-title {
  584. font-size: 30rpx;
  585. font-weight: bold;
  586. color: #333;
  587. margin-left:16rpx ;
  588. // margin-bottom: 16rpx;
  589. }
  590. .option-url-wrapper {
  591. display: flex;
  592. align-items: center;
  593. gap: 16rpx;
  594. margin-bottom: 16rpx;
  595. .option-url {
  596. flex: 1;
  597. padding: 16rpx 24rpx;
  598. background: #f5f5f5;
  599. border-radius: 8rpx;
  600. font-size: 24rpx;
  601. color: #666;
  602. overflow: hidden;
  603. text-overflow: ellipsis;
  604. white-space: nowrap;
  605. }
  606. .copy-btn {
  607. padding: 12rpx 24rpx;
  608. background: #388BFF;
  609. border-radius: 8rpx;
  610. font-size: 24rpx;
  611. color: #fff;
  612. white-space: nowrap;
  613. }
  614. }
  615. .option-tips {
  616. font-size: 22rpx;
  617. color: #999;
  618. }
  619. .option-action {
  620. display: flex;
  621. justify-content: flex-end;
  622. .enter-btn {
  623. padding: 12rpx 24rpx;
  624. background: #388BFF;
  625. border-radius: 34rpx 34rpx 34rpx 34rpx;
  626. font-family: PingFang SC, PingFang SC;
  627. font-weight: 500;
  628. font-size: 24rpx;
  629. color: #FFFFFF;
  630. }
  631. }
  632. }
  633. }
  634. }
  635. </style>