<template>
	<div id="app">
		<common ref="common" @asynCallBack="asynCallBack"></common>
		<top-header :pageTitle="pageTitle"></top-header>

		<div class="mui-content vongi-icons">
			<div class="vongi-all">
				<h2>常用服务</h2>
				<ul class="mui-table-view mui-grid-view mui-grid-9">
					<li v-for="(item,index) in menu_list" class="mui-table-view-cell mui-media mui-col-xs-3">
						<a v-if="item.iconUrl" @click="goto(item.iconUrl)">
							<img :src="requirePic(item.iconPic)" />
							<div class="mui-media-body" v-text="item.iconName"></div>
						</a>
						<router-link v-else :to="{name:item.iconRoute,query:item.iconParam}">
							<img :src="requirePic(item.iconPic)" />
							<div class="mui-media-body" v-text="item.iconName"></div>
						</router-link>
					</li>
					<li class="mui-table-view-cell mui-media mui-col-xs-3">
						<router-link :to="{name:'MasterEditFun'}">
							<img src="~$project/assets/img/icon_edit.png" />
							<div class="mui-media-body">编辑</div>
						</router-link>
					</li>
				</ul>
			</div>
			<div class="vongi-all">
				<h2>全部服务</h2>
				<div v-for="(iten,indey) in fun_list">
					<h4 v-text="iten.name"></h4>
					<ul class="mui-table-view mui-grid-view mui-grid-9">
						<li v-for="(item,index) in iten.list" :class="'mui-table-view-cell mui-media mui-col-xs-3 '+(item.iconRoute?'':'kfz')">
							<a v-if="item.iconUrl" @click="goto(item.iconUrl)">
								<img :src="requirePic(item.iconPic)" />
								<div class="mui-media-body" v-text="item.iconName"></div>
							</a>
							<router-link v-else :to="{name:item.iconRoute,query:item.iconParam}">
								<img :src="requirePic(item.iconPic)" />
								<div class="mui-media-body" v-text="item.iconName"></div>
							</router-link>
						</li>
					</ul>
				</div>
			</div>
		</div>

		<loading :visible="isLoading"></loading>
	</div>
</template>

<script>
	import * as API_User from '$project/apis/user'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import NavMenu from '@/components/NavMenu.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterAllFun',
		components: {
			Common,
			Loading,
			TopHeader,
			NavMenu
		},
		data() {
			return {
				isLoading: false,

				pageTitle: '全部服务',

				fun_list: [],
			}
		},
		created() {},
		methods: {
            goto(url){
                window.location=url;
            },
			//引入图片
			requirePic(file) {
				if (file) {
					if (file.indexOf('http') == 0) {
						return file;
					} else {
						return require('$project/assets/img/' + file);
					}
				}
			},
			//获取所有功能列表
			getAllFunList() {
				this.isLoading = true;
				API_User.getAllFunList().then(response => {

					this.isLoading = false;

					this.fun_list = response.allIcon;

				}).catch(error => {
					mui.toast(error);
				})
			},
			asynCallBack() {

			},
		},
		mounted() {
			this.getAllFunList();
		},
		destroyed() {

		},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
				person_data: 'person_data',
				person_popedom: 'person_popedom',
				menu_list: 'menu_list'
			})
		}
	}
</script>

<style src="$project/assets/css/iconfont.css"></style>
<style scoped src="$project/assets/css/xpgj.css"></style>
<style>
</style>
