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

1633 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?voiceId=' + this.voiceId
  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. uni.$on('selectVoice', (voiceId) => {
  834. // console.log('收到音色选择:', voiceId);
  835. this.voiceId = voiceId
  836. })
  837. this.courseId = args.courseId
  838. // 重置音频状态
  839. this.resetAudioState()
  840. // 先获取点进来的课程的页面列表
  841. await Promise.all([this.getCourseList(this.courseId), this.getCoursePageList(args.bookId)])
  842. await this.getVoiceList()
  843. },
  844. // 页面卸载时清理音频资源
  845. onUnload() {
  846. uni.$off('selectVoice')
  847. if (this.currentAudio) {
  848. this.currentAudio.destroy();
  849. this.currentAudio = null;
  850. }
  851. this.isPlaying = false;
  852. // 清理音频缓存
  853. this.clearAudioCache();
  854. },
  855. // 页面隐藏时暂停音频
  856. onHide() {
  857. this.pauseAudio();
  858. }
  859. }
  860. </script>
  861. <style lang="scss" scoped>
  862. .book-container {
  863. width: 100%;
  864. height: 100vh;
  865. background-color: #F8F8F8;
  866. position: relative;
  867. overflow: hidden;
  868. }
  869. .custom-navbar {
  870. position: fixed;
  871. top: 0;
  872. left: 0;
  873. right: 0;
  874. background-color: #F8F8F8;
  875. z-index: 1000;
  876. transition: transform 0.3s ease;
  877. &.navbar-hidden {
  878. transform: translateY(-100%);
  879. }
  880. }
  881. .navbar-content {
  882. display: flex;
  883. align-items: center;
  884. justify-content: space-between;
  885. padding: 20rpx 32rpx;
  886. // padding-top: calc(20rpx + var(--status-bar-height, 0));
  887. height: 60rpx;
  888. }
  889. .navbar-left,
  890. .navbar-right {
  891. width: 80rpx;
  892. display: flex;
  893. align-items: center;
  894. }
  895. .navbar-right {
  896. justify-content: flex-end;
  897. flex: 1;
  898. }
  899. .navbar-title {
  900. transform: translateX(-50rpx);
  901. flex: 1;
  902. text-align: center;
  903. font-family: PingFang SC;
  904. font-weight: 500;
  905. font-size: 32rpx;
  906. color: #262626;
  907. line-height: 48rpx;
  908. }
  909. .content-swiper {
  910. flex: 1;
  911. height: calc(100vh - 100rpx);
  912. // margin-top: 100rpx;
  913. margin-bottom: 100rpx;
  914. }
  915. .swiper-item {
  916. height: 100%;
  917. }
  918. .content-area {
  919. flex: 1;
  920. padding: 0 40rpx;
  921. padding-top: 100rpx;
  922. // background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  923. height: 100%;
  924. box-sizing: border-box;
  925. overflow-y: auto;
  926. }
  927. .card-content {
  928. background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  929. display: flex;
  930. flex-direction: column;
  931. gap: 32rpx;
  932. height: 1172rpx;
  933. margin-top: 20rpx;
  934. border-radius: 32rpx;
  935. // height: 100%;
  936. padding: 40rpx;
  937. // margin: 0
  938. border: 1px solid #FFFFFF;
  939. box-sizing: border-box;
  940. .card-line {
  941. display: flex;
  942. align-items: center;
  943. // margin-bottom: 20rpx;
  944. }
  945. .card-line-image {
  946. width: 48rpx;
  947. height: 48rpx;
  948. margin-right: 16rpx;
  949. }
  950. .card-line-text {
  951. font-family: PingFang SC;
  952. font-weight: 600;
  953. font-size: 30rpx;
  954. line-height: 48rpx;
  955. color: #3B3D3D;
  956. }
  957. .card-image {
  958. width: 590rpx;
  959. height: 268rpx;
  960. border-radius: 24rpx;
  961. // margin-bottom: 20rpx;
  962. }
  963. .english-text {
  964. display: block;
  965. font-family: PingFang SC;
  966. font-weight: 600;
  967. font-size: 32rpx;
  968. line-height: 48rpx;
  969. color: #3B3D3D;
  970. // margin-bottom: 16rpx;
  971. }
  972. .chinese-text {
  973. display: block;
  974. font-family: PingFang SC;
  975. font-weight: 400;
  976. font-size: 28rpx;
  977. line-height: 48rpx;
  978. color: #4F4F4F;
  979. }
  980. }
  981. /* 会员限制页面样式 */
  982. .member-content {
  983. display: flex;
  984. flex-direction: column;
  985. align-items: center;
  986. justify-content: center;
  987. height: 90%;
  988. background-color: #F8F8F8;
  989. padding: 40rpx;
  990. margin: -40rpx;
  991. box-sizing: border-box;
  992. }
  993. .member-title {
  994. font-family: PingFang SC;
  995. font-weight: 500;
  996. font-size: 40rpx;
  997. line-height: 1;
  998. color: #6f6f6f;
  999. text-align: center;
  1000. margin-bottom: 48rpx;
  1001. }
  1002. .member-button {
  1003. width: 670rpx;
  1004. height: 72rpx;
  1005. background: #06DADC;
  1006. border-radius: 200rpx;
  1007. display: flex;
  1008. align-items: center;
  1009. justify-content: center;
  1010. }
  1011. .member-button-text {
  1012. font-family: PingFang SC;
  1013. font-weight: 400;
  1014. font-size: 30rpx;
  1015. color: #FFFFFF;
  1016. }
  1017. .video-content {
  1018. width: 100vw;
  1019. margin: 200rpx -40rpx 0;
  1020. height: 500rpx;
  1021. background-color: #FFFFFF;
  1022. // padding: 40rpx;
  1023. border-radius: 24rpx;
  1024. display: flex;
  1025. align-items: center;
  1026. justify-content: center;
  1027. .video-player{
  1028. width: 670rpx;
  1029. margin: 0 auto;
  1030. height: 376rpx;
  1031. }
  1032. }
  1033. .text-content {
  1034. width: 100vw;
  1035. background-color: #F6F6F6;
  1036. height: 100%;
  1037. padding: 40rpx;
  1038. margin: -40rpx;
  1039. box-sizing: border-box;
  1040. }
  1041. .content-text {
  1042. font-family: PingFang SC;
  1043. // font-weight: 400;
  1044. font-size: 28rpx;
  1045. color: #3B3D3D;
  1046. line-height: 48rpx;
  1047. letter-spacing: 0;
  1048. text-align: justify;
  1049. word-break: break-all;
  1050. transition: all 0.3s ease;
  1051. }
  1052. .text-highlight {
  1053. background-color: $primary-color;
  1054. // color: #fff;
  1055. // padding: 8rpx 16rpx;
  1056. // border-radius: 8rpx;
  1057. // box-shadow: 0 2rpx 8rpx rgba(6, 218, 220, 0.3);
  1058. }
  1059. .custom-tabbar {
  1060. position: fixed;
  1061. bottom: 0;
  1062. left: 0;
  1063. right: 0;
  1064. // background-color: #fff;
  1065. border-top: 1rpx solid #EEEEEE;
  1066. z-index: 1000;
  1067. transition: transform 0.3s ease;
  1068. &.tabbar-hidden {
  1069. transform: translateY(100%);
  1070. }
  1071. }
  1072. .tabbar-content {
  1073. display: flex;
  1074. align-items: center;
  1075. justify-content: space-between;
  1076. padding: 24rpx 62rpx;
  1077. // z-index: 100;
  1078. // position: relative;
  1079. // background-color: #fff;
  1080. // padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
  1081. height: 88rpx;
  1082. }
  1083. .tabbar-left {
  1084. display: flex;
  1085. align-items: center;
  1086. gap: 35rpx;
  1087. }
  1088. .tab-button {
  1089. display: flex;
  1090. align-items: center;
  1091. flex-direction: column;
  1092. gap: 8rpx;
  1093. }
  1094. .tab-icon {
  1095. width: 52rpx;
  1096. height: 52rpx;
  1097. }
  1098. .tab-text {
  1099. font-family: PingFang SC;
  1100. // font-weight: 400;
  1101. font-size: 22rpx;
  1102. color: #999;
  1103. line-height: 24rpx;
  1104. }
  1105. .tabbar-right {
  1106. flex: 1;
  1107. display: flex;
  1108. justify-content: flex-end;
  1109. }
  1110. .page-controls {
  1111. display: flex;
  1112. align-items: center;
  1113. }
  1114. .page-numbers {
  1115. display: flex;
  1116. align-items: center;
  1117. gap: 8rpx;
  1118. overflow-x: auto;
  1119. max-width: 400rpx;
  1120. &::-webkit-scrollbar {
  1121. display: none;
  1122. }
  1123. }
  1124. .page-number {
  1125. min-width: 84rpx;
  1126. height: 58rpx;
  1127. display: flex;
  1128. align-items: center;
  1129. justify-content: center;
  1130. border-radius: 100rpx;
  1131. font-family: PingFang SC;
  1132. // font-weight: 400;
  1133. font-size: 30rpx;
  1134. color: #3B3D3D;
  1135. background-color: transparent;
  1136. border: 1px solid #3B3D3D;
  1137. transition: all 0.3s ease;
  1138. &.active {
  1139. border: 1px solid $primary-color;
  1140. color: $primary-color;
  1141. }
  1142. }
  1143. /* 课程弹出窗样式 */
  1144. .course-popup {
  1145. padding: 0 32rpx;
  1146. max-height: 80vh;
  1147. }
  1148. .popup-header {
  1149. display: flex;
  1150. justify-content: space-between;
  1151. align-items: center;
  1152. padding: 20rpx 0;
  1153. border-bottom: 2rpx solid #EEEEEE
  1154. // margin-bottom: 40rpx;
  1155. }
  1156. .popup-title {
  1157. font-family: PingFang SC;
  1158. font-weight: 500;
  1159. font-size: 34rpx;
  1160. color: #181818;
  1161. }
  1162. .course-list {
  1163. max-height: 60vh;
  1164. overflow-y: auto;
  1165. }
  1166. .course-item {
  1167. display: flex;
  1168. align-items: center;
  1169. gap: 24rpx;
  1170. padding-top: 24rpx;
  1171. padding-right: 8rpx;
  1172. padding-bottom: 24rpx;
  1173. padding-left: 8rpx;
  1174. border-bottom: 1px solid #EEEEEE;
  1175. cursor: pointer;
  1176. &:last-child {
  1177. border-bottom: none;
  1178. }
  1179. }
  1180. .course-number {
  1181. width: 80rpx;
  1182. font-family: PingFang SC;
  1183. // font-weight: 400;
  1184. font-size: 36rpx;
  1185. color: #999;
  1186. &.highlight {
  1187. color: $primary-color;
  1188. }
  1189. // margin-right: 24rpx;
  1190. }
  1191. .course-content {
  1192. flex: 1;
  1193. }
  1194. .course-english {
  1195. font-family: PingFang SC;
  1196. font-weight: 600;
  1197. font-size: 36rpx;
  1198. line-height: 44rpx;
  1199. color: #252545;
  1200. margin-bottom: 8rpx;
  1201. &.highlight {
  1202. color: $primary-color;
  1203. }
  1204. }
  1205. .course-chinese {
  1206. font-size: 28rpx;
  1207. line-height: 48rpx;
  1208. color: #3B3D3D;
  1209. &.highlight {
  1210. color: $primary-color;
  1211. }
  1212. }
  1213. /* 释义弹窗样式 */
  1214. .meaning-popup {
  1215. // width: 670rpx;
  1216. background-color: #FFFFFF;
  1217. // border-radius: 32rpx;
  1218. overflow: hidden;
  1219. }
  1220. .meaning-header {
  1221. display: flex;
  1222. justify-content: space-between;
  1223. align-items: center;
  1224. padding: 32rpx;
  1225. border-bottom: 2rpx solid #EEEEEE;
  1226. }
  1227. .close-btn {
  1228. width: 80rpx;
  1229. }
  1230. .close-text {
  1231. font-family: PingFang SC;
  1232. font-size: 32rpx;
  1233. color: #8b8b8b;
  1234. }
  1235. .meaning-title {
  1236. font-family: PingFang SC;
  1237. font-weight: 500;
  1238. font-size: 34rpx;
  1239. color: #181818;
  1240. }
  1241. .meaning-content {
  1242. padding: 32rpx;
  1243. }
  1244. .meaning-image {
  1245. width: 670rpx;
  1246. height: 268rpx;
  1247. border-radius: 24rpx;
  1248. margin-bottom: 32rpx;
  1249. }
  1250. .word-info {
  1251. margin-bottom: 32rpx;
  1252. }
  1253. .word-main {
  1254. display: flex;
  1255. align-items: center;
  1256. gap: 16rpx;
  1257. margin-bottom: 8rpx;
  1258. }
  1259. .word-text {
  1260. font-family: PingFang SC;
  1261. font-weight: 500;
  1262. font-size: 40rpx;
  1263. color: #181818;
  1264. }
  1265. .phonetic-container{
  1266. display: flex;
  1267. gap: 24rpx;
  1268. .phonetic-text {
  1269. font-family: PingFang SC;
  1270. font-size: 28rpx;
  1271. color: #262626;
  1272. margin-bottom: 16rpx;
  1273. }
  1274. }
  1275. .word-meaning {
  1276. display: flex;
  1277. gap: 16rpx;
  1278. }
  1279. .part-of-speech {
  1280. font-family: PingFang SC;
  1281. font-size: 28rpx;
  1282. color: #262626;
  1283. }
  1284. .meaning-text {
  1285. font-family: PingFang SC;
  1286. font-size: 28rpx;
  1287. color: #181818;
  1288. flex: 1;
  1289. }
  1290. .knowledge-gain {
  1291. background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  1292. border-radius: 24rpx;
  1293. padding: 32rpx 40rpx;
  1294. }
  1295. .knowledge-header {
  1296. display: flex;
  1297. align-items: center;
  1298. gap: 16rpx;
  1299. margin-bottom: 20rpx;
  1300. }
  1301. .knowledge-icon {
  1302. width: 48rpx;
  1303. height: 48rpx;
  1304. }
  1305. .knowledge-title {
  1306. font-family: PingFang SC;
  1307. font-weight: 600;
  1308. font-size: 30rpx;
  1309. color: #3B3D3D;
  1310. }
  1311. .knowledge-content {
  1312. font-family: PingFang SC;
  1313. font-size: 28rpx;
  1314. color: #4f4f4f;
  1315. line-height: 48rpx;
  1316. }
  1317. /* 音频控制栏样式 */
  1318. .audio-controls {
  1319. background: #fff;
  1320. padding: 20rpx 40rpx;
  1321. border-bottom: 1rpx solid #eee;
  1322. transition: transform 0.3s ease;
  1323. position: relative;
  1324. z-index: 10;
  1325. &.audio-hidden {
  1326. transform: translateY(100%);
  1327. }
  1328. }
  1329. .audio-time {
  1330. display: flex;
  1331. align-items: center;
  1332. margin-bottom: 20rpx;
  1333. }
  1334. .time-text {
  1335. font-size: 28rpx;
  1336. color: #999;
  1337. min-width: 80rpx;
  1338. }
  1339. .progress-container {
  1340. flex: 1;
  1341. margin: 0 20rpx;
  1342. }
  1343. .progress-bar {
  1344. position: relative;
  1345. height: 6rpx;
  1346. background: #f0f0f0;
  1347. border-radius: 3rpx;
  1348. }
  1349. .progress-fill {
  1350. position: absolute;
  1351. left: 0;
  1352. top: 0;
  1353. height: 100%;
  1354. background: #06DADC;
  1355. border-radius: 3rpx;
  1356. transition: width 0.1s ease;
  1357. }
  1358. .progress-thumb {
  1359. position: absolute;
  1360. top: 50%;
  1361. width: 16rpx;
  1362. height: 16rpx;
  1363. background: #06DADC;
  1364. border-radius: 50%;
  1365. transform: translate(-50%, -50%);
  1366. transition: left 0.1s ease;
  1367. }
  1368. .audio-controls-row {
  1369. display: flex;
  1370. align-items: center;
  1371. justify-content: space-between;
  1372. }
  1373. .control-btn {
  1374. display: flex;
  1375. // flex-direction: column;
  1376. align-items: center;
  1377. padding: 10rpx;
  1378. gap: 8rpx;
  1379. }
  1380. .control-text {
  1381. font-size: 28rpx;
  1382. color: #4A4A4A;
  1383. // margin-top: 8rpx;
  1384. }
  1385. .play-btn {
  1386. display: flex;
  1387. align-items: center;
  1388. justify-content: center;
  1389. padding: 10rpx;
  1390. }
  1391. /* 音频加载状态样式 */
  1392. .audio-loading-container {
  1393. background: #fff;
  1394. padding: 40rpx;
  1395. border-bottom: 1rpx solid #eee;
  1396. display: flex;
  1397. flex-direction: column;
  1398. align-items: center;
  1399. justify-content: center;
  1400. gap: 20rpx;
  1401. position: relative;
  1402. z-index: 10;
  1403. }
  1404. .loading-text {
  1405. font-size: 28rpx;
  1406. color: #999;
  1407. }
  1408. /* 获取音频按钮样式 */
  1409. .audio-get-button-container {
  1410. background: rgba(255, 255, 255, 0.95);
  1411. backdrop-filter: blur(10px);
  1412. padding: 30rpx;
  1413. border-radius: 20rpx;
  1414. border: 2rpx solid #E5E5E5;
  1415. transition: all 0.3s ease;
  1416. position: relative;
  1417. z-index: 10;
  1418. }
  1419. .get-audio-btn {
  1420. display: flex;
  1421. align-items: center;
  1422. justify-content: center;
  1423. gap: 16rpx;
  1424. padding: 20rpx 40rpx;
  1425. background: linear-gradient(135deg, #06DADC 0%, #04B8BA 100%);
  1426. border-radius: 50rpx;
  1427. box-shadow: 0 8rpx 20rpx rgba(6, 218, 220, 0.3);
  1428. transition: all 0.3s ease;
  1429. }
  1430. .get-audio-btn:active {
  1431. transform: scale(0.95);
  1432. box-shadow: 0 4rpx 10rpx rgba(6, 218, 220, 0.2);
  1433. }
  1434. .get-audio-text {
  1435. font-size: 32rpx;
  1436. color: #FFFFFF;
  1437. font-weight: 500;
  1438. }
  1439. </style>