内网环境判断

This commit is contained in:
王卓煜
2025-07-21 15:51:30 +08:00
parent 15dbd3f82f
commit 7839f3cfe3

View File

@@ -5,115 +5,125 @@
<u-toast ref="messager"></u-toast> <u-toast ref="messager"></u-toast>
<!-- <page-title :showBack="true"></page-title> --> <!-- <page-title :showBack="true"></page-title> -->
<view class="playbox" v-if="isShowPdt"><!--内容播放区域--> <view class="playbox" v-if="isShowPdt"><!--内容播放区域-->
<view style="min-height: 440upx;" > <view v-if="Internet != 2">
<view v-if="curContent.contentType==10" style="background-color: #000000;"> <view style="min-height: 440upx;" >
<!--视频--> <view v-if="curContent.contentType==10" style="background-color: #000000;">
<view style="position: relative;"> <!--视频-->
<video-player <view style="position: relative;">
:url="blobUrl" <video-player
:blobId="blobId" :url="blobUrl"
controls :blobId="blobId"
:enable-play-gesture="true" controls
:inittime="curContent.lastStudyTime" :enable-play-gesture="true"
@play="onPlayerPlay" :inittime="curContent.lastStudyTime"
@pause="onPlayerPause" @play="onPlayerPlay"
@ended="onPlayerEnded" @pause="onPlayerPause"
@timeupdate="onPlayerPlaying" @ended="onPlayerEnded"
@fullscreenchange="onFullScreen" @timeupdate="onPlayerPlaying"
:drag="curriculumData.isDrag" @fullscreenchange="onFullScreen"
style="width: 100%; object-fit: fill"> :drag="curriculumData.isDrag"
></video-player> style="width: 100%; object-fit: fill">
<view class="player-box" v-if="playerBoxShow"> ></video-player>
<view class="player-praise"> <view class="player-box" v-if="playerBoxShow">
<view @click="praiseContent" style="cursor: pointer;"> <view class="player-praise">
<image class="icon-small" v-if="isPraise" src="/static/images/icon/praise-active.png" /> <view @click="praiseContent" style="cursor: pointer;">
<image class="icon-small" v-else src="/static/images/icon/praise1.png" /> <image class="icon-small" v-if="isPraise" src="/static/images/icon/praise-active.png" />
<!-- {{ courseInfo.praises }} --> <image class="icon-small" v-else src="/static/images/icon/praise1.png" />
<view style="color:#fff;cursor: pointer;"></view> <!-- {{ courseInfo.praises }} -->
</view> <view style="color:#fff;cursor: pointer;"></view>
<view style="margin-left: 15px;cursor: pointer;" @click="treadContent"> </view>
<image class="icon-small" v-if="isTrample" src="/static/images/icon/trample-active.png" /> <view style="margin-left: 15px;cursor: pointer;" @click="treadContent">
<image class="icon-small" v-else src="/static/images/icon/trample.png" /> <image class="icon-small" v-if="isTrample" src="/static/images/icon/trample-active.png" />
<!-- {{ courseInfo.trampleCount }} --> <image class="icon-small" v-else src="/static/images/icon/trample.png" />
<view style="color:#fff;cursor: pointer;"></view> <!-- {{ courseInfo.trampleCount }} -->
</view> <view style="color:#fff;cursor: pointer;"></view>
</view> </view>
<!--以下部分已经移到下面了--> </view>
<!-- <view v-if="!scoreInfo.has" class="player-rate"> <!--以下部分已经移到下面了-->
<u-rate v-model="scoreInfo.score" active-color="#f7ba2a" text-color="#ff9900" score-template="{value}" void-color="#fff" @change="addScore"></u-rate> <!-- <view v-if="!scoreInfo.has" class="player-rate">
</view> <u-rate v-model="scoreInfo.score" active-color="#f7ba2a" text-color="#ff9900" score-template="{value}" void-color="#fff" @change="addScore"></u-rate>
<view v-if="scoreInfo.has" style="padding-top: 5px;display: flex;"> </view>
<view class="player-rate" style="padding-left: 5px;"> <view v-if="scoreInfo.has" style="padding-top: 5px;display: flex;">
<u-rate readonly :count="5" active-color="#f7ba2a" v-model="scoreInfo.score"></u-rate> <view class="player-rate" style="padding-left: 5px;">
</view> <u-rate readonly :count="5" active-color="#f7ba2a" v-model="scoreInfo.score"></u-rate>
<view class="score-text" style="margin-top:20px"> </view>
<text style="color:#ffb30f;">{{ toScore(scoreInfo.score) }}</text> <view class="score-text" style="margin-top:20px">
<text style="font-size: 12px;color: #fff"></text> <text style="color:#ffb30f;">{{ toScore(scoreInfo.score) }}</text>
</view> <text style="font-size: 12px;color: #fff"></text>
</view> --> </view>
</view> </view> -->
</view> </view>
</view> </view>
<!----> </view>
<view v-if="curContent.contentType==20"> <!---->
<!--音频播放--> <view v-if="curContent.contentType==20">
<view style="text-align: center;padding-top: 40px;background-color: #FFFFFF;"> <!--音频播放-->
<audio-player <view style="text-align: center;padding-top: 40px;background-color: #FFFFFF;">
:src="blobUrl" <audio-player
:name="curContent.contentName" :src="blobUrl"
:drag="curriculumData.isDrag" :name="curContent.contentName"
@onPlay="audioPlay" :drag="curriculumData.isDrag"
@onPause="audioPause" @onPlay="audioPlay"
@onPlaying="audioPlaying" @onPause="audioPause"
@onEnded="audioEnd"> @onPlaying="audioPlaying"
</audio-player> @onEnded="audioEnd">
</view> </audio-player>
</view> </view>
<view v-if="curContent.contentType==30"> </view>
<image :src="fileBaseUrl+curContent.content" style="width: 100%;"></image> <view v-if="curContent.contentType==30">
</view> <image :src="fileBaseUrl+curContent.content" style="width: 100%;"></image>
<view v-if="curContent.contentType==40"> </view>
<!--pdf文档--> <view v-if="curContent.contentType==40">
<view style="min-height: 500px;padding-top: 200upx;position: relative;"> <!--pdf文档-->
<pdf-preview v-if="curContent.content && curContent.content!=''" :src="curContent.content ? fileBaseUrl+curContent.content : ''"></pdf-preview> <view style="min-height: 500px;padding-top: 200upx;position: relative;">
</view> <pdf-preview v-if="curContent.content && curContent.content!=''" :src="curContent.content ? fileBaseUrl+curContent.content : ''"></pdf-preview>
</view> </view>
<view v-if="curContent.contentType==41"> </view>
<view class="about-gongsi-info" :style="{height:articleMore? '500upx':'auto'}" style="padding: 15px;text-indent:40px;line-height: 28px;position: relative;"> <view v-if="curContent.contentType==41">
<u-parse :content="curContent.content"></u-parse> <view class="about-gongsi-info" :style="{height:articleMore? '500upx':'auto'}" style="padding: 15px;text-indent:40px;line-height: 28px;position: relative;">
</view> <u-parse :content="curContent.content"></u-parse>
<view v-if="articleMore" @click="showMore" style="text-align: center;color: #387DF7;"><text>查看更多</text> </view> </view>
</view> <view v-if="articleMore" @click="showMore" style="text-align: center;color: #387DF7;"><text>查看更多</text> </view>
<div v-if="curContent.contentType == 50" style="min-height: 500px;"> </view>
<!--因为web-view 动态切换地址不好用所以这里先使用iframe--> <div v-if="curContent.contentType == 50" style="min-height: 500px;">
<iframe id="iframe-scorm" v-if="scormUrl" :src="scormUrl" @load="iframeScormLoad()" frameborder="0" scrolling="no" border="0px" style="width:100%;min-height:500px;border:0px;"></iframe> <!--因为web-view 动态切换地址不好用所以这里先使用iframe-->
</div> <iframe id="iframe-scorm" v-if="scormUrl" :src="scormUrl" @load="iframeScormLoad()" frameborder="0" scrolling="no" border="0px" style="width:100%;min-height:500px;border:0px;"></iframe>
<view v-if="curContent.contentType==52"> </div>
<!--外连接--> <view v-if="curContent.contentType==52">
<view v-if="conLink.openType == 1"> <!--外连接-->
<view v-if="conLink.url!=''" style="min-height: 400px;position: relative;"> <view v-if="conLink.openType == 1">
<web-view :src="conLink.url"></web-view> <view v-if="conLink.url!=''" style="min-height: 400px;position: relative;">
</view> <web-view :src="conLink.url"></web-view>
</view> </view>
<view v-else> </view>
<div style="text-align: center;padding: 20px;">{{ curContent.contentName }}</div> <view v-else>
<div style="text-align: center;padding: 20px;">{{ conLink.url }}</div> <div style="text-align: center;padding: 20px;">{{ curContent.contentName }}</div>
</view> <div style="text-align: center;padding: 20px;">{{ conLink.url }}</div>
</view> </view>
<!--作业--> </view>
<view v-if="curContent.contentType==60"> <!--作业-->
<course-homework :content="curContent" :studyId="studyId"></course-homework> <view v-if="curContent.contentType==60">
</view> <course-homework :content="curContent" :studyId="studyId"></course-homework>
<!--考试--> </view>
<view v-if="curContent.contentType==61"> <!--考试-->
<course-exam :courseType="courseInfo.type" :content="curContent" :studyId="studyId"></course-exam> <view v-if="curContent.contentType==61">
</view> <course-exam :courseType="courseInfo.type" :content="curContent" :studyId="studyId"></course-exam>
<!--评估--> </view>
<view v-if="curContent.contentType==62"> <!--评估-->
<course-assess :content="curContent" :studyId="studyId"></course-assess> <view v-if="curContent.contentType==62">
</view> <course-assess :content="curContent" :studyId="studyId"></course-assess>
</view> </view>
</view> </view>
</view>
<view v-if="Internet == 2">
<div style="margin-top:40px">
<span>十分抱歉您当前的网络环境不符合观看要求为了保障案例信息的安全您需要接入公司内网才能观看</span>
</div>
<div style="margin-top:20px" @click="getInternet">
<el-button type="primary">重新检测</el-button>
</div>
</view>
</view>
<view class="contentbox" v-if="courseInfo.name"> <view class="contentbox" v-if="courseInfo.name">
<view v-if="!catalogShow"> <view v-if="!catalogShow">
<view class="tabrow"> <view class="tabrow">
@@ -405,6 +415,16 @@
</u-popup> </u-popup>
<interact-share ref="comShare" :data="courseInfo":type="1"></interact-share> <interact-share ref="comShare" :data="courseInfo":type="1"></interact-share>
</view> </view>
<view v-if="protocolDialogVisible" class="protocol-dialog" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 30%; background-color: #fff; border-radius: 8px; z-index: 9999;">
<view class="protocol-title" style="padding: 15px; border-bottom: 1px solid #eee; font-weight: bold;">{{warnTitle}}</view>
<view class="protocol-content" style="padding: 20px;">
&emsp;&emsp;{{warn}}
</view>
<view class="dialog-footer" style="padding: 15px; text-align: center; border-top: 1px solid #eee;">
<view class="button-primary" @click="protocolDialogVisible = false" style="display: inline-block; padding: 8px 16px; background-color: #409EFF; color: #fff; border-radius: 4px; cursor: pointer;">确定</view>
</view>
</view>
<view v-if="protocolDialogVisible" class="dialog-mask" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 9998;"></view>
</template> </template>
<script> <script>
@@ -497,7 +517,11 @@
scormUrl:'', scormUrl:'',
maxDuration:0, //非音频最大时长 maxDuration:0, //非音频最大时长
cumulativeDuration:0, //非音频累计时长 cumulativeDuration:0, //非音频累计时长
defaultMaxTime:1800 //非音频默认最大时间 defaultMaxTime:1800, //非音频默认最大时间
Internet: 3,//1是成功 2是是失败 3是检测中
protocolDialogVisible:false,
warn:"测试内容",
warnTitle:"测试提示"
} }
}, },
computed: { computed: {
@@ -604,6 +628,41 @@
window.clearTimeout(this.handleTimeout); window.clearTimeout(this.handleTimeout);
} }
}, },
getXmlHttpRequest() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
},
getInternet(){
this.Internet = 3;
let $this = this;
let xmlhttp = this.getXmlHttpRequest();
let timedOut = false;
let timer = setTimeout(function () {
timedOut = true;
xmlhttp.abort();
}, 5000);
xmlhttp.open("HEAD", window.location.protocol + "//uapi.boe.com.cn/500.html", true);
xmlhttp.send();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
clearTimeout(timer);
$this.Internet = 2;
$this.protocolDialogVisible=true
} else {
clearTimeout(timer);
$this.Internet = 2;
}
} else {
if (timedOut) return;//忽略中止请求
clearTimeout(timer);//取消等待的超时
}
}
},
iframeScormLoad(){ iframeScormLoad(){
setTimeout(function(){ setTimeout(function(){
var scormIframe=document.getElementById('iframe-scorm'); var scormIframe=document.getElementById('iframe-scorm');
@@ -779,6 +838,10 @@
//this.curContent=this.contentList[0]; //this.curContent=this.contentList[0];
this.playContent(this.curContent,0); this.playContent(this.curContent,0);
} }
if(rs.result.isPermission){
this.getInternet()
console.log("需要内网环境")
}
uni.hideLoading(); uni.hideLoading();
}); });