<template>
	<view class="u-p-30 bg-gray min-page">
		<view class="  border-r-16 bg-fff  u-p-30 ">
			<view class="u-m-t-32">
				<up-grid :border="false" col="2">
					<up-grid-item @click="toPage(listItem,listIndex)" v-for="(listItem,listIndex) in computedMenus"
						:key="listIndex">
						<image style="width: 120rpx;height: 120rpx;" :src="listItem.miniIcon" mode="scaleToFill" />
						<text class="u-m-t-16 color-333 u-font-28 u-p-b-32">{{listItem.title}}</text>
					</up-grid-item>
				</up-grid>
			</view>

		</view>
	</view>
</template>

<script setup>
	import {
		computed
	} from 'vue';
	import go from '@/commons/utils/go.js';
	import {
		useMenusStore
	} from '@/store/menus.js';
	const menusStore = useMenusStore()
	async function init() {
		const res = await menusStore.getMenus()
	}
	init()

	function toPage(item, index) {
		console.log(item);
		uni.navigateTo({
			url: '/' + item.miniPath.replace(/^\/+|\/+$/g, ''),
			fail(err) {
				uni.showToast({
					icon: 'none',
					title: '无该页面路径或无权限访问该页面'
				})
			}
		})

	}

	const navList = [{
			title: '优惠券',
			icon: '/static/indexImg/icon-order.svg',
			pageUrl: 'PAGES_ORDER_INDEX'
		},
		{
			title: '霸王餐',
			icon: '/static/indexImg/icon-order.svg',
			pageUrl: 'PAGES_ORDER_INDEX'
		},
		{
			title: '邀请裂变',
			icon: '/static/indexImg/icon-order.svg',
			pageUrl: 'PAGES_ORDER_INDEX'
		},
		{
			title: '积分锁客',
			icon: '/static/indexImg/icon-order.svg',
			pageUrl: 'PAGES_ORDER_INDEX'
		},
		{
			title: '满减活动',
			icon: '/static/indexImg/icon-order.svg',
			pageUrl: 'PAGES_MARKET_DISCOUNT_ACTIVITY'
		},
		{
			title: '私域引流',
			icon: '/static/indexImg/icon-order.svg',
			pageUrl: 'PAGES_MARKET_DRAINAGE_CONFIG'
		},
		{
			title: '消费返现',
			icon: '/static/indexImg/icon-order.svg',
			pageUrl: 'PAGES_MARKET_CONSUME_CASHBACK'
		},

	];
	console.log(menusStore.adminPages);
	const computedMenus = computed(() => {
		const arr = menusStore.adminPages.filter(v => {
			return navList.find(navItem => navItem.title == v.title)
		})
		console.log(arr);
		return arr
	})
</script>

<style lang="scss">

</style>