diff --git a/.env.development b/.env.development
index 18be6449..d84f7c64 100644
--- a/.env.development
+++ b/.env.development
@@ -24,7 +24,7 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001'
# 线上
# VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7001'
-VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001'
+VITE_APP_BASE_H5_API_Url = 'https://aitstest.jlbank.com.cn:7001'
# VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://25.64.16.130:9601'
@@ -37,4 +37,4 @@ VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001'
# 于嘉文
# VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.16.143:9604'
# 孙宇
-VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.16.139:9604'
+# VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.16.139:9604'
diff --git a/src/api/practice.js b/src/api/practice.js
index 685afc9d..81cc6c19 100644
--- a/src/api/practice.js
+++ b/src/api/practice.js
@@ -41,7 +41,7 @@ export const queryPracticeRecordByExrId = (data) => {
});
};
-// 5.联系时候查询问答题结果
+// 5.练习时候查询问答题结果
export const queryCrsPracticeAnswerResult = (data) => {
return request({
url: base_url + '/traCrsPractice/queryCrsPracticeAnswerResult',
diff --git a/src/common/common.js b/src/common/common.js
index 06a08a74..7fd3b698 100644
--- a/src/common/common.js
+++ b/src/common/common.js
@@ -172,6 +172,25 @@ export const getUserInfo = (key = '') => {
const userInfo = uni.getStorageSync('userInfo')
return '' === key ? userInfo : userInfo[key];
}
+// 数字转换,把传入的秒转换为HH:mm:ss格式
+export const formatSeconds = (seconds) => {
+ // 处理非数字或负数情况
+ if (typeof seconds !== 'number' || isNaN(seconds) || seconds < 0) {
+ return '00:00:00';
+ }
+
+ // 计算小时、分钟和剩余秒数
+ const hours = Math.floor(seconds / 3600);
+ const minutes = Math.floor((seconds % 3600) / 60);
+ const remainingSeconds = Math.floor(seconds % 60);
+
+ // 补零函数:将数字转为两位数字符串
+ const padZero = (num) => num.toString().padStart(2, '0');
+
+ // 拼接成00:00:00格式
+ return `${padZero(hours)}:${padZero(minutes)}:${padZero(remainingSeconds)}`;
+ };
+
/**
* 判断当前运行平台是否匹配指定标识
* @param {string} flag - 平台标识:'IOS' 表示苹果iOS平台,'AND' 表示安卓平台
diff --git a/src/components/examination/question.vue b/src/components/examination/question.vue
index d6b175d4..2dfc9466 100644
--- a/src/components/examination/question.vue
+++ b/src/components/examination/question.vue
@@ -1,31 +1,33 @@
-
-
-
+
+
+
{{ voiceTime }}
-
+
{{ showContent }}
-
+
-
+ >
文
@@ -36,7 +38,7 @@
-
+
{{ showContent }}
@@ -62,7 +64,7 @@
完成
-
+
@@ -72,17 +74,13 @@
diff --git a/src/pages/examinationRecord/components/examRecordList.vue b/src/pages/examinationRecord/components/examRecordList.vue
new file mode 100644
index 00000000..22d370e8
--- /dev/null
+++ b/src/pages/examinationRecord/components/examRecordList.vue
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/examinationRecord/components/list-item.vue b/src/pages/examinationRecord/components/list-item.vue
deleted file mode 100644
index dc1240f8..00000000
--- a/src/pages/examinationRecord/components/list-item.vue
+++ /dev/null
@@ -1,249 +0,0 @@
-
-
-
-
-
-
- 未完成
- 已完成
-
-
-
- {{ item.taskName }}
-
-
- 起止时间:
- {{ item.startTm?.substr(0, 10) }}至{{ item.endTm?.substr(0, 10) }}
-
-
-
- 完成人数:
- {{ item.taskFinishSums ?? 0 }}/{{ item.taskSums ?? 0 }}
-
-
- 进度:
- {{ item.finishCrs ?? 0 }}/{{ item.sumCrs ?? 0 }}门课程
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/examinationRecord/index.vue b/src/pages/examinationRecord/index.vue
index db0e1675..d04841ab 100644
--- a/src/pages/examinationRecord/index.vue
+++ b/src/pages/examinationRecord/index.vue
@@ -5,59 +5,34 @@
- 学习任务
-
-
-
+ 考试记录
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -102,12 +66,11 @@
/*
状态栏 var(--status-bar-height)
标题高度88rpx
- 搜索栏高度80rpx
tab切换栏高度88rpx
下方滑动区域上下边距各10共20rpx
**/
- height: calc(100vh - var(--status-bar-height) - 88rpx - 80rpx - 88rpx - 20rpx);
+ height: calc(100vh - var(--status-bar-height) - 88rpx - 88rpx - 30rpx);
}
.swiper-item {
diff --git a/src/pages/favorites/components/favorites-task.vue b/src/pages/favorites/components/favorites-task.vue
deleted file mode 100644
index 488a1478..00000000
--- a/src/pages/favorites/components/favorites-task.vue
+++ /dev/null
@@ -1,236 +0,0 @@
-
-
-
-
-
-
- 未完成
- 已完成
-
-
-
- {{item.taskName}}
-
-
- 起止时间:{{item.startTm?.substr(0, 10)}}至{{item.endTm?.substr(0, 10)}}
-
-
-
- 完成人数:{{item.taskFinishSums ?? 0}}/{{item.taskSums ?? 0}}
-
-
- 我的进度:{{item.myProcess ?? 0}}%
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/favorites/components/favorites-course.vue b/src/pages/favorites/components/favoritesCourse.vue
similarity index 58%
rename from src/pages/favorites/components/favorites-course.vue
rename to src/pages/favorites/components/favoritesCourse.vue
index 447b4643..7601d40d 100644
--- a/src/pages/favorites/components/favorites-course.vue
+++ b/src/pages/favorites/components/favoritesCourse.vue
@@ -2,127 +2,129 @@
-
+
-
- {{item.evalGrade ?? 0}}分
-
+ {{ item.evalGrade ?? 0 }}分
- {{item.crsName}}
+ {{ item.crsName }}
- {{tagItem?.tagName}}
+ {{ tagItem?.tagName }}
-
- 发布:{{item.issuTm?.substr(0, 10)}}
-
-
- 已学:{{item.accmStdyCnt}}次
-
+ 发布:{{ item.issuTm?.substr(0, 10) }}
+ 已学:{{ item.accmStdyCnt }}次
-
+
\ No newline at end of file
+
diff --git a/src/pages/favorites/components/favoritesTask.vue b/src/pages/favorites/components/favoritesTask.vue
new file mode 100644
index 00000000..7327291f
--- /dev/null
+++ b/src/pages/favorites/components/favoritesTask.vue
@@ -0,0 +1,282 @@
+
+
+
+
+
+
+
+
+ 未完成
+ 已完成
+
+
+
+ {{ item.taskName }}
+
+
+ 起止时间:
+
+ {{ item.startTm?.substr(0, 10) }}至{{ item.endTm?.substr(0, 10) }}
+
+
+
+
+ 完成人数:
+ {{ item.taskFinishSums ?? 0 }}/{{ item.taskSums ?? 0 }}
+
+
+ 我的进度:
+ {{ item.myProcess ?? 0 }}%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/favorites/index.vue b/src/pages/favorites/index.vue
index 6db71eef..ddb99c04 100644
--- a/src/pages/favorites/index.vue
+++ b/src/pages/favorites/index.vue
@@ -9,14 +9,26 @@
-
+
-
+
@@ -30,30 +42,25 @@
\ No newline at end of file
+
diff --git a/src/pages/learningTasks/details.vue b/src/pages/learningTasks/details.vue
index fac17fd2..f0a4ee26 100644
--- a/src/pages/learningTasks/details.vue
+++ b/src/pages/learningTasks/details.vue
@@ -79,21 +79,35 @@
{{ item.crsName }}
-
+
暂无通过条件,可自动解锁
-
+
已自动解锁
-
- 完成练习
+
+
+ 完成练习
+
-
- 通过考试
+
+
+ 通过考试
+
@@ -112,13 +126,14 @@
@@ -221,59 +248,58 @@
}
.status_div {
color: #adb4c3;
- background-color: #F3F5F5;
+ background-color: #f3f5f5;
}
- .plug{
+ .plug {
border-top: 4rpx solid #e1e8f0;
}
}
//未完成
&.unfinished {
.circle_div {
- border: 4rpx solid #0066FF;
+ border: 4rpx solid #0066ff;
// background-color: #bdc7e6;
}
.line_div {
- border-left: 4rpx solid #0066FF;
+ border-left: 4rpx solid #0066ff;
}
.status_div {
- color: #FFFFFF;
- background-color: #4C93FF;
+ color: #ffffff;
+ background-color: #4c93ff;
}
- .plug{
- border-top: 4rpx solid #0066FF;
+ .plug {
+ border-top: 4rpx solid #0066ff;
}
}
// 未解锁
&.not_unlocked {
.circle_div {
- border: 4rpx solid #ADB4C3;
+ border: 4rpx solid #adb4c3;
}
.line_div {
- border-left: 4rpx dashed #ADB4C3;
+ border-left: 4rpx dashed #adb4c3;
}
.status_div {
- color: #6C9CE4;
- background-color: #EFF6FF;
+ color: #6c9ce4;
+ background-color: #eff6ff;
}
- .plug{
- border-top: 4rpx solid #ADB4C3;
+ .plug {
+ border-top: 4rpx solid #adb4c3;
}
}
// 最后一项
- &:last-child .plug{
+ &:last-child .plug {
width: 80%;
height: 40rpx;
margin-top: -6rpx;
-
}
.progress_div {
width: 30rpx;
display: flex;
align-items: center;
flex-direction: column;
-
+
.circle_div {
width: 20rpx;
height: 20rpx;
@@ -338,18 +364,16 @@
.button_text {
font-weight: 400;
font-size: 24rpx;
-
+
text-align: left;
margin-right: 50rpx;
- &.success{
- color: #0066FF;
+ &.success {
+ color: #0066ff;
}
- &.error{
+ &.error {
color: #999999;
}
}
-
-
}
}
}
diff --git a/src/pages/me/index.vue b/src/pages/me/index.vue
index f16c77a0..f176f2c1 100644
--- a/src/pages/me/index.vue
+++ b/src/pages/me/index.vue
@@ -1,589 +1,600 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ user_info.userName }}
-
-
-
-
-
-
-
-
- 工号:{{ user_info.loginName }}
-
-
-
-
-
-
-
-
- {{ badgeList[currentIndex].name }}
-
-
-
-
-
- 我的积分
-
-
-
-
-
-
-
-
- 徽章墙
-
-
-
-
-
-
-
-
-
-
-
-
-
- 课程记录
-
-
-
-
-
-
- 考试记录
-
-
-
-
-
- 竞赛记录
-
-
-
-
-
- AI陪练记录
-
-
-
-
-
- AI问答记录
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+ width: 4rpx;
+ height: 54rpx;
+ background: linear-gradient(
+ to bottom,
+ rgba(239, 246, 255, 0) 0%,
+ rgba(229, 239, 255, 1) 30%,
+ rgba(229, 239, 255, 1) 70%,
+ rgba(239, 246, 255, 0) 100%
+ );
+ }
+ }
+
+ .item {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+
+ .top {
+ font-family: PingFangSC, PingFang SC;
+ font-weight: 400;
+ font-size: 28rpx;
+ color: #666666;
+ line-height: 35rpx;
+ text-align: center;
+ font-style: normal;
+ }
+
+ .bottom {
+ margin-top: 5%;
+ font-weight: bold;
+ font-size: 50rpx;
+ color: #000000;
+ line-height: 58rpx;
+ text-align: left;
+ font-style: normal;
+ text-align: center;
+
+ // 数字滚动组件
+ :deep(.uv-count-num) {
+ font-weight: bold !important;
+ font-size: 50rpx !important;
+ color: #000000 !important;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ .main_div {
+ display: flex;
+ flex-direction: column;
+ background-color: #f6f8ff;
+ }
+
diff --git a/src/pages/practice/index.vue b/src/pages/practice/index.vue
index 54ec229e..dfea0327 100644
--- a/src/pages/practice/index.vue
+++ b/src/pages/practice/index.vue
@@ -15,8 +15,10 @@
/{{ storageTopicList.length }}
- 剩余时间
-
+ 练习时长
+
+ {{ formatSeconds(practiceTime) }}
+
@@ -49,10 +51,6 @@
@subject_click="subject_click"
v-model="item.my_answer"
>
-
@@ -84,10 +82,10 @@
import Subject from '@/components/examination/subject.vue';
import CharactersSubject from '@/components/examination/characters-subject.vue';
import TouchBtn from '@/components/examination/touchBtn.vue';
- import { ref, reactive, computed, onMounted, nextTick } from 'vue';
- import { onLoad } from '@dcloudio/uni-app';
+ import { ref, reactive, computed, onMounted, nextTick, onUnmounted } from 'vue';
+ import { onLoad, onHide, onShow, onUnload } from '@dcloudio/uni-app';
import common from '@/common/common';
- import { getPageCache } from '@/common/common';
+ import { setPageCache, formatSeconds, getPageCache } from '@/common/common';
import { commonUploadVoiceFile } from '@/api/common.js';
import { optionErrorIcon, examinationSheetIcon } from '@/common/imgSvg';
import { practiceAnswer, practiceCommit, queryCrsPracticeAnswerResult } from '@/api/practice.js';
@@ -95,7 +93,11 @@
const feedbackRef = ref(null);
const dialogRef = ref(null);
const touchBtnRef = ref(null);
-
+ const practiceTime = ref(0); // 当前练习时间
+ let practiceStartTime = 0; // 练习开始时间
+ let practiceTimeTimer = null; // 练习计时器
+ let leaveDuration = 0; // 当前总计离开时间
+ let leaveStartTime = 0; // 离开开始时间
const mode = ref('practice'); // 考试 examination 练习practice
const paperData = reactive({
exrId: '',
@@ -109,20 +111,19 @@
const systemInfo = uni.getSystemInfoSync();
const topic = computed({
get: () => topicList[questionNumber.value],
- set: (val) => topicList[questionNumber.value] = val
+ set: (val) => (topicList[questionNumber.value] = val)
});
const showTouchBtn = computed(() => {
return topic.value?.qnsTyp === 'ES';
});
// 下面语音组件的禁用状态判断
- const touchIsDisabled = computed(() => {
-
- return topic.value?.es_status !== '' && topic.value?.es_status !== undefined
- })
+ const touchIsDisabled = computed(() => {
+ console.log('下面语音组件的禁用状态判断', topic.value?.es_status !== '' && topic.value?.es_status !== undefined);
+ return topic.value?.es_status !== '' && topic.value?.es_status !== undefined;
+ });
-
- const progress = computed(() => {
+ const progress = computed(() => {
// 计算进度百分比(保留两位小数)
const total = storageTopicList.value.length;
if (total === 0) return 0;
@@ -132,8 +133,6 @@
// 弹出框配置
const dialogConfiguration = reactive({});
- const activeVoiceId = ref('');
-
const swiperChange = (item) => {
questionNumber.value = item.detail.current;
};
@@ -280,7 +279,7 @@
touchBtnRef.value?.clearinputText(old_text); // 清除发送框数据
// 处理失败情况
});
-
+
// const traQnsInfoVo = body.traQnsInfoVo;
// topic.analyContent = traQnsInfoVo.analyContent; // 答案解析
// console.log('答题结果', traQnsInfoVo);
@@ -294,41 +293,26 @@
})
.catch(() => {
topic.es_status = ''; // 取消转圈
-
});
};
// 录音组件提交
const touchBtnSubmit = (type, submitObj) => {
-
const old_text = touchBtnRef.value?.clearinputText(); // 清除发送框数据
-
+
if (type === 'voice') {
topic.value.es_status = '00'; // 00转圈
const voicePath = submitObj;
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {})
.then((res) => {
let _res = JSON.parse(res.data);
- console.log('res小行星', _res);
if (_res.rtnCode === '0000') {
- topic.value.es_status = '02'
+ topic.value.es_status = '02';
topic.value.my_answer = {
anserResult: _res.body.transContent,
ossKey: _res.body.fileId,
ossAddr: _res.body.ossFileAddr,
voicePath: voicePath
- }
- // {
- // "chatId":"CHAT025018122068202508232000590000000000000000000000000000000060",
- // "fileId":"S3F0250181220722025082320005900000676612",
- // "ossFileAddr":"http://25.18.122.66::9786/traoss/show//S3F0250181220722025082320005900000676612",
- // "transContent":"一二三四。"
- // }
- // submitProblemEssayQuestion({
- // anserResult: _res.body.transContent,
- // ossKey: _res.body.fileId,
- // ossAddr: _res.body.ossFileAddr,
- // voicePath: voicePath
- // });
+ };
}
})
.catch((err) => {
@@ -372,6 +356,8 @@
my_answer: []
}));
addProblem();
+ // 记录起始时间
+ practiceStartTime = new Date().getTime();
// #ifdef APP-PLUS
// 安全区域底部到屏幕底部的高度(即底部安全区域高度)
const safeAreaBottomHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom;
@@ -386,7 +372,7 @@
});
// #endif
});
-
+
const result_click = ({ key }) => {
console.log('res', key);
if (key === 'hand_in_paper') {
@@ -401,8 +387,6 @@
// 交卷按钮点击,打开交卷确认框
const hand_in_paper_button_click = () => {
console.log('点击交卷', paperData);
- // console.log('点击交卷topicList', topicList);
- // return;
// 判断是否完成所有题目
const completeList = topicList
.filter((res) => !!(Array.isArray(res.my_answer) ? res.my_answer.length : res.my_answer))
@@ -461,59 +445,42 @@
};
// 执行交卷
const hand_in_paper = () => {
- const answerDtoList = topicList.map((res) => {
- let answerItem = {
- examId: paperData.examId,
- papersId: paperData.papersId,
- qnsId: res.qnsId,
- ossKey: '',
- anserResult: ''
- };
- if (res.qnsTyp === 'ES') {
- // 问答题特殊处理
- return {
- ...answerItem,
- anserResult: ''
- };
- } else {
- //其他题
- return {
- ...answerItem,
- anserResult: res.my_answer.join(',')
- };
- }
- });
-
- console.log('answerDtoList', answerDtoList);
- dialogRef.value.close();
- common.loading('正在提交');
- commitPaperExam({
- examId: paperData.examId,
- execId: paperData.execId || '1',
- examLenTm: 1200,
- answerDtoStr: JSON.stringify(answerDtoList)
- })
- .then((res) => {
- console.log('提交成功', res);
- // 判断是否需要查分
- if (res.body.flagQuery === 'Y') {
- // 需要查分
- const examLenTm = 678;
- common.redirectTo(
- `/pages/examination/result?execId=${res.body.execId}&examLenTm=${examLenTm}&papersName=${paperData.papersName}`
- );
- } else {
- // todo 此处应该有个弹窗交代下结果
- common.navigateBack();
- }
- })
- .catch((res) => {
- console.log('error', res);
- })
- .finally(() => {
- common.hideLoading().body;
- });
+
};
+ // 启动定时器
+ const startTimer = () => {
+ if (practiceTimeTimer) {
+ clearInterval(practiceTimeTimer);
+ }
+ practiceTimeTimer = setInterval(() => {
+ const currentTime = Date.now();
+ const elapsedSeconds = Math.floor((currentTime - practiceStartTime - leaveDuration) / 1000);
+ practiceTime.value = elapsedSeconds;
+ }, 1000);
+ };
+ // 暂停定时器
+ const stopTimer = () => {
+ if (practiceTimeTimer) {
+ clearInterval(practiceTimeTimer);
+ practiceTimeTimer = null;
+ }
+ };
+ onShow(() => {
+ if (leaveStartTime) {
+ const time = Date.now() - leaveStartTime;
+ leaveDuration += time;
+ leaveStartTime = 0; // 重置离开开始时间
+ }
+ startTimer(); // 启动/恢复定时器
+ });
+
+ onHide(() => {
+ leaveStartTime = new Date().getTime();
+ stopTimer();
+ });
+ onUnload(() => {
+ stopTimer();
+ });
diff --git a/src/pages/wrongQuestionRecord/index.vue b/src/pages/wrongQuestionRecord/index.vue
index 95fdaae5..428852d4 100644
--- a/src/pages/wrongQuestionRecord/index.vue
+++ b/src/pages/wrongQuestionRecord/index.vue
@@ -128,7 +128,7 @@
}
.swiper {
- height: calc(100vh - var(--status-bar-height) - 54rpx - 88rpx - 20rpx - 10rpx - 156rpx);
+ height: calc(100vh - var(--status-bar-height) - 78rpx - 88rpx - 156rpx);
}
.swiper-item {
diff --git a/src/store/audioStore.js b/src/store/audioStore.js
new file mode 100644
index 00000000..29655fc3
--- /dev/null
+++ b/src/store/audioStore.js
@@ -0,0 +1,231 @@
+import {
+ defineStore
+} from 'pinia';
+import {
+ ref
+} from 'vue';
+
+export const useAudioStore = defineStore('audioStore', {
+ state: () => ({
+ // 音频实例(全局唯一)
+ audioInstance: null,
+ // 当前播放状态
+ isPlaying: false,
+ // 当前播放的音频地址
+ currentSrc: '',
+ // 加载状态
+ isLoading: false,
+ // 错误信息
+ errorMsg: '',
+ callbacks: {
+ onEnded: null, // 播放完成回调
+ onError: null, // 播放错误回调
+ onLoaded: null // 音频加载完成回调(可获取时长)
+ }
+ }),
+ getters: {
+ // 获取当前音频实例(简化外部调用)
+ getAudioInstance(state) {
+ return state.audioInstance;
+ },
+ // 检查是否正在播放
+ isAudioPlaying(state) {
+ return state.isPlaying;
+ }
+ },
+ actions: {
+ // 初始化音频实例(确保全局唯一)
+ initAudio() {
+ if (!this.audioInstance) {
+ // 创建实例
+ this.audioInstance = uni.createInnerAudioContext();
+ // 绑定事件监听
+ this.bindAudioEvents();
+ }
+ return this.audioInstance;
+ },
+
+ // 绑定音频事件(统一管理生命周期)
+ bindAudioEvents() {
+ if (!this.audioInstance) return;
+
+ // 播放开始事件
+ this.audioInstance.onPlay(() => {
+ this.isPlaying = true;
+ this.isLoading = false;
+ this.errorMsg = '';
+ });
+
+ // 播放结束事件
+ this.audioInstance.onEnded(() => {
+ this.resetAudioState();
+ // 触发自定义回调
+ if (this.callbacks.onEnded && typeof this.callbacks.onEnded === 'function') {
+ this.callbacks.onEnded();
+ }
+ });
+
+ // 音频可以播放时触发(此时通常能获取到时长)
+ this.audioInstance.onCanplay(() => {
+ // 尝试获取时长(部分环境需要延迟一点)
+ setTimeout(() => {
+ const duration = this.audioInstance.duration || 0;
+ if (duration > 0) {
+ this.duration = duration;
+ this.isLoaded = true;
+ this.isLoading = false;
+
+ // 触发加载完成回调(此时已获取时长)
+ if (this.callbacks.onLoaded) {
+ this.callbacks.onLoaded({
+ duration: this.duration
+ });
+ }
+ }
+ }, 100); // 短暂延迟确保时长已加载
+ });
+
+ // 加载完成事件
+ this.audioInstance.onCanplay(() => {
+ this.isLoading = false;
+ });
+
+ // 错误事件
+ this.audioInstance.onError((err) => {
+ this.isPlaying = false;
+ this.isLoading = false;
+ this.errorMsg = `播放错误: ${err.errMsg || '未知错误'}`;
+ console.error('音频错误:', err);
+ if (this.callbacks.onError && typeof this.callbacks.onError === 'function') {
+ this.callbacks.onError(this.errorMsg); // 把错误信息传给外部
+ }
+ });
+ },
+
+ // 新增:预设置音频地址并加载(此时不播放,仅获取时长)
+ setAudioSrc(src) {
+ if (!src || src === this.currentSrc) return; // 地址不变则不重复加载
+
+ this.initAudio();
+ this.isLoading = true;
+ this.isLoaded = false; // 重置加载状态
+ this.currentSrc = src;
+ this.errorMsg = '';
+
+ try {
+ // 先停止当前播放并清空旧地址
+ this.audioInstance.stop();
+ this.audioInstance.src = '';
+
+ // 设置新地址并加载(不自动播放)
+ this.audioInstance.src = src;
+ this.audioInstance.load(); // 手动触发加载
+ } catch (err) {
+ this.isLoading = false;
+ this.errorMsg = `设置音频失败: ${err.message}`;
+ }
+ },
+
+ // 修改:播放当前已设置的音频(需先调用setAudioSrc)
+ playAudio() {
+ if (!this.currentSrc) {
+ this.errorMsg = '请先设置音频地址';
+ return;
+ }
+
+ // 已在播放则暂停
+ if (this.isPlaying) {
+ this.pauseAudio();
+ return;
+ }
+
+ // 未加载完成则等待加载
+ if (!this.isLoaded) {
+ this.isLoading = true;
+ return;
+ }
+
+ // 执行播放
+ try {
+ this.audioInstance.play();
+ this.isPlaying = true;
+ this.isLoading = false;
+ } catch (err) {
+ this.isLoading = false;
+ this.errorMsg = `播放失败: ${err.message}`;
+ }
+ },
+
+ // 暂停播放
+ pauseAudio() {
+ if (this.audioInstance && this.isPlaying) {
+ this.audioInstance.pause();
+ this.isPlaying = false;
+ }
+ },
+
+ // 停止播放并重置状态
+ stopAudio() {
+ if (this.audioInstance) {
+ this.audioInstance.stop();
+ this.resetAudioState();
+ }
+ },
+ // 重置音频状态(保留实例,清空状态)
+ resetAudioState() {
+ this.isPlaying = false;
+ this.isLoading = false;
+ this.currentSrc = '';
+ // 清空地址避免残留
+ if (this.audioInstance) {
+ this.audioInstance.src = '';
+ }
+ },
+ // 销毁音频实例(页面卸载时调用)
+ destroyAudio() {
+ if (this.audioInstance) {
+ // 移除所有事件监听
+ this.audioInstance.offPlay();
+ this.audioInstance.offEnded();
+ this.audioInstance.offCanplay();
+ this.audioInstance.offError();
+ // 停止并销毁实例
+ this.audioInstance.stop();
+ this.audioInstance.destroy();
+ // 重置所有状态
+ this.audioInstance = null;
+ this.resetAudioState();
+ this.errorMsg = '';
+ }
+ },
+ // 移除所有回调(组件卸载时调用)
+ removeCallbacks() {
+ this.callbacks.onEnded = null;
+ this.callbacks.onError = null;
+ this.callbacks.onLoaded = null;
+ },
+ // 注册播放完成回调
+ onAudioEnded(callback) {
+ console.log('onAudioEnded');
+ if (typeof callback === 'function') {
+ this.callbacks.onEnded = callback;
+ }
+ },
+
+ // 注册播放错误回调
+ onAudioError(callback) {
+ console.log('注册播放错误回调');
+ if (typeof callback === 'function') {
+ this.callbacks.onError = callback;
+ }
+ },
+ // 新增:注册音频加载完成回调(用于获取时长)
+ onAudioLoaded(callback) {
+ if (typeof callback === 'function') {
+ this.callbacks.onLoaded = callback;
+ }
+ },
+
+ }
+
+});
\ No newline at end of file
diff --git a/src/uni_modules/uv-collapse/changelog.md b/src/uni_modules/uv-collapse/changelog.md
new file mode 100644
index 00000000..02195603
--- /dev/null
+++ b/src/uni_modules/uv-collapse/changelog.md
@@ -0,0 +1,5 @@
+## 1.0.1(2023-05-16)
+1. 优化组件依赖,修改后无需全局引入,组件导入即可使用
+2. 优化部分功能
+## 1.0.0(2023-05-10)
+uv-collapse 折叠面板
diff --git a/src/uni_modules/uv-collapse/components/uv-collapse-item/props.js b/src/uni_modules/uv-collapse/components/uv-collapse-item/props.js
new file mode 100644
index 00000000..18983c10
--- /dev/null
+++ b/src/uni_modules/uv-collapse/components/uv-collapse-item/props.js
@@ -0,0 +1,60 @@
+export default {
+ props: {
+ // 标题
+ title: {
+ type: String,
+ default: ''
+ },
+ // 标题右侧内容
+ value: {
+ type: String,
+ default: ''
+ },
+ // 标题下方的描述信息
+ label: {
+ type: String,
+ default: ''
+ },
+ // 是否禁用折叠面板
+ disabled: {
+ type: Boolean,
+ default: false
+ },
+ // 是否展示右侧箭头并开启点击反馈
+ isLink: {
+ type: Boolean,
+ default: true
+ },
+ // 是否开启点击反馈
+ clickable: {
+ type: Boolean,
+ default: true
+ },
+ // 是否显示内边框
+ border: {
+ type: Boolean,
+ default: true
+ },
+ // 标题的对齐方式
+ align: {
+ type: String,
+ default: 'left'
+ },
+ // 唯一标识符
+ name: {
+ type: [String, Number],
+ default: ''
+ },
+ // 标题左侧图片,可为绝对路径的图片或内置图标
+ icon: {
+ type: String,
+ default: ''
+ },
+ // 面板展开收起的过渡时间,单位ms
+ duration: {
+ type: Number,
+ default: 300
+ },
+ ...uni.$uv?.props?.collapseItem
+ }
+}
\ No newline at end of file
diff --git a/src/uni_modules/uv-collapse/components/uv-collapse-item/uv-collapse-item.vue b/src/uni_modules/uv-collapse/components/uv-collapse-item/uv-collapse-item.vue
new file mode 100644
index 00000000..32f03aa5
--- /dev/null
+++ b/src/uni_modules/uv-collapse/components/uv-collapse-item/uv-collapse-item.vue
@@ -0,0 +1,228 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/uni_modules/uv-collapse/components/uv-collapse/props.js b/src/uni_modules/uv-collapse/components/uv-collapse/props.js
new file mode 100644
index 00000000..70fa04c5
--- /dev/null
+++ b/src/uni_modules/uv-collapse/components/uv-collapse/props.js
@@ -0,0 +1,20 @@
+export default {
+ props: {
+ // 当前展开面板的name,非手风琴模式:[],手风琴模式:string | number
+ value: {
+ type: [String, Number, Array, null],
+ default: null
+ },
+ // 是否手风琴模式
+ accordion: {
+ type: Boolean,
+ default: false
+ },
+ // 是否显示外边框
+ border: {
+ type: Boolean,
+ default: true
+ },
+ ...uni.$uv?.props?.collapse
+ }
+}
\ No newline at end of file
diff --git a/src/uni_modules/uv-collapse/components/uv-collapse/uv-collapse.vue b/src/uni_modules/uv-collapse/components/uv-collapse/uv-collapse.vue
new file mode 100644
index 00000000..5e5c96da
--- /dev/null
+++ b/src/uni_modules/uv-collapse/components/uv-collapse/uv-collapse.vue
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
diff --git a/src/uni_modules/uv-collapse/package.json b/src/uni_modules/uv-collapse/package.json
new file mode 100644
index 00000000..cf9565f6
--- /dev/null
+++ b/src/uni_modules/uv-collapse/package.json
@@ -0,0 +1,89 @@
+{
+ "id": "uv-collapse",
+ "displayName": "uv-collapse 折叠面板 全面兼容小程序、nvue、vue2、vue3等多端",
+ "version": "1.0.1",
+ "description": "折叠面板组件,通过折叠面板收纳内容区域,点击可展开收起,多功能参数可配置。",
+ "keywords": [
+ "uv-collapse",
+ "uvui",
+ "uv-ui",
+ "collapse",
+ "折叠面板"
+],
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^3.1.0"
+ },
+ "dcloudext": {
+ "type": "component-vue",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "插件不采集任何数据",
+ "permissions": "无"
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [
+ "uv-ui-tools",
+ "uv-line",
+ "uv-cell"
+ ],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "y",
+ "vue3": "y"
+ },
+ "App": {
+ "app-vue": "y",
+ "app-nvue": "y"
+ },
+ "H5-mobile": {
+ "Safari": "y",
+ "Android Browser": "y",
+ "微信浏览器(Android)": "y",
+ "QQ浏览器(Android)": "y"
+ },
+ "H5-pc": {
+ "Chrome": "y",
+ "IE": "y",
+ "Edge": "y",
+ "Firefox": "y",
+ "Safari": "y"
+ },
+ "小程序": {
+ "微信": "y",
+ "阿里": "y",
+ "百度": "y",
+ "字节跳动": "y",
+ "QQ": "y",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/uni_modules/uv-collapse/readme.md b/src/uni_modules/uv-collapse/readme.md
new file mode 100644
index 00000000..cb340ba3
--- /dev/null
+++ b/src/uni_modules/uv-collapse/readme.md
@@ -0,0 +1,11 @@
+## Collapse 折叠面板
+
+> **组件名:uv-collapse**
+
+通过折叠面板收纳内容区域,点击可展开收起,多功能参数可配置。
+
+### 查看文档
+
+### [完整示例项目下载 | 关注更多组件](https://ext.dcloud.net.cn/plugin?name=uv-ui)
+
+#### 如使用过程中有任何问题,或者您对uv-ui有一些好的建议,欢迎加入 uv-ui 交流群:uv-ui、官方QQ群