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

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