四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

665 lines
17 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="directory-container">
  3. <view class="book-container">
  4. <view class="book-info">
  5. <view class="book-cover">
  6. <image :src="bookInfo.booksImg" mode="aspectFill" :style="{ width: '100%', height: '100%' }"></image>
  7. </view>
  8. <view class="book-details">
  9. <view class="book-title">{{ bookInfo.translate }}</view>
  10. <view class="book-subtitle">{{ bookInfo.booksName }}</view>
  11. <view class="book-author">{{ bookInfo.booksAuthor }}</view>
  12. <view class="book-level" :class="classMap[bookInfo.vipInfo.title]">{{ bookInfo.vipInfo.title }}
  13. </view>
  14. </view>
  15. </view>
  16. <view class="book-knowledge">
  17. <view class="book-knowledge-title" v-if="bookInfo.vocabularyRange">
  18. <text>
  19. 适合词汇量
  20. </text>
  21. <text class="book-knowledge-vocabulary">
  22. {{ bookInfo.vocabularyRange }}
  23. </text>
  24. </view>
  25. <view class="border" />
  26. <view class="book-knowledge-detail" v-if="bookInfo.knowledgePoints">
  27. <view class="book-knowledge-detail-title">
  28. 知识收获
  29. </view>
  30. <uv-parse :content="bookInfo.knowledgePoints"></uv-parse>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 课程和简介容器 -->
  35. <view class="content-container">
  36. <!-- 课程部分 -->
  37. <view class="course-section">
  38. <view class="course-header">
  39. <view class="course-title">课程</view>
  40. </view>
  41. <view class="course-list">
  42. <!-- 限制在做多五個課程 -->
  43. <view v-for="(course, index) in computedList" :key="index" class="course-item"
  44. @click="startLearning(course.id)">
  45. <view class="course-number">{{ String(index + 1).padStart(2, '0') }}</view>
  46. <view class="course-content">
  47. <view class="course-name">{{ course.english }}</view>
  48. <view class="course-subtitle">{{ course.chinese }}</view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="course-footer">
  53. <view class="course-total" @click="showAllCoursePopup">全部课程 · {{ courseList.total }}</view>
  54. <uv-icon name="arrow-right" size="24rpx" color="#999"></uv-icon>
  55. </view>
  56. </view>
  57. <!-- 简介部分 -->
  58. <view class="intro-section">
  59. <view class="intro-title">简介</view>
  60. <uv-parse :content="bookInfo.booksIntro" class="intro-content"></uv-parse>
  61. </view>
  62. <!-- 作者部分 -->
  63. <view class="author-section">
  64. <view class="author-title">作者</view>
  65. <view class="author-info">
  66. <view class="author-avatar">
  67. <image :src="bookInfo.aouthorImg" mode="aspectFill"></image>
  68. <view>
  69. <view class="author-name">{{ bookInfo.enAuthor }}</view>
  70. <view class="author-subtitle">{{ bookInfo.booksAuthor }}</view>
  71. </view>
  72. </view>
  73. <view class="author-details">
  74. <view class="author-description">
  75. {{ bookInfo.aouthorIntro }}
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 底部固定操作栏 -->
  82. <view class="bottom-action-bar">
  83. <view class="bottom-action-container">
  84. <view class="action-button secondary" @click="joinCourse">
  85. <image src="/static/course-icon.png" class="button-icon" mode="aspectFill"></image>
  86. <text>加入课程</text>
  87. </view>
  88. <view class="action-button primary" @click="startLearning(courseList.records[0].id)">
  89. <image src="/static/content-icon.png" class="button-icon"></image>
  90. <text>内容朗读</text>
  91. </view>
  92. <uv-button @click="startLearning(courseList.records[0].id)" type="primary" :custom-style="{
  93. width: '400rpx',
  94. height: '80rpx',
  95. borderRadius: '198rpx',
  96. background: '#06DADC',
  97. fontSize: '28rpx',
  98. fontWeight: '600',
  99. }">开始学习</uv-button>
  100. </view>
  101. <uv-safe-bottom></uv-safe-bottom>
  102. </view>
  103. <!-- 全部課程彈出窗 -->
  104. <uv-popup mode="bottom" ref="allCoursePopup" round="32rpx" bg-color="#f8f8f8">
  105. <view class="course-popup">
  106. <view class="popup-header">
  107. <view @click="closeAllCoursePopup">
  108. <uv-icon name="arrow-down" color="black" size="20"></uv-icon>
  109. </view>
  110. <view class="popup-title">全部课程</view>
  111. <view class="popup-title" @click="toggleCourseSort">
  112. 倒序
  113. </view>
  114. </view>
  115. <view class="course-list">
  116. <view v-for="(course, index) in displayAllCourseList" :key="course.id" class="course-item"
  117. @click="startLearning(course.id)">
  118. <view class="course-number">{{ String(course.index || index + 1).padStart(2, '0') }}</view>
  119. <view class="course-content">
  120. <view class="course-english">{{ course.english }}</view>
  121. <view class="course-chinese">{{ course.chinese }}</view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </uv-popup>
  127. </view>
  128. </template>
  129. <script>
  130. export default {
  131. data() {
  132. return {
  133. classMap: {
  134. '朵蕾会员': 'book-level-1',
  135. '萌芽会员': 'book-level-2',
  136. '盛放会员': 'book-level-3',
  137. },
  138. bookInfo: {
  139. },
  140. id: '',
  141. courseList: [
  142. ],
  143. allCourseList: [], // 全部課程列表
  144. isCourseSortReversed: false, // 課程排序是否倒序
  145. }
  146. },
  147. computed: {
  148. // 顯示的全部課程列表(支持倒序)
  149. displayAllCourseList() {
  150. const list = this.allCourseList.length > 0 ? this.allCourseList : this.courseList.records || [];
  151. return this.isCourseSortReversed ? [...list].reverse() : list;
  152. },
  153. computedList() {
  154. return this.courseList.records?.slice(0, 5) || []
  155. }
  156. },
  157. methods: {
  158. goBack() {
  159. uni.navigateBack()
  160. },
  161. // 加入课程
  162. async joinCourse() {
  163. const joinRes = await this.$api.book.addStand({
  164. id: this.id
  165. })
  166. if (joinRes.code === 200) {
  167. uni.showToast({
  168. title: '加入成功',
  169. icon: 'success',
  170. duration: 2000
  171. })
  172. }
  173. },
  174. // 开始学习
  175. startLearning(id) {
  176. // 默认学第一堂课
  177. uni.navigateTo({
  178. url: '/subPages/home/book?courseId=' + id + '&bookId=' + this.id + '&memberId=' + this.bookInfo.vip
  179. })
  180. },
  181. scroll() {
  182. console.log('被点击了');
  183. this.$scrollTo('testRef')
  184. },
  185. // 获取书籍详情
  186. async getDetail() {
  187. const detailRes = await this.$api.book.detail({
  188. id: this.id
  189. })
  190. if (detailRes.code === 200) {
  191. this.bookInfo = detailRes.result
  192. }
  193. },
  194. // 获取书籍的课程
  195. async getCourse() {
  196. const courseRes = await this.$api.book.course({
  197. id: this.id,
  198. pageNo: 1,
  199. pageSize: 999
  200. })
  201. if (courseRes.code === 200) {
  202. this.courseList = courseRes.result
  203. // 同時設置全部課程列表
  204. this.allCourseList = courseRes.result.records || []
  205. }
  206. },
  207. // 顯示全部課程彈出窗
  208. showAllCoursePopup() {
  209. this.$refs.allCoursePopup.open()
  210. },
  211. // 關閉全部課程彈出窗
  212. closeAllCoursePopup() {
  213. this.$refs.allCoursePopup.close()
  214. },
  215. // 切換課程排序
  216. toggleCourseSort() {
  217. this.isCourseSortReversed = !this.isCourseSortReversed
  218. }
  219. },
  220. onLoad(options) {
  221. if (options.id) {
  222. this.id = options.id
  223. Promise.all([
  224. this.getDetail(),
  225. this.getCourse()
  226. ])
  227. }
  228. }
  229. }
  230. </script>
  231. <style scoped lang="scss">
  232. .directory-container {
  233. min-height: 100vh;
  234. background-color: #264C8F;
  235. }
  236. .book-container {
  237. // position: sticky;
  238. // left: 0;
  239. // right: 0;
  240. // top: 0;
  241. padding: 30rpx;
  242. // z-index: 1;
  243. }
  244. .book-info {
  245. display: flex;
  246. align-items: start;
  247. gap: 32rpx;
  248. .book-cover {
  249. width: 208rpx;
  250. height: 292rpx;
  251. border-radius: 16rpx;
  252. }
  253. .book-details {
  254. color: white;
  255. display: flex;
  256. flex-direction: column;
  257. gap: 16rpx;
  258. .book-title {
  259. font-weight: 500;
  260. font-size: 40rpx;
  261. }
  262. .book-subtitle {
  263. font-weight: 500;
  264. font-size: 30rpx;
  265. }
  266. .book-author {
  267. font-size: 24rpx;
  268. }
  269. .book-level {
  270. font-size: 24rpx;
  271. width: 124rpx;
  272. height: 38rpx;
  273. border-radius: 8rpx;
  274. text-align: center;
  275. line-height: 38rpx;
  276. color: #080D21;
  277. background: #E9F1FF;
  278. border: 2rpx solid #C4DAFF
  279. }
  280. .book-level-1 {
  281. background: #E9F1FF;
  282. border: 2rpx solid #C4DAFF
  283. }
  284. .book-level-2 {
  285. background: #FFE9E9;
  286. border: 2rpx solid #FFDBC4
  287. }
  288. .book-level-3 {
  289. background: #FFF4E9;
  290. border: 2rpx solid #FFE2C4
  291. }
  292. }
  293. }
  294. .book-knowledge {
  295. box-shadow: 0px 1px 5px 0px #103577;
  296. background: #234684;
  297. color: #fff;
  298. margin-top: 32rpx;
  299. border: 2rpx solid #FFFFFF3B;
  300. border-radius: 32rpx;
  301. padding-top: 32rpx;
  302. padding-right: 40rpx;
  303. padding-bottom: 32rpx;
  304. padding-left: 40rpx;
  305. gap: 24rpx;
  306. display: flex;
  307. flex-direction: column;
  308. gap: 22rpx;
  309. .book-knowledge-title {
  310. font-size: 32rpx;
  311. font-weight: 600;
  312. display: flex;
  313. justify-content: space-between;
  314. .book-knowledge-vocabulary {
  315. font-size: 40rpx;
  316. color: #06DADC;
  317. }
  318. }
  319. .border {
  320. width: 100%;
  321. border: 2rpx solid;
  322. border-image-source: linear-gradient(90deg, rgba(233, 181, 123, 0) 0%, rgba(255, 255, 255, 0.79) 50.48%, rgba(233, 181, 123, 0) 100%);
  323. border-image-slice: 1;
  324. }
  325. .book-knowledge-detail-title {
  326. font-size: 32rpx;
  327. font-weight: 600;
  328. margin-bottom: 16rpx;
  329. }
  330. }
  331. /* 课程和简介容器 */
  332. .content-container {
  333. padding: 40rpx 32rpx 240rpx;
  334. border-radius: 40rpx 40rpx 0 0;
  335. overflow: hidden;
  336. background: #fff;
  337. display: flex;
  338. gap: 24rpx;
  339. flex-direction: column;
  340. position: relative;
  341. }
  342. /* 课程部分 */
  343. .course-section {
  344. background: #F8F8F8;
  345. border-radius: 32rpx;
  346. border-radius: 32rpx;
  347. padding-top: 36rpx;
  348. padding-right: 32rpx;
  349. padding-bottom: 36rpx;
  350. padding-left: 32rpx;
  351. gap: 36rpx;
  352. display: flex;
  353. flex-direction: column;
  354. }
  355. .course-title {
  356. font-size: 32rpx;
  357. font-weight: 600;
  358. color: #3B3D3D;
  359. }
  360. .course-list {
  361. // margin-bottom: 32rpx;
  362. display: flex;
  363. flex-direction: column;
  364. gap: 24rpx;
  365. }
  366. .course-item {
  367. display: flex;
  368. align-items: center;
  369. // background: red;
  370. border-bottom: 2rpx solid #EEEEEE;
  371. padding-bottom: 20rpx;
  372. gap: 36rpx;
  373. }
  374. .course-item:last-child {
  375. border-bottom: none;
  376. }
  377. .course-number {
  378. font-size: 36rpx;
  379. color: #999;
  380. }
  381. .course-content {
  382. flex: 1;
  383. }
  384. .course-name {
  385. font-size: 32rpx;
  386. font-weight: 600;
  387. color: #3B3D3D;
  388. margin-bottom: 8rpx;
  389. }
  390. .course-subtitle {
  391. font-size: 28rpx;
  392. color: #3B3D3D;
  393. }
  394. .course-footer {
  395. display: flex;
  396. align-items: center;
  397. // justify-content: space-between;
  398. }
  399. .course-total {
  400. font-size: 24rpx;
  401. color: #999;
  402. cursor: pointer;
  403. }
  404. /* 课程弹出窗样式 */
  405. .course-popup {
  406. padding: 0 32rpx;
  407. max-height: 80vh;
  408. .popup-header {
  409. display: flex;
  410. justify-content: space-between;
  411. align-items: center;
  412. padding: 20rpx 0;
  413. border-bottom: 2rpx solid #EEEEEE // margin-bottom: 40rpx;
  414. }
  415. .popup-title {
  416. font-family: PingFang SC;
  417. font-weight: 500;
  418. font-size: 34rpx;
  419. color: #181818;
  420. }
  421. .course-list {
  422. max-height: 60vh;
  423. overflow-y: auto;
  424. }
  425. .course-item {
  426. display: flex;
  427. align-items: center;
  428. gap: 24rpx;
  429. padding-top: 24rpx;
  430. padding-right: 8rpx;
  431. padding-bottom: 24rpx;
  432. padding-left: 8rpx;
  433. border-bottom: 1px solid #EEEEEE;
  434. cursor: pointer;
  435. &:last-child {
  436. border-bottom: none;
  437. }
  438. }
  439. .course-number {
  440. width: 80rpx;
  441. font-family: PingFang SC;
  442. // font-weight: 400;
  443. font-size: 36rpx;
  444. color: #999;
  445. &.highlight {
  446. color: $primary-color;
  447. }
  448. // margin-right: 24rpx;
  449. }
  450. .course-content {
  451. flex: 1;
  452. }
  453. .course-english {
  454. font-family: PingFang SC;
  455. font-weight: 600;
  456. font-size: 36rpx;
  457. line-height: 44rpx;
  458. color: #252545;
  459. margin-bottom: 8rpx;
  460. &.highlight {
  461. color: $primary-color;
  462. }
  463. }
  464. .course-chinese {
  465. font-size: 28rpx;
  466. line-height: 48rpx;
  467. color: #3B3D3D;
  468. &.highlight {
  469. color: $primary-color;
  470. }
  471. }
  472. }
  473. /* 简介部分 */
  474. .intro-section {
  475. background: #F8F8F8;
  476. border-radius: 32rpx;
  477. padding: 32rpx;
  478. }
  479. .intro-title {
  480. font-size: 32rpx;
  481. font-weight: 600;
  482. color: #3B3D3D;
  483. margin-bottom: 24rpx;
  484. }
  485. .intro-content {
  486. font-size: 28rpx;
  487. line-height: 48rpx;
  488. color: #4F4F4F;
  489. }
  490. /* 作者部分 */
  491. .author-section {
  492. background: #F8F8F8;
  493. border-radius: 32rpx;
  494. padding: 32rpx;
  495. .author-title {
  496. font-size: 32rpx;
  497. font-weight: 600;
  498. color: #3B3D3D;
  499. margin-bottom: 24rpx;
  500. }
  501. .author-info {
  502. display: flex;
  503. gap: 24rpx;
  504. align-items: flex-start;
  505. flex-direction: column;
  506. .author-avatar {
  507. display: flex;
  508. align-items: center;
  509. gap: 16rpx;
  510. image {
  511. width: 80rpx;
  512. height: 80rpx;
  513. border-radius: 50%;
  514. overflow: hidden;
  515. flex-shrink: 0;
  516. }
  517. .author-name {
  518. font-size: 36rpx;
  519. font-weight: 600;
  520. color: #252545;
  521. margin-bottom: 12rpx;
  522. }
  523. .author-subtitle {
  524. font-size: 28rpx;
  525. color: #3B3D3D;
  526. // margin-bottom: 16rpx;
  527. }
  528. }
  529. .author-details {
  530. flex: 1;
  531. .author-description {
  532. font-size: 28rpx;
  533. line-height: 48rpx;
  534. color: #4F4F4F;
  535. }
  536. }
  537. }
  538. }
  539. /* 底部固定操作栏 */
  540. .bottom-action-bar {
  541. position: fixed;
  542. bottom: 0;
  543. left: 0;
  544. right: 0;
  545. background: #fff;
  546. padding: 24rpx 32rpx 0;
  547. box-shadow: 0rpx -2rpx 0rpx 0rpx #0000001A;
  548. z-index: 99;
  549. .bottom-action-container {
  550. display: flex;
  551. align-items: center;
  552. gap: 20rpx;
  553. .action-button {
  554. display: flex;
  555. flex-direction: column;
  556. align-items: center;
  557. justify-content: center;
  558. padding: 16rpx 0rpx;
  559. border-radius: 16rpx;
  560. min-width: 120rpx;
  561. gap: 8rpx;
  562. .button-icon {
  563. width: 44rpx;
  564. height: 44rpx;
  565. }
  566. text {
  567. font-size: 24rpx;
  568. color: #999999;
  569. }
  570. }
  571. }
  572. }
  573. </style>