<template>
	<uni-popup ref="kaitongRef" :animation="false" :is-mask-click="false" mask-background-color="rgba(0,0,0, 0.76);">
		<view class="ezy-tip-dialog tip-small-dialog sjh-kjdl-dialog">
			<view class="close-btn" @click="handleClose"></view>
			<view class="tip-content-box sjh-kjdl-content-box">
				<view class="tip-title">开通方式</view>
                <view class="kjdl-btn" @click="handleKaitong">使用手机号快速登录</view>
                <view class="ykkt-text" @click="youkeKaitongIos"  v-if="currentPlatform== 'ios'">游客身份开通(限当前设备使用)</view>
			</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>
