<template>
  <div>
<!--    header 部分布局-->
    <lucency-header :lang="lang" page-key="index" />
    <banner :wait-time="2500"/>

<!--    优势项目部分展示,参考海康-->
    <showing-stand :lang="lang"/>
<!--    产品中心,参考大华,动态加载这部分内容-->
    <product-center :lang="lang"/>
<!--    新闻中心-->
    <new-center :lang="lang"/>
<!--    页脚 -->
    <default-footer :lang="lang"/>

  </div>
</template>

<script>
import lucencyHeader from "~/components/header/lucencyHeader";
import banner from "@/components/banner/banner";
import productCenter from "~/components/productCenter";
import showingStand from "~/components/showingStand";
import newCenter from "@/components/newCenter";
import defaultFooter from "~/components/footer/defaultFooter";
import langMap from "~/map/langMap";
import handle from "~/until/handle";
export default {
  components: { lucencyHeader,banner,showingStand,defaultFooter,productCenter,newCenter },
  props:['uLang'],
  data(){
    return {
      lang: this.uLang?this.uLang:langMap.lang.cn,
    }
  },
  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>
