<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<view>
			<input id="myInput" type="text" v-model="funName" placeholder="请输入方法名" />
			<button id="btnCheck" @click="funCheck">验证</button>
		</view>
		<button @click="btnTestClick">toTest</button>
		<view id="iframeView">
			<iframe :src="iframeSRC" id="myIframe">该浏览器不支持 iframe 标签</iframe>
		</view>
		<view id="routerTest">
			<view>
				<router-link to="../test/test2">test2</router-link>
			</view>
			<view>
				<router-view></router-view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {
		},
		data() {
			return {
				title: 'Hello',
				funName: '',
				myHost: 'http://39.105.166.141:8085',
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				},
				iframeSRC: '#pages/test/test2'
			}
		},
		onLoad() {
			// uni.redirectTo({
			// 	url:"../test/StartLearning"
			// })
		},
		mounted() {
			window.addEventListener('message', event => {
				let data = event.data;
				console.log(data);
				if (data.cmd === 'jump') {
					console.log("-----------jump111");
					// this.iframeSRC = '#pages/test/test3';
					// this.iframeSRC = '#pages/index/index';
					this.iframeSRC = 'https://www.baidu.com';
				} else if (data.cmd === 'jump2') {
					console.log("-----------jump222");
					this.iframeSRC = '#pages/test/test2';
					// this.iframeSRC = 'https://www.baidu.com';
				} else {
					console.log("***********notjump");
				}
			})
		},
		methods: {
			funCheck() {
				console.log(this.funName)
				this.testPOST();
			},
			testPOST() {
				let url = "http://39.105.166.141:8085/user/loginin";
				uni.request({
					header: {
						// 'Content-Type': 'application/x-www-form-urlencoded'
						'Content-Type': 'application/json'
					},
					url: url,
					method: 'POST',
					data: {
						"IlabAccount": "teststudent01",
						"Password": "qgsTest002"
					},
					dataType: 'json',
					success: (res) => {
						// var result = JSON.parse(res);
						console.log("success***", res)
					},
					fail: (res) => {
						console.log("fail***", res)
					}
				});
			},
			btnTestClick() {
				uni.navigateTo({
					url: '/pages/test/test',
				});
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	#myInput {
		border: #007AFF 1rpx solid;
	}

	#iframeView {
		margin-top: 20rpx;
	}

	#myIframe {
		border: none;
	}

	#routerTest {
		width: 500rpx;
		height: 200rpx;
		border: #aa00ff 1rpx solid;
		flex-direction: row;
	}
</style>
