<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { getLogin } from "@/api/ajax";
import { getToken } from '@/utils/auth'
export default {
  name: "App",
  data() {
    return {
    };
  },
  created() {
    this.fn()
  },
  methods:{
    async fn() {
        let userInfor = getToken();
        if (userInfor) {
            let MethodName = "/OrgServer/DictManager/GetStudyPhaseList";
            let typeListAll = [{
                study_phase: -1,
                study_phase_name: '全部'
            }]
            let typeList = []
            await getLogin(MethodName, {})
                .then((res) => {
                    if (res.status === 1) {
                        typeListAll = typeListAll.concat(res.study_phase_list)
                        typeList = res.study_phase_list
                    }
                })
                .catch(() => {

                });
            this.$store.commit('setStudyTypeAll',typeListAll)   
            this.$store.commit('setStudyType',typeList)
            let MethodNames = "/OrgServer/DictManager/GetOrgTypeList";
            let typeListAlls = [{
                type: -1,
                type_name: '全部'
            }]
            let typeLists = []
            await getLogin(MethodNames, {})
                .then((res) => {
                    if (res.status === 1) {
                        typeListAlls = typeListAlls.concat(res.type_list)
                        typeLists = res.type_list
                    }
                })
                .catch(() => {

                });
            this.$store.commit('setOrgTypeAll',typeListAlls)   
            this.$store.commit('setOrgType',typeLists)
            let provinceCityListAll = [{
                label: '全部',
                value: '0',
                leaf: true
            }]
            let provinceCityList = []
            await getLogin('/OrgServer/DictManager/GetAllProvinceCityList', {})
                .then((res) => {
                    if (res.status === 1) {
                        res.province_list.forEach(item => {
                            let obj = {
                                label: item.name,
                                value: item.id,
                                children: []
                            }
                            item.city_list.forEach(items=>{
                                let objs = {
                                    label: items.name,
                                    value: items.id,
                                    leaf: true
                                }
                                obj.children.push(objs)
                            })
                            provinceCityList.push(obj)
                            provinceCityListAll.push(obj)
                        });
                    }
                })
                .catch(() => {

                });
            this.$store.commit('setProviceCity',provinceCityList)
            this.$store.commit('setProviceCityAll',provinceCityListAll)
            let searchStatusList = [{
                status:-1,
                status_name:'全部'
            }]
            await getLogin('/OrgServer/DictManager/GetSysUserStatusList', {})
            .then((res) => {
                if(res.status===1){
                    searchStatusList = searchStatusList.concat(res.status_list)
                }
            })
            .catch(() => {
                this.loading = false
            });
            this.$store.commit('setSearchStatusList',searchStatusList)
            await getLogin('/OrgServer/Manager/SysConfigManager/GetSysConfig_Preview', {})
            .then((res) => {
                if(res.status===1){
                    this.$store.commit('setPreviewUrl',res.preview_server_url)
                }
            })
            .catch(() => {
                this.loading = false
            });
        }
    }         
  },
  mounted(){
  },
};
</script>
<style lang="scss" scoped>
#app{
    background: #F7F8FA;
    min-width: 1440px;
    min-height: 100%;
}
</style>
