<template>
	<uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
		mask-background-color="rgba(255, 255, 255, 0.1);" type="bottom">
		<view class="xuexi-dagang-page">
			<!-- 头部 -->
			<view class="dagang-title">
				<text></text>
				<icon @click="goUpPage"></icon>
			</view>
			<!-- 目录 -->
			<view class="xuexi-dagang-body">
				<view v-for="item in list" @click="handleSelect" :key="item.danyuanId"></view>
			</view>
		</view>
	</uni-popup>
</template>

<script setup>
	import {
		ref
	} from 'vue';

	const list = [];
	const popupRef = ref(null)
	const emits = defineEmits(['close', 'select'])
	import * as httpApi from "@/api/chanpinShuxue.js";
	
	function goUpPage() {
		this.$refs.popupRef.close();
		emits('close')
	}
	
	function showPopup() {
		list.value = [];
		httpApi.getShuxueChanpinDanyuanMulu().then(res => {
			list.value = res.data;
			popupRef.value.open();
		})
	}
	
	function closePopup() {
		popupRef.value.close();
	}
	
	function handleSelect(item) {
		emits('select', item)
		closePopup();
	}
	
	defineExpose({
		showPopup
	})
</script>

<style>
</style>