<template>
	<div id="app">
		<div id="pdfh5"></div>
	</div>
</template>
<script>
	import Pdfh5 from "pdfh5";
	export default {
		name: 'App',
		data() {
			return {
				pdfh5: null,
				pdfName: "",
				ImgUrl: this.$ImgUrl
			};
		},
		onLoad: function(options) {
			console.warn(options);
			let type = options.pdfName.split("_")[1] * 1
			switch (type) {
				case 1:
					uni.setNavigationBarTitle({
						title: "服务协议"
					})
					break;
				case 2:
					uni.setNavigationBarTitle({
						title: "隐私权政策"
					})
					break;
				case 3:
					uni.setNavigationBarTitle({
						title: "未成年人个人信息保护规则"
					})
					break;
				default:
					break;
			}
			this.pdfName = options.pdfName
			this.Init(this.ImgUrl + 'AgreementPdf/' + this.pdfName)
		},
		mounted() {},
		methods: {
			// 跳转协议
			async Init(pdfName) {
				let this_ = this
				try {
					this.$nextTick(function() {
						//实例化
						this_.pdfh5 = new Pdfh5("#pdfh5", {
							pdfurl: pdfName + '.pdf',
							scale: 2,
							zoomEnable: true,
							renderType: 'svg'

						});
						//监听完成事件
						this_.pdfh5.on("complete", function(status, msg, time) {
							console.log("状态：" + status + "，信息：" + msg + "，耗时：" + time + "毫秒，总页数：" +
								this.totalNum)
						})
					})
				} catch (e) {
					//TODO handle the exception
				}
			}
		}
	}
</script>

<style>
	@import "pdfh5/css/pdfh5.css";

	* {
		padding: 0;
		margin: 0;
	}

	html,
	body,
	#app {
		width: 100%;
		height: 100%;
	}
</style>
