<template>
    <view id="configuration-detail">
			<web-view :src="url" :webview-styles="webviewStyles"></web-view>
		</view>
</template>

<script>
export default {
    components: {

    },
    data() {
        return {
					title:'',
					url:'',
					isLandscape:false,
					webviewStyles: {
							progress: {
									color: '#2979ff'
							}
					},
        };
    },
    computed: {

    },
		//页面显示时切换为横屏配置
		onShow() {
			// #ifdef APP-PLUS
			uni.showLoading({
				title: "加载中..."
			})
			this.isLandscape = true;
			setTimeout(() => {
				console.log("切横屏")
				if(this.isLandscape){
					plus.screen.unlockOrientation();
					plus.screen.lockOrientation('landscape-primary');
				}
				uni.hideLoading();
			}, 1200)
			//#endif
		},
		//页面卸载时切换为竖屏配置
		onUnload() {
			// #ifdef APP-PLUS
			console.log("切竖屏")
			this.robotView.close();
			plus.screen.unlockOrientation();//解除锁定屏幕方向
			plus.screen.lockOrientation('portrait-primary'); //锁死屏幕方向为竖屏
			this.isLandscape = false;
			uni.navigateTo({
				 url:"./configuration-appgo"
			});

			// #endif
		},
		onResize(e){
			console.log("窗口变化")
		},
		onLoad(option) {
			console.log("获取参数为",option)
			// #ifdef APP-PLUS
			plus.navigator.setFullscreen(true);
			setTimeout(() => {
				this.addBtn();
			}, 1500)
			// #endif
			this.$u.mpShare = {
				path: '/pages/configuration/configuration-detail?name=' + option.name + '&url=' + option.url, // 默认为当前页面路径，一般无需修改，QQ小程序不支持
			}
			if(option.url){
				this.title = decodeURIComponent(option.name);
				// #ifdef MP
				uni.setNavigationBarTitle({
				　　title: this.title
				})
				// #endif
				this.url = decodeURIComponent(option.url);
			}
		},
    watch: {

    },
    created() {

    },
    mounted() {

    },
    methods: {
			addBtn(){
				let top = 30;
				// 防止状态栏过高
				if(uni.getSystemInfoSync().statusBarHeight > 30){
					top = uni.getSystemInfoSync().statusBarHeight + 'px';
				}else{
					top = 30 + 'px';
				}

				this.robotView = new plus.nativeObj.View('robot-btn', {
					top: top,
					left: '30px',
					height: '50px',
					width: '50px'
				},
				[{
						tag: 'img',
						id: 'robot',
						src: '/static/app-plus/image/configuration/return.png',
						position: {
							top: '0px',
							left: '0px',
							width: '50px',
							height: '50px'
						}
					}
				]);
				//显示按钮1
				this.robotView.show();
				//按钮1添加点击事件
				this.robotView.addEventListener("click", (e) => {
					uni.navigateBack({delta:1})
				}, false);
			}

    },
};
</script>
<style>
	page,#configuration-detail{
		height: 100%;
		background: url("data:image/gif;base64,[encoded data, 88220 characters]");
		background-repeat: no-repeat;
		/* 背景位置 */
		background-position: center center;/* 可以和其他方位组合使用 */
	}
</style>
<style scoped lang="less">
	.status_bar {
		position: fixed;
		top: 20rpx;
		left: 20rpx;
		z-index: 999;
	}
</style>
