<script setup>
	/**
	 * name：
	 * user：sa0ChunLuyu
	 * date：2024年9月12日 20:01:39
	 */
	import {
		ref
	} from 'vue'
	import {
		$api,
		$response
	} from '@/api'
	import {
		onShow
	} from '@dcloudio/uni-app'
	import {
		useStore
	} from '@/store'
	import List1 from './src/list1.vue'
	import List2 from './src/list2.vue'
	const $store = useStore()
	const $props = defineProps({
		type: {
			type: Number,
			default: 1
		}
	});

	const posts = ref([])
	const getArticleList = async () => {
		const response = await $api('ArticleGetList', {
			type: Number($props.type)
		})
		$response(response, () => {
			posts.value = response.data.list
		})
	}

	const mountedAction = () => {
		getArticleList()
	}

	const config_ref = ref(null)
	const configRef = (e) => {
		if (!config_ref.value) {
			config_ref.value = e
			mountedAction()
		}
	}

	onShow(() => {
		if (!!config_ref.value) {
			mountedAction()
		}
	})
</script>
<template>
	<view>
		<view v-if="!!$store.config">
			<view :ref="configRef"></view>
		</view>
		<view>
			<view v-if="[1,2].includes(Number($props.type))">
				<List1 :list="posts" :type="Number($props.type)"></List1>
			</view>
			<view v-if="[3].includes(Number($props.type))">
				<List2 :list="posts" :type="Number($props.type)"></List2>
			</view>
		</view>
	</view>
</template>
<style scoped>

</style>