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

506 lines
11 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. <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. <view
  43. v-for="(course, index) in courseList.records"
  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">全部课程 · {{ 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. <view class="intro-content">
  64. {{ bookInfo.booksIntro }}
  65. </view>
  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">
  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. </view>
  109. </template>
  110. <script>
  111. export default {
  112. data() {
  113. return {
  114. classMap: {
  115. '朵蕾会员': 'book-level-1',
  116. '萌芽会员': 'book-level-2',
  117. '盛放会员': 'book-level-3',
  118. },
  119. bookInfo: {
  120. },
  121. id: '',
  122. courseList: [
  123. ]
  124. }
  125. },
  126. methods: {
  127. goBack() {
  128. uni.navigateBack()
  129. },
  130. // 加入课程
  131. async joinCourse() {
  132. const joinRes = await this.$api.book.addStand({
  133. id: this.id
  134. })
  135. if (joinRes.code === 200){
  136. uni.showToast({
  137. title: '加入成功',
  138. icon: 'success',
  139. duration: 2000
  140. })
  141. }
  142. },
  143. // 开始学习
  144. startLearning(id) {
  145. // 默认学第一堂课
  146. uni.navigateTo({
  147. url: '/subPages/home/book?courseId=' + id + '&bookId=' + this.id
  148. })
  149. },
  150. // 获取书籍详情
  151. async getDetail() {
  152. const detailRes = await this.$api.book.detail({
  153. id: this.id
  154. })
  155. if (detailRes.code === 200){
  156. this.bookInfo = detailRes.result
  157. }
  158. },
  159. // 获取书籍的课程
  160. async getCourse() {
  161. const courseRes = await this.$api.book.course({
  162. id: this.id,
  163. pageNo: 1,
  164. pageSize: 5
  165. })
  166. if (courseRes.code === 200){
  167. this.courseList = courseRes.result
  168. }
  169. },
  170. },
  171. onLoad(options) {
  172. if (options.id){
  173. this.id = options.id
  174. Promise.all([
  175. this.getDetail(),
  176. this.getCourse()
  177. ])
  178. }
  179. }
  180. }
  181. </script>
  182. <style scoped lang="scss">
  183. .directory-container {
  184. min-height: 100vh;
  185. background-color: #264C8F;
  186. }
  187. .book-container{
  188. position: sticky;
  189. left: 0;
  190. right: 0;
  191. top: 0;
  192. padding: 30rpx;
  193. }
  194. .book-info {
  195. display: flex;
  196. align-items: start;
  197. gap: 32rpx;
  198. .book-cover {
  199. width: 208rpx;
  200. height: 292rpx;
  201. border-radius: 16rpx;
  202. }
  203. .book-details{
  204. color: white;
  205. display: flex;
  206. flex-direction: column;
  207. gap: 16rpx;
  208. .book-title{
  209. font-weight: 500;
  210. font-size: 40rpx;
  211. }
  212. .book-subtitle{
  213. font-weight: 500;
  214. font-size: 30rpx;
  215. }
  216. .book-author{
  217. font-size: 24rpx;
  218. }
  219. .book-level{
  220. font-size: 24rpx;
  221. width: 124rpx;
  222. height: 38rpx;
  223. border-radius: 8rpx;
  224. text-align: center;
  225. line-height: 38rpx;
  226. color: #080D21;
  227. }
  228. .book-level-1{
  229. background: #E9F1FF;
  230. border: 2rpx solid #C4DAFF
  231. }
  232. .book-level-2{
  233. background: #FFE9E9;
  234. border: 2rpx solid #FFDBC4
  235. }
  236. .book-level-3{
  237. background: #FFF4E9;
  238. border: 2rpx solid #FFE2C4
  239. }
  240. }
  241. }
  242. .book-knowledge{
  243. box-shadow: 0px 1px 5px 0px #103577;
  244. background: #234684;
  245. color: #fff;
  246. margin-top: 32rpx;
  247. border: 2rpx solid #FFFFFF3B;
  248. border-radius: 32rpx;
  249. padding-top: 32rpx;
  250. padding-right: 40rpx;
  251. padding-bottom: 32rpx;
  252. padding-left: 40rpx;
  253. gap: 24rpx;
  254. display: flex;
  255. flex-direction: column;
  256. gap: 22rpx;
  257. .book-knowledge-title{
  258. font-size: 32rpx;
  259. font-weight: 600;
  260. display: flex;
  261. justify-content: space-between;
  262. .book-knowledge-vocabulary{
  263. font-size: 40rpx;
  264. color: #06DADC;
  265. }
  266. }
  267. .border {
  268. width: 100%;
  269. border: 2rpx solid;
  270. 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%);
  271. border-image-slice: 1;
  272. }
  273. .book-knowledge-detail-title{
  274. font-size: 32rpx;
  275. font-weight: 600;
  276. margin-bottom: 16rpx;
  277. }
  278. }
  279. /* 课程和简介容器 */
  280. .content-container {
  281. padding: 40rpx 32rpx 240rpx;
  282. border-radius: 40rpx 40rpx 0 0;
  283. overflow: hidden;
  284. background: #fff;
  285. display: flex;
  286. gap: 24rpx;
  287. flex-direction: column;
  288. position: relative;
  289. z-index: 100;
  290. }
  291. /* 课程部分 */
  292. .course-section {
  293. background: #F8F8F8;
  294. border-radius: 32rpx;
  295. border-radius: 32rpx;
  296. padding-top: 36rpx;
  297. padding-right: 32rpx;
  298. padding-bottom: 36rpx;
  299. padding-left: 32rpx;
  300. gap: 36rpx;
  301. display: flex;
  302. flex-direction: column;
  303. }
  304. .course-title {
  305. font-size: 32rpx;
  306. font-weight: 600;
  307. color: #3B3D3D;
  308. }
  309. .course-list {
  310. // margin-bottom: 32rpx;
  311. display: flex;
  312. flex-direction: column;
  313. gap: 24rpx;
  314. }
  315. .course-item {
  316. display: flex;
  317. align-items: center;
  318. // background: red;
  319. border-bottom: 2rpx solid #EEEEEE;
  320. padding-bottom: 20rpx;
  321. gap: 36rpx;
  322. }
  323. .course-item:last-child {
  324. border-bottom: none;
  325. }
  326. .course-number {
  327. font-size: 36rpx;
  328. color: #999;
  329. }
  330. .course-content {
  331. flex: 1;
  332. }
  333. .course-name {
  334. font-size: 32rpx;
  335. font-weight: 600;
  336. color: #3B3D3D;
  337. margin-bottom: 8rpx;
  338. }
  339. .course-subtitle {
  340. font-size: 28rpx;
  341. color: #3B3D3D;
  342. }
  343. .course-footer {
  344. display: flex;
  345. align-items: center;
  346. // justify-content: space-between;
  347. }
  348. .course-total {
  349. font-size: 24rpx;
  350. color: #999;
  351. }
  352. /* 简介部分 */
  353. .intro-section {
  354. background: #F8F8F8;
  355. border-radius: 32rpx;
  356. padding: 32rpx;
  357. }
  358. .intro-title {
  359. font-size: 32rpx;
  360. font-weight: 600;
  361. color: #3B3D3D;
  362. margin-bottom: 24rpx;
  363. }
  364. .intro-content {
  365. font-size: 28rpx;
  366. line-height: 48rpx;
  367. color: #4F4F4F;
  368. }
  369. /* 作者部分 */
  370. .author-section {
  371. background: #F8F8F8;
  372. border-radius: 32rpx;
  373. padding: 32rpx;
  374. .author-title {
  375. font-size: 32rpx;
  376. font-weight: 600;
  377. color: #3B3D3D;
  378. margin-bottom: 24rpx;
  379. }
  380. .author-info {
  381. display: flex;
  382. gap: 24rpx;
  383. align-items: flex-start;
  384. flex-direction: column;
  385. .author-avatar {
  386. display: flex;
  387. align-items: center;
  388. gap: 16rpx;
  389. image {
  390. width: 80rpx;
  391. height: 80rpx;
  392. border-radius: 50%;
  393. overflow: hidden;
  394. flex-shrink: 0;
  395. }
  396. .author-name {
  397. font-size: 36rpx;
  398. font-weight: 600;
  399. color: #252545;
  400. margin-bottom: 12rpx;
  401. }
  402. .author-subtitle {
  403. font-size: 28rpx;
  404. color: #3B3D3D;
  405. // margin-bottom: 16rpx;
  406. }
  407. }
  408. .author-details {
  409. flex: 1;
  410. .author-description {
  411. font-size: 28rpx;
  412. line-height: 48rpx;
  413. color: #4F4F4F;
  414. }
  415. }
  416. }
  417. }
  418. /* 底部固定操作栏 */
  419. .bottom-action-bar {
  420. position: fixed;
  421. bottom: 0;
  422. left: 0;
  423. right: 0;
  424. background: #fff;
  425. padding: 24rpx 32rpx 0;
  426. box-shadow: 0rpx -2rpx 0rpx 0rpx #0000001A;
  427. z-index: 999;
  428. .bottom-action-container{
  429. display: flex;
  430. align-items: center;
  431. gap: 20rpx;
  432. .action-button {
  433. display: flex;
  434. flex-direction: column;
  435. align-items: center;
  436. justify-content: center;
  437. padding: 16rpx 0rpx;
  438. border-radius: 16rpx;
  439. min-width: 120rpx;
  440. gap: 8rpx;
  441. .button-icon {
  442. width: 44rpx;
  443. height: 44rpx;
  444. }
  445. text {
  446. font-size: 24rpx;
  447. color: #999999;
  448. }
  449. }
  450. }
  451. }
  452. </style>