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

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