四零语境前端代码仓库
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.

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