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

653 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 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 computedList"
  44. :key="index"
  45. class="course-item"
  46. @click="startLearning(course.id)"
  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/course-icon.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/content-icon.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 @click="closeAllCoursePopup">
  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. computedList(){
  166. return this.courseList.records?.slice(0, 5) || []
  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: 999
  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. closeAllCoursePopup() {
  221. this.$refs.allCoursePopup.close()
  222. },
  223. // 切換課程排序
  224. toggleCourseSort() {
  225. this.isCourseSortReversed = !this.isCourseSortReversed
  226. }
  227. },
  228. onLoad(options) {
  229. if (options.id){
  230. this.id = options.id
  231. Promise.all([
  232. this.getDetail(),
  233. this.getCourse()
  234. ])
  235. }
  236. }
  237. }
  238. </script>
  239. <style scoped lang="scss">
  240. .directory-container {
  241. min-height: 100vh;
  242. background-color: #264C8F;
  243. }
  244. .book-container{
  245. // position: sticky;
  246. // left: 0;
  247. // right: 0;
  248. // top: 0;
  249. padding: 30rpx;
  250. // z-index: 1;
  251. }
  252. .book-info {
  253. display: flex;
  254. align-items: start;
  255. gap: 32rpx;
  256. .book-cover {
  257. width: 208rpx;
  258. height: 292rpx;
  259. border-radius: 16rpx;
  260. }
  261. .book-details{
  262. color: white;
  263. display: flex;
  264. flex-direction: column;
  265. gap: 16rpx;
  266. .book-title{
  267. font-weight: 500;
  268. font-size: 40rpx;
  269. }
  270. .book-subtitle{
  271. font-weight: 500;
  272. font-size: 30rpx;
  273. }
  274. .book-author{
  275. font-size: 24rpx;
  276. }
  277. .book-level{
  278. font-size: 24rpx;
  279. width: 124rpx;
  280. height: 38rpx;
  281. border-radius: 8rpx;
  282. text-align: center;
  283. line-height: 38rpx;
  284. color: #080D21;
  285. }
  286. .book-level-1{
  287. background: #E9F1FF;
  288. border: 2rpx solid #C4DAFF
  289. }
  290. .book-level-2{
  291. background: #FFE9E9;
  292. border: 2rpx solid #FFDBC4
  293. }
  294. .book-level-3{
  295. background: #FFF4E9;
  296. border: 2rpx solid #FFE2C4
  297. }
  298. }
  299. }
  300. .book-knowledge{
  301. box-shadow: 0px 1px 5px 0px #103577;
  302. background: #234684;
  303. color: #fff;
  304. margin-top: 32rpx;
  305. border: 2rpx solid #FFFFFF3B;
  306. border-radius: 32rpx;
  307. padding-top: 32rpx;
  308. padding-right: 40rpx;
  309. padding-bottom: 32rpx;
  310. padding-left: 40rpx;
  311. gap: 24rpx;
  312. display: flex;
  313. flex-direction: column;
  314. gap: 22rpx;
  315. .book-knowledge-title{
  316. font-size: 32rpx;
  317. font-weight: 600;
  318. display: flex;
  319. justify-content: space-between;
  320. .book-knowledge-vocabulary{
  321. font-size: 40rpx;
  322. color: #06DADC;
  323. }
  324. }
  325. .border {
  326. width: 100%;
  327. border: 2rpx solid;
  328. 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%);
  329. border-image-slice: 1;
  330. }
  331. .book-knowledge-detail-title{
  332. font-size: 32rpx;
  333. font-weight: 600;
  334. margin-bottom: 16rpx;
  335. }
  336. }
  337. /* 课程和简介容器 */
  338. .content-container {
  339. padding: 40rpx 32rpx 240rpx;
  340. border-radius: 40rpx 40rpx 0 0;
  341. overflow: hidden;
  342. background: #fff;
  343. display: flex;
  344. gap: 24rpx;
  345. flex-direction: column;
  346. position: relative;
  347. z-index: 9999;
  348. }
  349. /* 课程部分 */
  350. .course-section {
  351. background: #F8F8F8;
  352. border-radius: 32rpx;
  353. border-radius: 32rpx;
  354. padding-top: 36rpx;
  355. padding-right: 32rpx;
  356. padding-bottom: 36rpx;
  357. padding-left: 32rpx;
  358. gap: 36rpx;
  359. display: flex;
  360. flex-direction: column;
  361. }
  362. .course-title {
  363. font-size: 32rpx;
  364. font-weight: 600;
  365. color: #3B3D3D;
  366. }
  367. .course-list {
  368. // margin-bottom: 32rpx;
  369. display: flex;
  370. flex-direction: column;
  371. gap: 24rpx;
  372. }
  373. .course-item {
  374. display: flex;
  375. align-items: center;
  376. // background: red;
  377. border-bottom: 2rpx solid #EEEEEE;
  378. padding-bottom: 20rpx;
  379. gap: 36rpx;
  380. }
  381. .course-item:last-child {
  382. border-bottom: none;
  383. }
  384. .course-number {
  385. font-size: 36rpx;
  386. color: #999;
  387. }
  388. .course-content {
  389. flex: 1;
  390. }
  391. .course-name {
  392. font-size: 32rpx;
  393. font-weight: 600;
  394. color: #3B3D3D;
  395. margin-bottom: 8rpx;
  396. }
  397. .course-subtitle {
  398. font-size: 28rpx;
  399. color: #3B3D3D;
  400. }
  401. .course-footer {
  402. display: flex;
  403. align-items: center;
  404. // justify-content: space-between;
  405. }
  406. .course-total {
  407. font-size: 24rpx;
  408. color: #999;
  409. cursor: pointer;
  410. }
  411. /* 课程弹出窗样式 */
  412. .course-popup {
  413. padding: 0 32rpx;
  414. max-height: 80vh;
  415. .popup-header {
  416. display: flex;
  417. justify-content: space-between;
  418. align-items: center;
  419. padding: 20rpx 0;
  420. border-bottom: 2rpx solid #EEEEEE
  421. // margin-bottom: 40rpx;
  422. }
  423. .popup-title {
  424. font-family: PingFang SC;
  425. font-weight: 500;
  426. font-size: 34rpx;
  427. color: #181818;
  428. }
  429. .course-list {
  430. max-height: 60vh;
  431. overflow-y: auto;
  432. }
  433. .course-item {
  434. display: flex;
  435. align-items: center;
  436. gap: 24rpx;
  437. padding-top: 24rpx;
  438. padding-right: 8rpx;
  439. padding-bottom: 24rpx;
  440. padding-left: 8rpx;
  441. border-bottom: 1px solid #EEEEEE;
  442. cursor: pointer;
  443. &:last-child {
  444. border-bottom: none;
  445. }
  446. }
  447. .course-number {
  448. width: 80rpx;
  449. font-family: PingFang SC;
  450. // font-weight: 400;
  451. font-size: 36rpx;
  452. color: #999;
  453. &.highlight {
  454. color: $primary-color;
  455. }
  456. // margin-right: 24rpx;
  457. }
  458. .course-content {
  459. flex: 1;
  460. }
  461. .course-english {
  462. font-family: PingFang SC;
  463. font-weight: 600;
  464. font-size: 36rpx;
  465. line-height: 44rpx;
  466. color: #252545;
  467. margin-bottom: 8rpx;
  468. &.highlight {
  469. color: $primary-color;
  470. }
  471. }
  472. .course-chinese {
  473. font-size: 28rpx;
  474. line-height: 48rpx;
  475. color: #3B3D3D;
  476. &.highlight {
  477. color: $primary-color;
  478. }
  479. }
  480. }
  481. /* 简介部分 */
  482. .intro-section {
  483. background: #F8F8F8;
  484. border-radius: 32rpx;
  485. padding: 32rpx;
  486. }
  487. .intro-title {
  488. font-size: 32rpx;
  489. font-weight: 600;
  490. color: #3B3D3D;
  491. margin-bottom: 24rpx;
  492. }
  493. .intro-content {
  494. font-size: 28rpx;
  495. line-height: 48rpx;
  496. color: #4F4F4F;
  497. }
  498. /* 作者部分 */
  499. .author-section {
  500. background: #F8F8F8;
  501. border-radius: 32rpx;
  502. padding: 32rpx;
  503. .author-title {
  504. font-size: 32rpx;
  505. font-weight: 600;
  506. color: #3B3D3D;
  507. margin-bottom: 24rpx;
  508. }
  509. .author-info {
  510. display: flex;
  511. gap: 24rpx;
  512. align-items: flex-start;
  513. flex-direction: column;
  514. .author-avatar {
  515. display: flex;
  516. align-items: center;
  517. gap: 16rpx;
  518. image {
  519. width: 80rpx;
  520. height: 80rpx;
  521. border-radius: 50%;
  522. overflow: hidden;
  523. flex-shrink: 0;
  524. }
  525. .author-name {
  526. font-size: 36rpx;
  527. font-weight: 600;
  528. color: #252545;
  529. margin-bottom: 12rpx;
  530. }
  531. .author-subtitle {
  532. font-size: 28rpx;
  533. color: #3B3D3D;
  534. // margin-bottom: 16rpx;
  535. }
  536. }
  537. .author-details {
  538. flex: 1;
  539. .author-description {
  540. font-size: 28rpx;
  541. line-height: 48rpx;
  542. color: #4F4F4F;
  543. }
  544. }
  545. }
  546. }
  547. /* 底部固定操作栏 */
  548. .bottom-action-bar {
  549. position: fixed;
  550. bottom: 0;
  551. left: 0;
  552. right: 0;
  553. background: #fff;
  554. padding: 24rpx 32rpx 0;
  555. box-shadow: 0rpx -2rpx 0rpx 0rpx #0000001A;
  556. z-index: 10000;
  557. .bottom-action-container{
  558. display: flex;
  559. align-items: center;
  560. gap: 20rpx;
  561. .action-button {
  562. display: flex;
  563. flex-direction: column;
  564. align-items: center;
  565. justify-content: center;
  566. padding: 16rpx 0rpx;
  567. border-radius: 16rpx;
  568. min-width: 120rpx;
  569. gap: 8rpx;
  570. .button-icon {
  571. width: 44rpx;
  572. height: 44rpx;
  573. }
  574. text {
  575. font-size: 24rpx;
  576. color: #999999;
  577. }
  578. }
  579. }
  580. }
  581. </style>