<template>
    <keep-alive include="*">
        <router-view></router-view>
    </keep-alive>
</template>
<script>
import { mapState } from "vuex";
export default {
    name: '',
    data() {
        return {

        }
    },
    computed: {
        ...mapState(["locationInfo"])
    },
    created() {
        // this.$http.post({
        //     url: '/auth/login',
        //     data: {
        //         username: 'root',
        //         password: '123456',
        //     }
        // }).then(res => {

        // }).catch(() => {

        // })


    },
    mounted() {
        // var geolocation = new qq.maps.Geolocation(
        //     "GLFBZ-ZR2W6-76XSA-MF7CQ-GDJ6Z-6FB5K",
        //     "图途象"
        // );
        // if (!this.locationInfo) {
        //     geolocation.getLocation(res => {
        //         console.log(res)
        //         this.$store.commit('updateLocationInfo', res)

        //     })
        // }

        var mapObj = new AMap.Map('iCenter');
        mapObj.plugin('AMap.Geolocation', ()=> {
            var geolocation = new AMap.Geolocation({
                enableHighAccuracy: false,//是否使用高精度定位，默认:true
                timeout: 10000,          //超过10秒后停止定位，默认：无穷大
                maximumAge: 0,           //定位结果缓存0毫秒，默认：0
            });
            mapObj.addControl(geolocation);
            geolocation.getCurrentPosition();
            AMap.event.addListener(geolocation, 'complete', (result)=>{
                console.log(result)
                this.$store.commit('updateLocationInfo', result)
            });//返回定位信息
        });
    },
    watch: {
        $route() {
            if (this.$route.meta.title) {
                document.title = this.$route.meta.title
            }
            else {
                document.title = '图途象'
            }
        }
    },
    methods: {
    }
}
</script>
