123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <template>
- <view>
- <web-view v-if="fullUrl" :src="fullUrl" />
- <read-socket v-if="fileId && pageShow" v-model="fileId" :course-id="courseId" />
- <read-check v-if="fileId && pageShow && checkOn===true" :time-sec="checkSec" @break="checkBreak" />
- <face-check v-if="fileId && pageShow"
- :courseId="courseId"
- :fileId="fileId"
- @ok="pageShow=true"
- @no="pageShow=false"
- >
- </face-check>
-
- </view>
- </template>
- <script>
-
- import ReadSocket from './components/ReadSocket'
- import ReadCheck from './components/ReadCheck'
- import FaceCheck from './components/FaceCheck'
- export default {
- components: { ReadSocket, ReadCheck, FaceCheck},
- data() {
- return {
- courseId: null,
- fileId: null,
- checkOn: false,
- checkSec: 0,
- // 阅读器地址
- viewerUrl: null,
- // 完整预览路径
- fullUrl: '',
- // 页面隐藏状态
- pageShow: Boolean
- }
- },
- onLoad: function(option) {
-
- // #ifndef H5
- this.viewerUrl = `${this.$urls.api}/hybrid/html/web/viewer.html`
- // #endif
-
- // #ifdef H5
- this.viewerUrl = '/hybrid/html/web/viewer.html'
- // #endif
-
- const path = decodeURIComponent(option.path)
- this.courseId = option.courseId
- this.fileId = option.fileId
- this.checkOn = option.checkOn
-
- if(option.checkOn && option.checkOn==='true'){
- this.checkOn = true
- }
-
- if(option.checkSec){
- this.checkSec = parseInt(option.checkSec)
- }
- // 填充文件
- this.fillUrl(path)
-
- console.log('课件地址', this.fullUrl)
-
- },
-
- onHide: function(){
- // 程序隐藏
- console.log('隐藏了...')
- this.pageShow = false
- },
- onShow:function(){
- console.log('显示了...')
- this.pageShow = true
- },
-
- methods:{
- // 填充H5地址
- fillUrl(path){
- if(path.startsWith('https://') || path.startsWith('http://')){
- // 网络文件
- this.fullUrl = `${this.viewerUrl}?file=${path}`;
- }else{
- // 本地地址
- this.fullUrl = `${this.viewerUrl}?file=${this.$urls.api}${path}`;
- }
- },
-
- // 验证
- checkBreak(){
- uni.switchTab({
- url: '/pages/index/index'
- })
- }
- }
- }
- </script>
|