<template>
	<view>
		<web-view :webview-styles="webviewStyles" :src="src"></web-view>
	</view>
</template>

<script>
	import facebook from '@/utils/facebook.js'
	export default {
		data() {
			return {
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				},
				src:''
			}
		},
		mounted() {
			// 初始化 Facebook SDK
			    window.fbAsyncInit = function() {
				console.log("初始化 Facebook SDK");
				console.log(f);
			      FB.init({
			        appId: '884982142884404', 
					// 21026908a4829cc8f4dceffbddd01c2e    1179110879655260
			        autoLogAppEvents: true,
			        xfbml: true,
			        version: 'v9.0',
			      });
			    };
		},
		onLoad(e) {
			let that = this;
			let s = 0;
			let time = setInterval(() => {
				uni.getNetworkType({
					success: (res) => {
						console.log(res.networkType, s);
						if (res.networkType == 'none') {
							uni.showToast({
								icon: 'none',
								title: 'Please connect to the network',
								duration: 3000,
							})
						} else if (res.networkType !== 'none') {
							that.typee = 2;
							clearInterval(time);
							
						}
					}
				})
				s++;
			}, 1000);
			this.src = e.src
		},
		methods:{
			FB.login(function(response) {
			  if (response.authResponse) {
			    // 登录成功
			    console.log(response);
			    // 可以在这里处理登录后的数据
			  } else {
			    // 登录失败
									  uni.showToast({
									  	title:'User cancelled login or did not fully authorize.',
										icon:'none',
										duration: 2000
									  })
			    console.log('User cancelled login or did not fully authorize.');
			  }
			}, { scope: 'public_profile,email' });
		}
	}
</script>

<style>

</style>