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

1626 lines
42 KiB

  1. <template>
  2. <view class="book-container">
  3. <!-- 自定义顶部导航栏 -->
  4. <uv-status-bar></uv-status-bar>
  5. <view class="custom-navbar" :class="{ 'navbar-hidden': !showNavbar }">
  6. <uv-status-bar></uv-status-bar>
  7. <view class="navbar-content">
  8. <view class="navbar-left" @click="goBack">
  9. <uv-icon name="arrow-left" size="20" color="#262626"></uv-icon>
  10. </view>
  11. <view class="navbar-title">{{ currentPageTitle }}</view>
  12. </view>
  13. </view>
  14. <!-- Swiper内容区域 -->
  15. <swiper
  16. class="content-swiper"
  17. :current="currentPage - 1"
  18. :disable-touch="isAudioLoading"
  19. @change="onSwiperChange"
  20. >
  21. <swiper-item
  22. v-for="(page, index) in bookPages"
  23. :key="index"
  24. class="swiper-item"
  25. >
  26. <view class="content-area" @click="toggleNavbar">
  27. <!-- 图片卡片页面 -->
  28. <view v-for="(item, index) in page" :key="index">
  29. <view v-if="item.type === 'card'" class="card-content">
  30. <view class="card-line">
  31. <image src="/static/划重点图标.png" class="card-line-image" mode="aspectFill" />
  32. <text class="card-line-text">划线重点</text>
  33. </view>
  34. <image class="card-image" :src="item.image" mode="aspectFill"></image>
  35. <text class="english-text" user-select @longpress="showWordMeaning(item.wordMeaning)">{{ item.englishText }}</text>
  36. <text class="chinese-text" user-select>{{ item.chineseText }}</text>
  37. </view>
  38. <!-- 文本页面 -->
  39. <view v-else-if="item.type === 'text'" class="text-content" >
  40. <view :class="{ 'text-highlight': isTextHighlighted(page, index) }">
  41. <text
  42. class="content-text"
  43. user-select
  44. >
  45. {{ item.content }}
  46. </text>
  47. </view>
  48. </view>
  49. <!-- 文本页面 -->
  50. <view v-else-if="item.type === 'image'" class="image-container">
  51. <image class="content-image" :src="item.imageUrl" mode="aspectFill"></image>
  52. </view>
  53. <!-- 视频页面 -->
  54. <view v-else-if="item.type === 'video'" class="video-content">
  55. <video :src="item.video" class="video-player" controls :poster="item.poster"></video>
  56. </view>
  57. <!-- 会员限制页面 -->
  58. <view v-else-if="item.type === 'member'" class="member-content">
  59. <text class="member-title">{{ item.title }}</text>
  60. <view class="member-button" @click="unlockBook">
  61. <text class="member-button-text">{{ item.buttonText }}</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </swiper-item>
  67. </swiper>
  68. <!-- 自定义底部控制栏 -->
  69. <view class="custom-tabbar" :class="{ 'tabbar-hidden': !showNavbar }">
  70. <!-- 音频控制栏 -->
  71. <!-- 获取音频按钮 -->
  72. <view v-if="!hasAudioData && !isAudioLoading && isTextPage" class="audio-get-button-container">
  73. <view class="get-audio-btn" @click="handleGetAudio">
  74. <uv-icon name="play-circle" size="24" color="#06DADC"></uv-icon>
  75. <text class="get-audio-text">获取第{{currentPage}}页音频</text>
  76. </view>
  77. </view>
  78. <!-- 音频加载状态 -->
  79. <view v-else-if="isAudioLoading && isTextPage" class="audio-loading-container">
  80. <uv-loading-icon mode="spinner" size="30" color="#06DADC"></uv-loading-icon>
  81. <text class="loading-text">正在加载第{{currentPage}}页音频...</text>
  82. </view>
  83. <!-- 正常音频控制栏 -->
  84. <view v-else-if="hasAudioData" class="audio-controls" :class="{ 'audio-hidden': !isTextPage }">
  85. <view class="audio-time">
  86. <text class="time-text">{{ formatTime(currentTime) }}</text>
  87. <view class="progress-container">
  88. <view class="progress-bar">
  89. <view class="progress-fill" :style="{ width: progressPercent + '%' }"></view>
  90. <view class="progress-thumb" :style="{ left: progressPercent + '%' }"></view>
  91. </view>
  92. </view>
  93. <text class="time-text">{{ formatTime(totalTime) }}</text>
  94. </view>
  95. <view class="audio-controls-row">
  96. <view class="control-btn" @click="toggleLoop">
  97. <uv-icon name="reload" size="20" :color="isLoop ? '#06DADC' : '#999'"></uv-icon>
  98. <text class="control-text">循环</text>
  99. </view>
  100. <view class="control-btn" @click="previousPage">
  101. <text class="control-text">上一页</text>
  102. </view>
  103. <view class="play-btn" @click="togglePlay">
  104. <uv-icon :name="isPlaying ? 'pause-circle-fill' : 'play-circle-fill'" size="40" color="#666"></uv-icon>
  105. </view>
  106. <view class="control-btn" @click="nextPage">
  107. <text class="control-text">下一页</text>
  108. </view>
  109. <view class="control-btn" @click="toggleSpeed">
  110. <text class="control-text">{{ playSpeed }}x</text>
  111. </view>
  112. </view>
  113. </view>
  114. <view style="background-color: #fff;position: relative;z-index: 100" >
  115. <view class="tabbar-content">
  116. <view class="tabbar-left">
  117. <view class="tab-button" @click="toggleCoursePopup">
  118. <image src="/static/课程图标.png" class="tab-icon" />
  119. <text class="tab-text">课程</text>
  120. </view>
  121. <view class="tab-button" @click="toggleSound">
  122. <image src="/static/音色切换图标.png" class="tab-icon" />
  123. <text class="tab-text">音色切换</text>
  124. </view>
  125. </view>
  126. <view class="tabbar-right">
  127. <view class="page-controls">
  128. <view class="page-numbers">
  129. <view
  130. v-for="(page, index) in bookPages"
  131. :key="index"
  132. class="page-number"
  133. :class="{ 'active': (index + 1) === currentPage }"
  134. @click="goToPage(index + 1)"
  135. >
  136. {{ index + 1 }}
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. <uv-safe-bottom></uv-safe-bottom>
  143. </view>
  144. </view>
  145. <!-- 课程选择弹出窗 -->
  146. <uv-popup
  147. mode="bottom"
  148. ref="coursePopup"
  149. round="32rpx"
  150. bg-color="#f8f8f8"
  151. >
  152. <view class="course-popup">
  153. <view class="popup-header">
  154. <view>
  155. <uv-icon name="arrow-down" color="black" size="20"></uv-icon>
  156. </view>
  157. <view class="popup-title">课程</view>
  158. <view class="popup-title" @click="toggleSort">
  159. 倒序
  160. </view>
  161. </view>
  162. <view class="course-list">
  163. <view
  164. v-for="(course, index) in displayCourseList"
  165. :key="course.id"
  166. class="course-item"
  167. :class="{ 'active': course.id === currentCourse }"
  168. @click="selectCourse(course.id)"
  169. >
  170. <view class="course-number " :class="{ 'highlight': course.id === currentCourse }">{{ String(course.index).padStart(2, '0') }}</view>
  171. <view class="course-content">
  172. <view class="course-english" :class="{ 'highlight': course.id === currentCourse }">{{ course.english }}</view>
  173. <view class="course-chinese" :class="{ 'highlight': course.id === currentCourse }">{{ course.chinese }}</view>
  174. </view>
  175. </view>
  176. </view>
  177. </view>
  178. </uv-popup>
  179. <!-- 释义弹出窗 -->
  180. <uv-popup
  181. mode="bottom"
  182. ref="meaningPopup"
  183. round="32rpx"
  184. bg-color="#FFFFFF"
  185. :overlay="true"
  186. >
  187. <view class="meaning-popup" v-if="currentWordMeaning">
  188. <view class="meaning-header">
  189. <view class="close-btn" @click="closeMeaningPopup">
  190. <text class="close-text">关闭</text>
  191. </view>
  192. <view class="meaning-title">释义</view>
  193. <view style="width: 80rpx;"></view>
  194. </view>
  195. <view class="meaning-content">
  196. <image class="meaning-image" src="/static/默认图片.png" mode="aspectFill"></image>
  197. <view class="word-info">
  198. <view class="word-main">
  199. <text class="word-text">{{ currentWordMeaning.word }}</text>
  200. </view>
  201. <view class="phonetic-container">
  202. <uv-icon name="volume-fill" size="16" color="#000"></uv-icon>
  203. <text class="phonetic-text">{{ currentWordMeaning.phonetic }}</text>
  204. </view>
  205. <view class="word-meaning">
  206. <text class="part-of-speech">{{ currentWordMeaning.partOfSpeech }}</text>
  207. <text class="meaning-text">{{ currentWordMeaning.meaning }}</text>
  208. </view>
  209. </view>
  210. <view class="knowledge-gain">
  211. <view class="knowledge-header">
  212. <image src="/static/知识收获图标.png" class="knowledge-icon" mode="aspectFill" />
  213. <text class="knowledge-title">知识收获</text>
  214. </view>
  215. <text class="knowledge-content">{{ currentWordMeaning.knowledgeGain }}</text>
  216. </view>
  217. </view>
  218. </view>
  219. </uv-popup>
  220. </view>
  221. </template>
  222. <script>
  223. export default {
  224. data() {
  225. return {
  226. voiceId: '',
  227. courseId: '',
  228. showNavbar: true,
  229. currentPage: 1,
  230. currentCourse: 1, // 当前课程索引
  231. currentWordMeaning: null, // 当前显示的单词释义
  232. isReversed: false, // 是否倒序显示
  233. // 音频控制相关数据
  234. isPlaying: false,
  235. currentTime: 0,
  236. totalTime: 0,
  237. isLoop: false,
  238. playSpeed: 1.0,
  239. speedOptions: [1.0, 1.25, 1.5, 2.0],
  240. // 音频数组管理
  241. currentPageAudios: [], // 当前页面的音频数组
  242. currentAudioIndex: 0, // 当前播放的音频索引
  243. audioContext: null, // 音频上下文
  244. currentAudio: null, // 当前音频实例
  245. // 音频缓存管理
  246. audioCache: {}, // 页面音频缓存 {pageIndex: {audios: [], totalDuration: 0}}
  247. // 音频加载状态
  248. isAudioLoading: false, // 音频是否正在加载
  249. hasAudioData: false, // 当前页面是否已有音频数据
  250. // 文本高亮相关
  251. currentHighlightIndex: -1, // 当前高亮的文本索引
  252. courseIdList: [],
  253. bookTitle: '',
  254. courseList: [
  255. ],
  256. // 二维数组 代表每个页面
  257. bookPages: [
  258. ],
  259. // 存储每个页面的标题
  260. pageTitles: [],
  261. }
  262. },
  263. computed: {
  264. displayCourseList() {
  265. return this.isReversed ? [...this.courseList].reverse() : this.courseList;
  266. },
  267. // 判断当前页面是否为文字类型
  268. isTextPage() {
  269. const currentPageData = this.bookPages[this.currentPage - 1];
  270. // currentPageData是一个数组 其中的一个元素的type是text就会返回true
  271. return currentPageData && currentPageData.some(item => item.type === 'text');
  272. },
  273. // 计算音频播放进度百分比
  274. progressPercent() {
  275. return this.totalTime > 0 ? (this.currentTime / this.totalTime) * 100 : 0;
  276. },
  277. // 动态页面标题
  278. currentPageTitle() {
  279. return this.pageTitles[this.currentPage - 1] || this.bookTitle;
  280. }
  281. },
  282. methods: {
  283. // 获取当前页面的音频内容
  284. async getCurrentPageAudio() {
  285. // 检查缓存中是否已有当前页面的音频数据
  286. const cacheKey = `${this.courseId}_${this.currentPage}`;
  287. if (this.audioCache[cacheKey]) {
  288. console.log('从缓存加载音频数据:', cacheKey);
  289. // 从缓存加载音频数据
  290. this.currentPageAudios = this.audioCache[cacheKey].audios;
  291. this.totalTime = this.audioCache[cacheKey].totalDuration;
  292. this.currentAudioIndex = 0;
  293. this.isPlaying = false;
  294. this.currentTime = 0;
  295. return;
  296. }
  297. // 开始加载状态
  298. this.isAudioLoading = true;
  299. // 清空当前页面音频数组
  300. this.currentPageAudios = [];
  301. this.currentAudioIndex = 0;
  302. this.isPlaying = false;
  303. this.currentTime = 0;
  304. this.totalTime = 0;
  305. // 对着当前页面的每一个[]元素进行切割 如果是文本text类型则进行音频请求
  306. const currentPageData = this.bookPages[this.currentPage - 1];
  307. if (currentPageData) {
  308. // 收集所有text类型的元素
  309. const textItems = currentPageData.filter(item => item.type === 'text');
  310. if (textItems.length > 0) {
  311. // 并行发送所有音频请求
  312. const audioPromises = textItems.map(async (item, index) => {
  313. try {
  314. // 进行音频请求 - 修正字段名:使用content而不是text
  315. const radioRes = await this.$api.music.textToVoice({
  316. text: item.content,
  317. voiceId: this.voiceId,
  318. });
  319. console.log(`音频请求响应 ${index + 1}:`, radioRes);
  320. if(radioRes.code === 200){
  321. // API返回的是Base64编码的WAV音频数据,在uniapp环境中需要特殊处理
  322. const base64Data = radioRes.result;
  323. // 在uniapp中,可以直接使用base64数据作为音频源
  324. const audioUrl = `data:audio/wav;base64,${base64Data}`;
  325. // 同时保存到原始数据中以保持兼容性
  326. item.audioUrl = audioUrl;
  327. console.log(`音频URL设置成功 ${index + 1}:`, audioUrl);
  328. return {
  329. url: audioUrl,
  330. text: item.content,
  331. duration: 0, // 音频时长,需要在加载后获取
  332. index: index // 保持原始顺序
  333. };
  334. } else {
  335. console.error(`音频请求失败 ${index + 1}:`, radioRes);
  336. return null;
  337. }
  338. } catch (error) {
  339. console.error(`音频请求异常 ${index + 1}:`, error);
  340. return null;
  341. }
  342. });
  343. // 等待所有音频请求完成
  344. const audioResults = await Promise.all(audioPromises);
  345. // 按原始顺序添加到音频数组中,过滤掉失败的请求
  346. this.currentPageAudios = audioResults
  347. .filter(result => result !== null)
  348. .sort((a, b) => a.index - b.index)
  349. .map(result => ({
  350. url: result.url,
  351. text: result.text,
  352. duration: result.duration
  353. }));
  354. console.log('所有音频请求完成,共获取', this.currentPageAudios.length, '个音频');
  355. }
  356. // 如果有音频,计算总时长
  357. if (this.currentPageAudios.length > 0) {
  358. await this.calculateTotalDuration();
  359. // 将音频数据保存到缓存中
  360. const cacheKey = `${this.courseId}_${this.currentPage}`;
  361. this.audioCache[cacheKey] = {
  362. audios: [...this.currentPageAudios], // 深拷贝音频数组
  363. totalDuration: this.totalTime
  364. };
  365. console.log('音频数据已缓存:', cacheKey, this.audioCache[cacheKey]);
  366. // 限制缓存大小
  367. this.limitCacheSize(10);
  368. }
  369. }
  370. // 结束加载状态
  371. this.isAudioLoading = false;
  372. // 设置音频数据状态
  373. this.hasAudioData = this.currentPageAudios.length > 0;
  374. },
  375. // 重置音频状态
  376. resetAudioState() {
  377. // 检查当前页面是否已有缓存的音频数据
  378. const pageKey = `${this.courseId}_${this.currentPage}`;
  379. const cachedAudio = this.audioCache[pageKey];
  380. if (cachedAudio && cachedAudio.audios && cachedAudio.audios.length > 0) {
  381. // 如果有缓存的音频数据,恢复音频状态
  382. this.currentPageAudios = cachedAudio.audios;
  383. this.totalTime = cachedAudio.totalDuration || 0;
  384. this.hasAudioData = true;
  385. } else {
  386. // 如果没有缓存的音频数据,重置为初始状态
  387. this.currentPageAudios = [];
  388. this.totalTime = 0;
  389. this.hasAudioData = false;
  390. }
  391. // 重置播放状态
  392. this.currentAudioIndex = 0;
  393. this.isPlaying = false;
  394. this.currentTime = 0;
  395. this.isAudioLoading = false;
  396. this.currentHighlightIndex = -1;
  397. },
  398. // 手动获取音频
  399. async handleGetAudio() {
  400. // 检查是否有音色ID
  401. if (!this.voiceId) {
  402. uni.showToast({
  403. title: '音色未加载,请稍后重试',
  404. icon: 'none'
  405. });
  406. return;
  407. }
  408. // 检查当前页面是否有文本内容
  409. if (!this.isTextPage) {
  410. uni.showToast({
  411. title: '当前页面没有文本内容',
  412. icon: 'none'
  413. });
  414. return;
  415. }
  416. // 检查是否正在加载
  417. if (this.isAudioLoading) {
  418. return;
  419. }
  420. // 调用获取音频方法
  421. await this.getCurrentPageAudio();
  422. },
  423. // 获取音色列表 拿第一个做默认的音色id
  424. async getVoiceList() {
  425. const voiceRes = await this.$api.music.list()
  426. if(voiceRes.code === 200){
  427. this.voiceId = voiceRes.result[0].id
  428. console.log('获取默认音色ID:', this.voiceId);
  429. }
  430. },
  431. toggleNavbar() {
  432. this.showNavbar = !this.showNavbar
  433. },
  434. goBack() {
  435. uni.navigateBack()
  436. },
  437. toggleCoursePopup() {
  438. if (this.$refs.coursePopup) {
  439. this.$refs.coursePopup.open()
  440. }
  441. // console.log('123123123');
  442. },
  443. toggleSort() {
  444. this.isReversed = !this.isReversed
  445. },
  446. selectCourse(courseId) {
  447. this.currentCourse = courseId
  448. if (this.$refs.coursePopup) {
  449. this.$refs.coursePopup.close()
  450. }
  451. // 这里可以添加切换课程的逻辑
  452. // console.log('选择课程:', courseId)
  453. this.getCourseList(courseId)
  454. },
  455. showWordMeaning(wordMeaning) {
  456. if (wordMeaning) {
  457. this.currentWordMeaning = wordMeaning
  458. if (this.$refs.meaningPopup) {
  459. this.$refs.meaningPopup.open()
  460. }
  461. }
  462. },
  463. closeMeaningPopup() {
  464. if (this.$refs.meaningPopup) {
  465. this.$refs.meaningPopup.close()
  466. }
  467. this.currentWordMeaning = null
  468. },
  469. // 计算音频总时长
  470. async calculateTotalDuration() {
  471. let totalDuration = 0;
  472. for (let i = 0; i < this.currentPageAudios.length; i++) {
  473. const audio = this.currentPageAudios[i];
  474. try {
  475. const duration = await this.getAudioDuration(audio.url);
  476. audio.duration = duration;
  477. totalDuration += duration;
  478. } catch (error) {
  479. console.error('获取音频时长失败:', error);
  480. // 如果无法获取时长,估算一个默认值(假设每100字符约5秒)
  481. const estimatedDuration = Math.max(5, audio.text.length / 20);
  482. audio.duration = estimatedDuration;
  483. totalDuration += estimatedDuration;
  484. }
  485. }
  486. this.totalTime = totalDuration;
  487. console.log('音频总时长:', totalDuration, '秒');
  488. },
  489. // 获取音频时长
  490. getAudioDuration(audioUrl) {
  491. return new Promise((resolve, reject) => {
  492. const audio = uni.createInnerAudioContext();
  493. audio.src = audioUrl;
  494. audio.onCanplay(() => {
  495. resolve(audio.duration || 5); // 如果无法获取时长,默认5秒
  496. audio.destroy();
  497. });
  498. audio.onError((error) => {
  499. console.error('音频加载失败:', error);
  500. reject(error);
  501. audio.destroy();
  502. });
  503. // 设置超时
  504. setTimeout(() => {
  505. reject(new Error('获取音频时长超时'));
  506. audio.destroy();
  507. }, 3000);
  508. });
  509. },
  510. // 音频控制方法
  511. togglePlay() {
  512. if (this.currentPageAudios.length === 0) {
  513. uni.showToast({
  514. title: '当前页面没有音频内容',
  515. icon: 'none'
  516. });
  517. return;
  518. }
  519. if (this.isPlaying) {
  520. this.pauseAudio();
  521. } else {
  522. this.playAudio();
  523. }
  524. },
  525. // 播放音频
  526. playAudio() {
  527. if (this.currentPageAudios.length === 0) return;
  528. // 如果没有当前音频实例或者需要切换音频
  529. if (!this.currentAudio || this.currentAudio.src !== this.currentPageAudios[this.currentAudioIndex].url) {
  530. this.createAudioInstance();
  531. }
  532. this.currentAudio.play();
  533. this.isPlaying = true;
  534. // 更新高亮状态
  535. this.updateHighlightIndex();
  536. },
  537. // 暂停音频
  538. pauseAudio() {
  539. if (this.currentAudio) {
  540. this.currentAudio.pause();
  541. }
  542. this.isPlaying = false;
  543. // 暂停时清除高亮
  544. this.currentHighlightIndex = -1;
  545. },
  546. // 创建音频实例
  547. createAudioInstance() {
  548. // 销毁之前的音频实例
  549. if (this.currentAudio) {
  550. this.currentAudio.destroy();
  551. }
  552. const audio = uni.createInnerAudioContext();
  553. audio.src = this.currentPageAudios[this.currentAudioIndex].url;
  554. audio.playbackRate = this.playSpeed;
  555. // 音频事件监听
  556. audio.onPlay(() => {
  557. console.log('音频开始播放');
  558. this.isPlaying = true;
  559. });
  560. audio.onPause(() => {
  561. console.log('音频暂停');
  562. this.isPlaying = false;
  563. });
  564. audio.onTimeUpdate(() => {
  565. this.updateCurrentTime();
  566. });
  567. audio.onEnded(() => {
  568. console.log('当前音频播放结束');
  569. this.onAudioEnded();
  570. });
  571. audio.onError((error) => {
  572. console.error('音频播放错误:', error);
  573. this.isPlaying = false;
  574. uni.showToast({
  575. title: '音频播放失败',
  576. icon: 'none'
  577. });
  578. });
  579. this.currentAudio = audio;
  580. },
  581. // 更新当前播放时间
  582. updateCurrentTime() {
  583. if (!this.currentAudio) return;
  584. let totalTime = 0;
  585. // 计算之前音频的总时长
  586. for (let i = 0; i < this.currentAudioIndex; i++) {
  587. totalTime += this.currentPageAudios[i].duration;
  588. }
  589. // 加上当前音频的播放时间
  590. totalTime += this.currentAudio.currentTime;
  591. this.currentTime = totalTime;
  592. // 更新当前高亮的文本索引
  593. this.updateHighlightIndex();
  594. },
  595. // 更新高亮文本索引
  596. updateHighlightIndex() {
  597. if (!this.isPlaying || this.currentPageAudios.length === 0) {
  598. this.currentHighlightIndex = -1;
  599. return;
  600. }
  601. // 根据当前播放的音频索引设置高亮
  602. this.currentHighlightIndex = this.currentAudioIndex;
  603. console.log('更新高亮索引:', this.currentHighlightIndex, '当前音频索引:', this.currentAudioIndex);
  604. },
  605. // 判断当前文本是否应该高亮
  606. isTextHighlighted(page, index) {
  607. // 只有当前页面且是文本类型才可能高亮
  608. if (page !== this.bookPages[this.currentPage - 1]) return false;
  609. // 计算当前页面中text类型元素的索引
  610. let textIndex = 0;
  611. for (let i = 0; i <= index; i++) {
  612. if (page[i].type === 'text') {
  613. if (i === index) {
  614. const shouldHighlight = textIndex === this.currentHighlightIndex;
  615. if (shouldHighlight) {
  616. console.log('高亮文本:', textIndex, '当前高亮索引:', this.currentHighlightIndex);
  617. }
  618. return shouldHighlight;
  619. }
  620. textIndex++;
  621. }
  622. }
  623. return false;
  624. },
  625. // 音频播放结束处理
  626. onAudioEnded() {
  627. if (this.currentAudioIndex < this.currentPageAudios.length - 1) {
  628. // 播放下一个音频
  629. this.currentAudioIndex++;
  630. this.playAudio();
  631. } else {
  632. // 所有音频播放完毕
  633. if (this.isLoop) {
  634. // 循环播放
  635. this.currentAudioIndex = 0;
  636. this.playAudio();
  637. } else {
  638. // 停止播放
  639. this.isPlaying = false;
  640. this.currentTime = this.totalTime;
  641. this.currentHighlightIndex = -1;
  642. }
  643. }
  644. },
  645. toggleLoop() {
  646. this.isLoop = !this.isLoop;
  647. },
  648. toggleSpeed() {
  649. const currentIndex = this.speedOptions.indexOf(this.playSpeed);
  650. const nextIndex = (currentIndex + 1) % this.speedOptions.length;
  651. this.playSpeed = this.speedOptions[nextIndex];
  652. // 如果当前有音频在播放,更新播放速度
  653. if (this.currentAudio) {
  654. this.currentAudio.playbackRate = this.playSpeed;
  655. }
  656. },
  657. // 上一个音频
  658. previousAudio() {
  659. // 如果正在加载音频,禁止切换
  660. if (this.isAudioLoading) {
  661. return;
  662. }
  663. if (this.currentPageAudios.length === 0) return;
  664. if (this.currentAudioIndex > 0) {
  665. this.currentAudioIndex--;
  666. if (this.isPlaying) {
  667. this.playAudio();
  668. }
  669. }
  670. },
  671. // 下一个音频
  672. nextAudio() {
  673. // 如果正在加载音频,禁止切换
  674. if (this.isAudioLoading) {
  675. return;
  676. }
  677. if (this.currentPageAudios.length === 0) return;
  678. if (this.currentAudioIndex < this.currentPageAudios.length - 1) {
  679. this.currentAudioIndex++;
  680. if (this.isPlaying) {
  681. this.playAudio();
  682. }
  683. }
  684. },
  685. async previousPage() {
  686. // 如果正在加载音频,禁止翻页
  687. if (this.isAudioLoading) {
  688. return;
  689. }
  690. if (this.currentPage > 1) {
  691. // 停止当前音频播放
  692. this.pauseAudio();
  693. this.currentPage--;
  694. // 获取对应页面的数据(如果还没有获取过)
  695. if (this.courseIdList[this.currentPage - 1] && this.bookPages[this.currentPage - 1].length === 0) {
  696. await this.getBookPages(this.courseIdList[this.currentPage - 1]);
  697. }
  698. // 清空当前音频状态
  699. this.resetAudioState();
  700. }
  701. },
  702. async nextPage() {
  703. // 如果正在加载音频,禁止翻页
  704. if (this.isAudioLoading) {
  705. return;
  706. }
  707. if (this.currentPage < this.bookPages.length) {
  708. // 停止当前音频播放
  709. this.pauseAudio();
  710. this.currentPage++;
  711. // 获取对应页面的数据(如果还没有获取过)
  712. if (this.courseIdList[this.currentPage - 1] && this.bookPages[this.currentPage - 1].length === 0) {
  713. await this.getBookPages(this.courseIdList[this.currentPage - 1]);
  714. }
  715. // 清空当前音频状态
  716. this.resetAudioState();
  717. }
  718. },
  719. formatTime(seconds) {
  720. const mins = Math.floor(seconds / 60);
  721. const secs = Math.floor(seconds % 60);
  722. return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
  723. },
  724. toggleSound() {
  725. console.log('音色切换')
  726. uni.navigateTo({
  727. url: '/subPages/home/music'
  728. })
  729. },
  730. unlockBook() {
  731. console.log('解锁全书')
  732. // 这里可以跳转到会员页面或者调用解锁接口
  733. uni.navigateTo({
  734. url: '/pages/index/member'
  735. })
  736. },
  737. async goToPage(page) {
  738. // 如果正在加载音频,禁止翻页
  739. if (this.isAudioLoading) {
  740. return;
  741. }
  742. // 停止当前音频播放
  743. this.pauseAudio();
  744. this.currentPage = page
  745. console.log('跳转到页面:', page)
  746. // 获取对应页面的数据(如果还没有获取过)
  747. if (this.courseIdList[this.currentPage - 1] && this.bookPages[this.currentPage - 1].length === 0) {
  748. await this.getBookPages(this.courseIdList[this.currentPage - 1]);
  749. }
  750. // 清空当前音频状态
  751. this.resetAudioState();
  752. },
  753. async onSwiperChange(e) {
  754. // 如果正在加载音频,禁止翻页
  755. if (this.isAudioLoading) {
  756. return;
  757. }
  758. // 停止当前音频播放
  759. this.pauseAudio();
  760. this.currentPage = e.detail.current + 1
  761. // 获取对应页面的数据(如果还没有获取过)
  762. if (this.courseIdList[this.currentPage - 1] && this.bookPages[this.currentPage - 1].length === 0) {
  763. await this.getBookPages(this.courseIdList[this.currentPage - 1]);
  764. }
  765. // 清空当前音频状态
  766. this.resetAudioState();
  767. },
  768. async getCourseList(id) {
  769. const res = await this.$api.book.coursePage({
  770. id: id
  771. })
  772. if (res.code === 200) {
  773. this.courseIdList = res.result.map(item => item.id)
  774. // 初始化二维数组 换一种方式
  775. this.bookPages = this.courseIdList.map(() => [])
  776. // 初始化标题数组
  777. this.pageTitles = this.courseIdList.map(() => '')
  778. // 重置音频状态
  779. this.resetAudioState()
  780. // 初始化第一页
  781. if (this.courseIdList.length > 0) {
  782. await this.getBookPages(this.courseIdList[0])
  783. }
  784. }
  785. },
  786. async getBookPages(id) {
  787. const res = await this.$api.book.coursesPageDetail({
  788. id: id
  789. })
  790. if (res.code === 200) {
  791. // 使用$set确保响应式更新
  792. // 确保当前页面存在
  793. if (this.currentPage - 1 < this.bookPages.length) {
  794. this.$set(this.bookPages, this.currentPage - 1, JSON.parse(res.result.content))
  795. // 保存页面标题
  796. this.$set(this.pageTitles, this.currentPage - 1, res.result.title || '')
  797. }
  798. }
  799. },
  800. // 获取课程列表
  801. async getCoursePageList (bookId) {
  802. const res = await this.$api.book.course({
  803. id: bookId
  804. })
  805. if (res.code === 200) {
  806. this.courseList = res.result.records
  807. // 打上序列号
  808. this.courseList = this.courseList.map((item, index) => ({
  809. ...item,
  810. index,
  811. }))
  812. }
  813. },
  814. // 清理音频缓存
  815. clearAudioCache() {
  816. this.audioCache = {};
  817. console.log('音频缓存已清理');
  818. },
  819. // 限制缓存大小,保留最近访问的页面
  820. limitCacheSize(maxSize = 10) {
  821. const cacheKeys = Object.keys(this.audioCache);
  822. if (cacheKeys.length > maxSize) {
  823. // 删除最旧的缓存项
  824. const keysToDelete = cacheKeys.slice(0, cacheKeys.length - maxSize);
  825. keysToDelete.forEach(key => {
  826. delete this.audioCache[key];
  827. });
  828. console.log('缓存大小已限制,删除了', keysToDelete.length, '个缓存项');
  829. }
  830. }
  831. },
  832. async onLoad(args) {
  833. this.courseId = args.courseId
  834. // 重置音频状态
  835. this.resetAudioState()
  836. // 先获取点进来的课程的页面列表
  837. await Promise.all([this.getCourseList(this.courseId), this.getCoursePageList(args.bookId)])
  838. await this.getVoiceList()
  839. },
  840. // 页面卸载时清理音频资源
  841. onUnload() {
  842. if (this.currentAudio) {
  843. this.currentAudio.destroy();
  844. this.currentAudio = null;
  845. }
  846. this.isPlaying = false;
  847. // 清理音频缓存
  848. this.clearAudioCache();
  849. },
  850. // 页面隐藏时暂停音频
  851. onHide() {
  852. this.pauseAudio();
  853. }
  854. }
  855. </script>
  856. <style lang="scss" scoped>
  857. .book-container {
  858. width: 100%;
  859. height: 100vh;
  860. background-color: #F8F8F8;
  861. position: relative;
  862. overflow: hidden;
  863. }
  864. .custom-navbar {
  865. position: fixed;
  866. top: 0;
  867. left: 0;
  868. right: 0;
  869. background-color: #F8F8F8;
  870. z-index: 1000;
  871. transition: transform 0.3s ease;
  872. &.navbar-hidden {
  873. transform: translateY(-100%);
  874. }
  875. }
  876. .navbar-content {
  877. display: flex;
  878. align-items: center;
  879. justify-content: space-between;
  880. padding: 20rpx 32rpx;
  881. // padding-top: calc(20rpx + var(--status-bar-height, 0));
  882. height: 60rpx;
  883. }
  884. .navbar-left,
  885. .navbar-right {
  886. width: 80rpx;
  887. display: flex;
  888. align-items: center;
  889. }
  890. .navbar-right {
  891. justify-content: flex-end;
  892. flex: 1;
  893. }
  894. .navbar-title {
  895. transform: translateX(-50rpx);
  896. flex: 1;
  897. text-align: center;
  898. font-family: PingFang SC;
  899. font-weight: 500;
  900. font-size: 32rpx;
  901. color: #262626;
  902. line-height: 48rpx;
  903. }
  904. .content-swiper {
  905. flex: 1;
  906. height: calc(100vh - 100rpx);
  907. // margin-top: 100rpx;
  908. margin-bottom: 100rpx;
  909. }
  910. .swiper-item {
  911. height: 100%;
  912. }
  913. .content-area {
  914. flex: 1;
  915. padding: 0 40rpx;
  916. padding-top: 100rpx;
  917. // background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  918. height: 100%;
  919. box-sizing: border-box;
  920. overflow-y: auto;
  921. }
  922. .card-content {
  923. background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  924. display: flex;
  925. flex-direction: column;
  926. gap: 32rpx;
  927. height: 1172rpx;
  928. margin-top: 20rpx;
  929. border-radius: 32rpx;
  930. // height: 100%;
  931. padding: 40rpx;
  932. // margin: 0
  933. border: 1px solid #FFFFFF;
  934. box-sizing: border-box;
  935. .card-line {
  936. display: flex;
  937. align-items: center;
  938. // margin-bottom: 20rpx;
  939. }
  940. .card-line-image {
  941. width: 48rpx;
  942. height: 48rpx;
  943. margin-right: 16rpx;
  944. }
  945. .card-line-text {
  946. font-family: PingFang SC;
  947. font-weight: 600;
  948. font-size: 30rpx;
  949. line-height: 48rpx;
  950. color: #3B3D3D;
  951. }
  952. .card-image {
  953. width: 590rpx;
  954. height: 268rpx;
  955. border-radius: 24rpx;
  956. // margin-bottom: 20rpx;
  957. }
  958. .english-text {
  959. display: block;
  960. font-family: PingFang SC;
  961. font-weight: 600;
  962. font-size: 32rpx;
  963. line-height: 48rpx;
  964. color: #3B3D3D;
  965. // margin-bottom: 16rpx;
  966. }
  967. .chinese-text {
  968. display: block;
  969. font-family: PingFang SC;
  970. font-weight: 400;
  971. font-size: 28rpx;
  972. line-height: 48rpx;
  973. color: #4F4F4F;
  974. }
  975. }
  976. /* 会员限制页面样式 */
  977. .member-content {
  978. display: flex;
  979. flex-direction: column;
  980. align-items: center;
  981. justify-content: center;
  982. height: 90%;
  983. background-color: #F8F8F8;
  984. padding: 40rpx;
  985. margin: -40rpx;
  986. box-sizing: border-box;
  987. }
  988. .member-title {
  989. font-family: PingFang SC;
  990. font-weight: 500;
  991. font-size: 40rpx;
  992. line-height: 1;
  993. color: #6f6f6f;
  994. text-align: center;
  995. margin-bottom: 48rpx;
  996. }
  997. .member-button {
  998. width: 670rpx;
  999. height: 72rpx;
  1000. background: #06DADC;
  1001. border-radius: 200rpx;
  1002. display: flex;
  1003. align-items: center;
  1004. justify-content: center;
  1005. }
  1006. .member-button-text {
  1007. font-family: PingFang SC;
  1008. font-weight: 400;
  1009. font-size: 30rpx;
  1010. color: #FFFFFF;
  1011. }
  1012. .video-content {
  1013. width: 100vw;
  1014. margin: 200rpx -40rpx 0;
  1015. height: 500rpx;
  1016. background-color: #FFFFFF;
  1017. // padding: 40rpx;
  1018. border-radius: 24rpx;
  1019. display: flex;
  1020. align-items: center;
  1021. justify-content: center;
  1022. .video-player{
  1023. width: 670rpx;
  1024. margin: 0 auto;
  1025. height: 376rpx;
  1026. }
  1027. }
  1028. .text-content {
  1029. width: 100vw;
  1030. background-color: #F6F6F6;
  1031. height: 100%;
  1032. padding: 40rpx;
  1033. margin: -40rpx;
  1034. box-sizing: border-box;
  1035. }
  1036. .content-text {
  1037. font-family: PingFang SC;
  1038. // font-weight: 400;
  1039. font-size: 28rpx;
  1040. color: #3B3D3D;
  1041. line-height: 48rpx;
  1042. letter-spacing: 0;
  1043. text-align: justify;
  1044. word-break: break-all;
  1045. transition: all 0.3s ease;
  1046. }
  1047. .text-highlight {
  1048. background-color: $primary-color;
  1049. // color: #fff;
  1050. // padding: 8rpx 16rpx;
  1051. // border-radius: 8rpx;
  1052. // box-shadow: 0 2rpx 8rpx rgba(6, 218, 220, 0.3);
  1053. }
  1054. .custom-tabbar {
  1055. position: fixed;
  1056. bottom: 0;
  1057. left: 0;
  1058. right: 0;
  1059. // background-color: #fff;
  1060. border-top: 1rpx solid #EEEEEE;
  1061. z-index: 1000;
  1062. transition: transform 0.3s ease;
  1063. &.tabbar-hidden {
  1064. transform: translateY(100%);
  1065. }
  1066. }
  1067. .tabbar-content {
  1068. display: flex;
  1069. align-items: center;
  1070. justify-content: space-between;
  1071. padding: 24rpx 62rpx;
  1072. // z-index: 100;
  1073. // position: relative;
  1074. // background-color: #fff;
  1075. // padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
  1076. height: 88rpx;
  1077. }
  1078. .tabbar-left {
  1079. display: flex;
  1080. align-items: center;
  1081. gap: 35rpx;
  1082. }
  1083. .tab-button {
  1084. display: flex;
  1085. align-items: center;
  1086. flex-direction: column;
  1087. gap: 8rpx;
  1088. }
  1089. .tab-icon {
  1090. width: 52rpx;
  1091. height: 52rpx;
  1092. }
  1093. .tab-text {
  1094. font-family: PingFang SC;
  1095. // font-weight: 400;
  1096. font-size: 22rpx;
  1097. color: #999;
  1098. line-height: 24rpx;
  1099. }
  1100. .tabbar-right {
  1101. flex: 1;
  1102. display: flex;
  1103. justify-content: flex-end;
  1104. }
  1105. .page-controls {
  1106. display: flex;
  1107. align-items: center;
  1108. }
  1109. .page-numbers {
  1110. display: flex;
  1111. align-items: center;
  1112. gap: 8rpx;
  1113. overflow-x: auto;
  1114. max-width: 400rpx;
  1115. &::-webkit-scrollbar {
  1116. display: none;
  1117. }
  1118. }
  1119. .page-number {
  1120. min-width: 84rpx;
  1121. height: 58rpx;
  1122. display: flex;
  1123. align-items: center;
  1124. justify-content: center;
  1125. border-radius: 100rpx;
  1126. font-family: PingFang SC;
  1127. // font-weight: 400;
  1128. font-size: 30rpx;
  1129. color: #3B3D3D;
  1130. background-color: transparent;
  1131. border: 1px solid #3B3D3D;
  1132. transition: all 0.3s ease;
  1133. &.active {
  1134. border: 1px solid $primary-color;
  1135. color: $primary-color;
  1136. }
  1137. }
  1138. /* 课程弹出窗样式 */
  1139. .course-popup {
  1140. padding: 0 32rpx;
  1141. max-height: 80vh;
  1142. }
  1143. .popup-header {
  1144. display: flex;
  1145. justify-content: space-between;
  1146. align-items: center;
  1147. padding: 20rpx 0;
  1148. border-bottom: 2rpx solid #EEEEEE
  1149. // margin-bottom: 40rpx;
  1150. }
  1151. .popup-title {
  1152. font-family: PingFang SC;
  1153. font-weight: 500;
  1154. font-size: 34rpx;
  1155. color: #181818;
  1156. }
  1157. .course-list {
  1158. max-height: 60vh;
  1159. overflow-y: auto;
  1160. }
  1161. .course-item {
  1162. display: flex;
  1163. align-items: center;
  1164. gap: 24rpx;
  1165. padding-top: 24rpx;
  1166. padding-right: 8rpx;
  1167. padding-bottom: 24rpx;
  1168. padding-left: 8rpx;
  1169. border-bottom: 1px solid #EEEEEE;
  1170. cursor: pointer;
  1171. &:last-child {
  1172. border-bottom: none;
  1173. }
  1174. }
  1175. .course-number {
  1176. width: 80rpx;
  1177. font-family: PingFang SC;
  1178. // font-weight: 400;
  1179. font-size: 36rpx;
  1180. color: #999;
  1181. &.highlight {
  1182. color: $primary-color;
  1183. }
  1184. // margin-right: 24rpx;
  1185. }
  1186. .course-content {
  1187. flex: 1;
  1188. }
  1189. .course-english {
  1190. font-family: PingFang SC;
  1191. font-weight: 600;
  1192. font-size: 36rpx;
  1193. line-height: 44rpx;
  1194. color: #252545;
  1195. margin-bottom: 8rpx;
  1196. &.highlight {
  1197. color: $primary-color;
  1198. }
  1199. }
  1200. .course-chinese {
  1201. font-size: 28rpx;
  1202. line-height: 48rpx;
  1203. color: #3B3D3D;
  1204. &.highlight {
  1205. color: $primary-color;
  1206. }
  1207. }
  1208. /* 释义弹窗样式 */
  1209. .meaning-popup {
  1210. // width: 670rpx;
  1211. background-color: #FFFFFF;
  1212. // border-radius: 32rpx;
  1213. overflow: hidden;
  1214. }
  1215. .meaning-header {
  1216. display: flex;
  1217. justify-content: space-between;
  1218. align-items: center;
  1219. padding: 32rpx;
  1220. border-bottom: 2rpx solid #EEEEEE;
  1221. }
  1222. .close-btn {
  1223. width: 80rpx;
  1224. }
  1225. .close-text {
  1226. font-family: PingFang SC;
  1227. font-size: 32rpx;
  1228. color: #8b8b8b;
  1229. }
  1230. .meaning-title {
  1231. font-family: PingFang SC;
  1232. font-weight: 500;
  1233. font-size: 34rpx;
  1234. color: #181818;
  1235. }
  1236. .meaning-content {
  1237. padding: 32rpx;
  1238. }
  1239. .meaning-image {
  1240. width: 670rpx;
  1241. height: 268rpx;
  1242. border-radius: 24rpx;
  1243. margin-bottom: 32rpx;
  1244. }
  1245. .word-info {
  1246. margin-bottom: 32rpx;
  1247. }
  1248. .word-main {
  1249. display: flex;
  1250. align-items: center;
  1251. gap: 16rpx;
  1252. margin-bottom: 8rpx;
  1253. }
  1254. .word-text {
  1255. font-family: PingFang SC;
  1256. font-weight: 500;
  1257. font-size: 40rpx;
  1258. color: #181818;
  1259. }
  1260. .phonetic-container{
  1261. display: flex;
  1262. gap: 24rpx;
  1263. .phonetic-text {
  1264. font-family: PingFang SC;
  1265. font-size: 28rpx;
  1266. color: #262626;
  1267. margin-bottom: 16rpx;
  1268. }
  1269. }
  1270. .word-meaning {
  1271. display: flex;
  1272. gap: 16rpx;
  1273. }
  1274. .part-of-speech {
  1275. font-family: PingFang SC;
  1276. font-size: 28rpx;
  1277. color: #262626;
  1278. }
  1279. .meaning-text {
  1280. font-family: PingFang SC;
  1281. font-size: 28rpx;
  1282. color: #181818;
  1283. flex: 1;
  1284. }
  1285. .knowledge-gain {
  1286. background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  1287. border-radius: 24rpx;
  1288. padding: 32rpx 40rpx;
  1289. }
  1290. .knowledge-header {
  1291. display: flex;
  1292. align-items: center;
  1293. gap: 16rpx;
  1294. margin-bottom: 20rpx;
  1295. }
  1296. .knowledge-icon {
  1297. width: 48rpx;
  1298. height: 48rpx;
  1299. }
  1300. .knowledge-title {
  1301. font-family: PingFang SC;
  1302. font-weight: 600;
  1303. font-size: 30rpx;
  1304. color: #3B3D3D;
  1305. }
  1306. .knowledge-content {
  1307. font-family: PingFang SC;
  1308. font-size: 28rpx;
  1309. color: #4f4f4f;
  1310. line-height: 48rpx;
  1311. }
  1312. /* 音频控制栏样式 */
  1313. .audio-controls {
  1314. background: #fff;
  1315. padding: 20rpx 40rpx;
  1316. border-bottom: 1rpx solid #eee;
  1317. transition: transform 0.3s ease;
  1318. position: relative;
  1319. z-index: 10;
  1320. &.audio-hidden {
  1321. transform: translateY(100%);
  1322. }
  1323. }
  1324. .audio-time {
  1325. display: flex;
  1326. align-items: center;
  1327. margin-bottom: 20rpx;
  1328. }
  1329. .time-text {
  1330. font-size: 28rpx;
  1331. color: #999;
  1332. min-width: 80rpx;
  1333. }
  1334. .progress-container {
  1335. flex: 1;
  1336. margin: 0 20rpx;
  1337. }
  1338. .progress-bar {
  1339. position: relative;
  1340. height: 6rpx;
  1341. background: #f0f0f0;
  1342. border-radius: 3rpx;
  1343. }
  1344. .progress-fill {
  1345. position: absolute;
  1346. left: 0;
  1347. top: 0;
  1348. height: 100%;
  1349. background: #06DADC;
  1350. border-radius: 3rpx;
  1351. transition: width 0.1s ease;
  1352. }
  1353. .progress-thumb {
  1354. position: absolute;
  1355. top: 50%;
  1356. width: 16rpx;
  1357. height: 16rpx;
  1358. background: #06DADC;
  1359. border-radius: 50%;
  1360. transform: translate(-50%, -50%);
  1361. transition: left 0.1s ease;
  1362. }
  1363. .audio-controls-row {
  1364. display: flex;
  1365. align-items: center;
  1366. justify-content: space-between;
  1367. }
  1368. .control-btn {
  1369. display: flex;
  1370. // flex-direction: column;
  1371. align-items: center;
  1372. padding: 10rpx;
  1373. gap: 8rpx;
  1374. }
  1375. .control-text {
  1376. font-size: 28rpx;
  1377. color: #4A4A4A;
  1378. // margin-top: 8rpx;
  1379. }
  1380. .play-btn {
  1381. display: flex;
  1382. align-items: center;
  1383. justify-content: center;
  1384. padding: 10rpx;
  1385. }
  1386. /* 音频加载状态样式 */
  1387. .audio-loading-container {
  1388. background: #fff;
  1389. padding: 40rpx;
  1390. border-bottom: 1rpx solid #eee;
  1391. display: flex;
  1392. flex-direction: column;
  1393. align-items: center;
  1394. justify-content: center;
  1395. gap: 20rpx;
  1396. position: relative;
  1397. z-index: 10;
  1398. }
  1399. .loading-text {
  1400. font-size: 28rpx;
  1401. color: #999;
  1402. }
  1403. /* 获取音频按钮样式 */
  1404. .audio-get-button-container {
  1405. background: rgba(255, 255, 255, 0.95);
  1406. backdrop-filter: blur(10px);
  1407. padding: 30rpx;
  1408. border-radius: 20rpx;
  1409. border: 2rpx solid #E5E5E5;
  1410. transition: all 0.3s ease;
  1411. position: relative;
  1412. z-index: 10;
  1413. }
  1414. .get-audio-btn {
  1415. display: flex;
  1416. align-items: center;
  1417. justify-content: center;
  1418. gap: 16rpx;
  1419. padding: 20rpx 40rpx;
  1420. background: linear-gradient(135deg, #06DADC 0%, #04B8BA 100%);
  1421. border-radius: 50rpx;
  1422. box-shadow: 0 8rpx 20rpx rgba(6, 218, 220, 0.3);
  1423. transition: all 0.3s ease;
  1424. }
  1425. .get-audio-btn:active {
  1426. transform: scale(0.95);
  1427. box-shadow: 0 4rpx 10rpx rgba(6, 218, 220, 0.2);
  1428. }
  1429. .get-audio-text {
  1430. font-size: 32rpx;
  1431. color: #FFFFFF;
  1432. font-weight: 500;
  1433. }
  1434. </style>