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