|
@@ -11,7 +11,7 @@
|
|
|
style="background-image:url(../../static/bg1.svg) ;height: 100vh;background-size: cover;background-color: #beb685;">
|
|
|
<view class="flex-item flex-item-V uni-bg-red">
|
|
|
<view style="height: 50px;padding: 30px;">
|
|
|
- <view class="title">艺术监测考试</view>
|
|
|
+ <view class="title"><strong style="color: #414100 ;">艺术监测考试</strong></view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="flex-item flex-item-V uni-bg-green">
|
|
@@ -31,11 +31,23 @@
|
|
|
<view class="flex-item uni-bg-blue">
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view style="position: fixed;right: 10px;bottom: 10px;background-color: #c1c1c1;width: 300px;height: 200px;">
|
|
|
- <a href="https://down.360safe.com/se/qd/360se_setup__sembg100031.exe">360浏览器</a>
|
|
|
- <br/>
|
|
|
- <a href="https://c2rsetup.officeapps.live.com/c2r/downloadEdge.aspx?platform=Default&source=EdgeStablePage&Channel=Stable&language=zh-cn&brand=M100">edge浏览器</a>
|
|
|
- </view>
|
|
|
+ <uni-card :title="'浏览器下载和音频测试'"
|
|
|
+ style="position: fixed;right: 10px;bottom: 10px;background-color: #a4c1bd;width: 280px;height: 180px;border-radius: 25px;padding: 20px;">
|
|
|
+ <strong><uni-link href="https://browser.360.cn/" text="360浏览器" color="#780002"></uni-link> /
|
|
|
+ <uni-link href="https://www.microsoft.com/zh-cn/edge/download" text="Edge浏览器"
|
|
|
+ color="#780002"></uni-link> /
|
|
|
+ <uni-link href="https://www.google.cn/intl/zh-CN/chrome/browser-tools/" text="谷歌浏览器"
|
|
|
+ color="#780002"></uni-link></strong>
|
|
|
+ <view style="width: 95%;height: 60%;background-color: #adab6f;padding: 2%;border-radius: 5px;">
|
|
|
+ <slider :value="sliderValue" @change="onSliderChange" max="100" style="width: 85%;" :block-size='15'
|
|
|
+ block-color='#A2ABAA' activeColor='#19C590'></slider>
|
|
|
+ <button @click="onplay()"
|
|
|
+ style="width: 40%;display: inline-block;margin: 0 4% ;padding: 2px;">播放/暂停</button>
|
|
|
+ <button @click="stop()"
|
|
|
+ style="width: 40%;display: inline-block;margin: 0 4% ;padding: 2px;">结束</button>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </uni-card>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
@@ -59,7 +71,13 @@
|
|
|
msgType: 'success',
|
|
|
messageText: '这是一条成功提示',
|
|
|
value: '',
|
|
|
-
|
|
|
+ innerAudioContext: null,
|
|
|
+ audio: true,
|
|
|
+ sliderValue: null,
|
|
|
+ intervalIDqw: null,
|
|
|
+ intervalIDs: null,
|
|
|
+ duration: '',
|
|
|
+ currentTime: '',
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -87,6 +105,7 @@
|
|
|
let user = JSON.stringify(data.data.result.userInfo)
|
|
|
sessionStorage.removeItem("user")
|
|
|
sessionStorage.setItem("user", user)
|
|
|
+ this.stop()
|
|
|
redirectTo('/pages/examPage/examInfo');
|
|
|
} else {
|
|
|
this.messageToggle('error', data.data.message)
|
|
@@ -96,7 +115,80 @@
|
|
|
.catch(err => {
|
|
|
this.messageToggle('error', "网络质量不佳,请重试")
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ onplay() {
|
|
|
+ if (this.audio) {
|
|
|
+ this.audio = false
|
|
|
+ this.innerAudioContext.play();
|
|
|
+ this.intervalIDs = setInterval(() => {
|
|
|
+ if (this.innerAudioContext.duration !== 0) {
|
|
|
+ // clearInterval(intervalID);
|
|
|
+ this.duration = this.formatTime(this.innerAudioContext.duration) // 总时长
|
|
|
+ this.currentTime = this.formatTime(this.innerAudioContext.currentTime) // 当前时长
|
|
|
+ if (this.currentTime === this.duration) {
|
|
|
+ clearInterval(this.intervalIDs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 500);
|
|
|
+ // 启动定时器,每秒更新一次进度条位置
|
|
|
+ this.intervalIDqw = setInterval(() => {
|
|
|
+ if (this.innerAudioContext.duration > 0) {
|
|
|
+ this.sliderValue = (this.innerAudioContext.currentTime / this.innerAudioContext
|
|
|
+ .duration) * 100;
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.audio = true
|
|
|
+ this.innerAudioContext.pause()
|
|
|
+ clearInterval(this.intervalIDs);
|
|
|
+ clearInterval(this.intervalIDqw);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ stop() {
|
|
|
+ this.audio = true
|
|
|
+ this.innerAudioContext.stop()
|
|
|
+ this.sliderValue = 0
|
|
|
+ clearInterval(this.intervalIDs);
|
|
|
+ clearInterval(this.intervalIDqw);
|
|
|
+ },
|
|
|
+ formatTime(seconds) {
|
|
|
+ const minutes = Math.floor(seconds / 60);
|
|
|
+ const remainingSeconds = Math.floor(seconds % 60);
|
|
|
+ return `${minutes}:${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`;
|
|
|
+ },
|
|
|
+ onSliderChange(event) {
|
|
|
+ const value = event.detail.value;
|
|
|
+ if (this.innerAudioContext && this.innerAudioContext.duration > 0) {
|
|
|
+ // 验证 value 是否是有效的百分比值(0-100之间)
|
|
|
+ if (isNaN(value) || value < 0 || value > 100) {
|
|
|
+ console.error("Invalid value:", value);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算新的位置
|
|
|
+ const newPosition = (value / 100) * this.innerAudioContext.duration;
|
|
|
+
|
|
|
+ // 验证 newPosition 是否是有效的数字,不是 NaN,并且在有效范围内
|
|
|
+ if (!isNaN(newPosition) && newPosition >= 0 && newPosition <= this.innerAudioContext.duration) {
|
|
|
+ // 设置音频播放位置
|
|
|
+ this.innerAudioContext.seek(newPosition);
|
|
|
+ console.log("Seeking to position:", newPosition);
|
|
|
+ if (!this.dragging) { // 避免拖动滑块时自动更新
|
|
|
+ this.sliderValue = value;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.error("Invalid newPosition:", newPosition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ doKey(e) {
|
|
|
+ const ev = e || window.event // 获取event对象
|
|
|
+ if (ev.keyCode === 13) {
|
|
|
+ this.submitUser()
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
},
|
|
|
mounted() {
|
|
|
|
|
@@ -104,6 +196,9 @@
|
|
|
.getItem("token") !== "") {
|
|
|
redirectTo('/pages/examPage/examInfo');
|
|
|
}
|
|
|
+ this.innerAudioContext = uni.createInnerAudioContext();
|
|
|
+ this.innerAudioContext.src = 'http://10.11.12.100:9000/exam-bucket/中华人民共和国国歌.mp3';
|
|
|
+ document.onkeydown = this.doKey
|
|
|
},
|
|
|
created() {
|
|
|
|
|
@@ -114,11 +209,11 @@
|
|
|
.uni-input {
|
|
|
padding-left: 20px;
|
|
|
border: 1rpx solid #EEEEEE;
|
|
|
- height: 96rpx;
|
|
|
+ height: 50px;
|
|
|
box-shadow: 2px 2px 5px #aaaaaa;
|
|
|
margin: auto;
|
|
|
- margin-top: 300px;
|
|
|
- line-height: 96rpx;
|
|
|
+ margin-top: 25vh;
|
|
|
+
|
|
|
color: #000000;
|
|
|
width: 380px;
|
|
|
display: flex;
|
|
@@ -153,6 +248,6 @@
|
|
|
color: #000000;
|
|
|
width: 600px;
|
|
|
text-align: center;
|
|
|
- margin: auto;
|
|
|
+ margin: 0 auto 0 auto;
|
|
|
}
|
|
|
</style>
|