Commit e0ca408a authored by zhengke's avatar zhengke
parents c010e298 c687298a
<template>
<!-- 单选题 -->
<view>
<view class="listen">
<view class="item" style="padding: 0 20px">
<view class="name">
<view>
......@@ -34,7 +34,13 @@
style="width: 26rpx; height: 22rpx"
src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/horn.png"
/>
{{audioTime}}
<van-count-down
:time="audioTime"
:auto-start="false"
class="flex flex_center_center"
ref="listenCountdown"
format="mm:ss"
/>
</view>
</view>
<view class="questionView">
......@@ -138,9 +144,11 @@ import {
watch,
computed,
onMounted,
onUnmounted,
} from "vue";
import { changeNumToHan } from "../../utils/index";
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true
export default {
props: {
paperData: Object,
......@@ -149,7 +157,7 @@ export default {
isLast: Boolean,
},
setup(props, context) {
let { ctx } = getCurrentInstance();
let { refs } = getCurrentInstance();
let data = reactive({
autoplay: false,
sortIndex: props.sort + 1, //大题序号
......@@ -157,8 +165,8 @@ export default {
data: props.paperData,
current: 1, //默认从第几个开始-用于从快捷菜单点入
ExamIndex: 1, //第几题
audioTime:'00:00',
isPlay:false,
audioTime:60*60*1000,
isPlay:true,
});
data.data.DetailsList.map((item) => {
let arr = item.Title.split(" "); //按空格分段
......@@ -188,25 +196,30 @@ export default {
audioManage(url) {
innerAudioContext.src = url;
console.log(188, innerAudioContext);
innerAudioContext.autoplay = true
innerAudioContext.onCanplay(()=> {
console.log( innerAudioContext.duration)
// 必须。可以当做是初始化时长
innerAudioContext.duration;
// 必须。不然也获取不到时长
setTimeout(() => {
let t=innerAudioContext.duration
let m=parseInt(t/60)<10?'0'+parseInt(t/60):parseInt(t/60)
let s=parseInt(t%60)<10?'0'+parseInt(t%60):parseInt(t%60)
data.audioTime=m+':'+s
console.log( data.audioTime); // 401.475918
let t= innerAudioContext.duration
// let m=parseInt(t/60)<10?'0'+parseInt(t/60):parseInt(t/60)
// let s=parseInt(t%60)<10?'0'+parseInt(t%60):parseInt(t%60)
data.audioTime= t*1000
console.log( 207,t, data.audioTime); // 401.475918
}, 100)
})
innerAudioContext.onPlay(() => {
console.log("开始播放");
});
if(data.isPlay) {
innerAudioContext.play();
// refs.listenCountdown.start();
console.log("开始播放",refs);
data.isPlay=false
}else{
innerAudioContext.stop();
console.log("停了");
data.isPlay=true
}
// console.log(189, innerAudioContext.duration);
innerAudioContext.onError((res) => {
console.log(res.errMsg);
......@@ -240,6 +253,7 @@ export default {
},
onchange(e) {
data.audioTime="00:00"
innerAudioContext.stop();
data.ExamIndex = e.detail.current;
if (data.ExamIndex === data.data.DetailsList.length + 1) {
console.log("听力", e.detail);
......@@ -255,6 +269,10 @@ export default {
data.current = props.paperData.DetailsList.length;
}
});
onUnmounted(()=>{
innerAudioContext.stop();
data.isPlay=true
});
let that = methods;
return {
...toRefs(data),
......@@ -263,7 +281,7 @@ export default {
},
};
</script>
<style scoped>
<style>
.name {
height: 90rpx;
font-size: 28rpx;
......@@ -318,6 +336,7 @@ export default {
font-weight: 500;
color: #00acf9;
}
.item2 {
box-sizing: border-box;
margin: 30rpx 0;
......@@ -363,4 +382,9 @@ export default {
font-weight: bold;
color: #111111;
}
.listen .van-count-down{
font-size: 22rpx !important;
color: #00acf9 !important;
background-color: #000000
}
</style>
......@@ -59,10 +59,7 @@
}, {
"path": "examPaper", //试卷内容
"style": {
"navigationStyle": "custom",
"usingComponents": {
"van-count-down": "/wxcomponents/vant/count-down/index" //
}
"navigationStyle": "custom"
}
}]
}
......@@ -119,7 +116,8 @@
"van-nav-bar": "/wxcomponents/vant/nav-bar/index", //
"van-tab": "/wxcomponents/vant/tab/index", //
"van-tabs": "/wxcomponents/vant/tabs/index", //
"van-tree-select": "/wxcomponents/vant/tree-select/index" //
"van-tree-select": "/wxcomponents/vant/tree-select/index", //
"van-count-down": "/wxcomponents/vant/count-down/index"
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment