<template>
	<view>
		<web-view :webview-styles="webviewStyles" :src="host" @load="pageShowHandler" update-title="false"></web-view>
	</view>
	
</template>
<!-- uni 的 SDK -->
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
<script>
	
	import vue, {
		ref,
		reactive,
		toRefs,
		toRef,
		getCurrentInstance,
		watch,
		computed,
		onMounted,
		provide,
		nextTick,
	} from "vue";

	export default {
	
		setup(props) {
			uni.showLoading()
			let data = reactive({
				host:'',
				dataContent:{}
			});
			let methods = {
				Back(){
					uni.navigateBack({
						delta: 1
					})
				},
				pageShowHandler(e){
					uni.hideLoading()
				},
				getUrl(){
					uni.showLoading({
						title:'加载中',
						mask:true
					})
					if (process.env.NODE_ENV === "development") {
						// data.host = `https://localhost:8181/#/uploadFiles?uid=${data.dataContent.Uid}&courseId=${data.dataContent.CourseId}`
						data.host = `https://edu.kookaku.com/#/uploadFiles?uid=${data.dataContent.Uid}&courseId=${data.dataContent.CourseId}`
					} else {
						data.host = `https://edu.kookaku.com/#/uploadFiles?uid=${data.dataContent.Uid}&courseId=${data.dataContent.CourseId}`
					}
					setTimeout(()=>{
						uni.hideLoading()
					},5000)
				}
			}
			return {
				...toRefs(data),
				...methods
			};			
		},
		onLoad(options) {
			let json = JSON.parse(decodeURIComponent(options.exam))
			this.dataContent = json
			this.getUrl()
		}
		
	};
</script>

<style scoped>
	
</style>
