<template>
  <div class="w-full">
    <lucency-header :lang="lang" page-key="index" ></lucency-header>
    <div class="content h-screen">
      server data = {{msg}}
    </div>
    <div class="content h-screen">
      server data = {{msg}}
    </div>

  </div>
</template>

<script>
import lucencyHeader from "~/components/header/lucencyHeader";
import langMap from "~/map/langMap";
import handle from "~/until/handle";
export default {
  components: { lucencyHeader },
  data(){
    return {
      lang: langMap.lang.cn,
      msg: ""
    }
  },
  mounted() {
    this.$root.$on('changeLang',this.switchLang)
    this.loadData();
  },
  methods:{
    switchLang(nextLang){
      console.log("11111111111111111")
      if(nextLang){
        this.lang = nextLang;
      }else{
        if(this.lang === langMap.lang.cn){
          this.lang = langMap.lang.en
        }else{
          this.lang = langMap.lang.cn
        }
      }

    },
    async loadData(){
      let [err,res] = await handle(this.$axios.get("http://kindring.cn:9999/get"))
      if(err){
        console.log(err);
        return;
      }
      let result = res.data;
      console.log(result)
      if(result.code === 200){
        console.log("set msg")
       this.msg = result.msg ;
      }
    }
  }
}
</script>

<style>

</style>
