<script setup>
	import {
		useUpdateApp
	} from '@/store/update.js';
	import {
		cxcJurisdictionApi,
		taskListApi
	} from '@/api/api.js';
	import {
		onLaunch,
		onShow
	} from "@dcloudio/uni-app";
	import {
		getLocation,
		getWeather,
		// beforeJump
	} from './utils/index.js';
	import {
		useStore
	} from '@/store';
	import {
		ref
	} from 'vue';

	onLaunch(() => {
		console.log('---', todoNum.value)

		// 动态更新角标
		uni.setTabBarBadge({
			index: '1',
			text: todoNum.value // 角标内容
		});

		uni.onTabBarMidButtonTap(() => {
			uni.navigateTo({
				url: '/pages/task/todotask'
			})
		})

		// 检查更新
		useUpdateApp().checkAppUpdate()
		// 定位
		getLocation()
	})
	onShow(() => {
		taskList()

		cxcJurisdictionApi({
			id: "1827997127165677570"
		}).then((res) => {
			// 1为灰化
			if (res.success) {
				const store = useStore()
				uni.setStorageSync('isgray', res.result.value)
				store.setIsgray(res.result.value)
			}
		})
	})
	const todoNum = ref(0)
	const taskList = () => {
		taskListApi({
			pageNo: 1,
			pageSize: 4,
			_t: new Date().getTime()
		}).then((res) => {
			if (res.success) {
				todoNum.value = res.result.total
			}
		})
	}
</script>

<style lang="scss">
	/*每个页面公共css */

	.gray {
		filter: grayscale(1);
	}

	.f-row {
		display: flex;
		flex-direction: row;
	}

	.f-col {
		display: flex;
		flex-direction: column;
	}

	.jca {
		justify-content: space-around;
	}

	.jce {
		justify-content: space-evenly;
	}

	.jcb {
		justify-content: space-between;
	}

	.aic {
		align-items: center;
	}
</style>