<template>
	<uni-popup ref="kaitongRef" :animation="false" :is-mask-click="false" mask-background-color="rgba(0,0,0, 0.76);">
		<view class="phone-tip-dialog">
			<view class="common-body-box">
				<view class="tip-title">开通方式</view>
				<view @click="handleClose">关闭</view>
			</view>

			<view @click="handleKaitong">使用手机号快速登录</view>
			<view @click="youkeKaitongIos"  v-if="currentPlatform== 'ios'">游客身份开通(限当前设备使用)</view>
		</view>
	</uni-popup>

	<goLoginVue ref="LoginRef" @success="onLoginSuccess"></goLoginVue>
</template>

<script setup>
	import {
		nextTick,
		ref
	} from 'vue';
	import goLoginVue from "@/components/goLogin/goLogin.vue"

	const kaitongRef = ref(null); // 索引
	const LoginRef = ref(null);
	const currentPlatform = ref(null);
  const emits = defineEmits(['success','ykIoszhifu']);


	function isIOSorAndroid() {
		const systemInfo = uni.getSystemInfoSync();

		if (systemInfo.platform == 'ios') {
			currentPlatform.value = 'ios'
		} else {
			currentPlatform.value = 'android'
		}
	}

	// 打开弹窗
	function handleShow() {
		isIOSorAndroid();
		kaitongRef.value.open();
	}

	function handleClose() {
		kaitongRef.value.close();
	}

	function handleKaitong() {
		LoginRef.value.showDl();
		nextTick(() => {
			kaitongRef.value.close();
		})
	}
	function youkeKaitongIos(){
		    emits('ykIoszhifu')
	}

  function onLoginSuccess() {
    emits('success')
  }

	defineExpose({
		handleShow
	})
</script>

<style>
</style>