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

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