<template>
  <div class="lang" @click="flagDrop = !flagDrop">
    <span class="lang-title">{{title}}</span>
    <img :src="downIcon" class="lang-icon"/>
    <win-select :selectData="localList"
                @on-change="handleLangFunc"
                :flagDrop.sync="flagDrop"></win-select>
  </div>
</template>

<script>
import downIcon from '../../../static/images/icon-down.png';
import WinSelect from '../select/select';

export default {
  components: { WinSelect },
  name: 'language',
  props: {
    lang: String,
  },
  data() {
    return {
      flagDrop: false,
      downIcon,
      langList: {
        'zh-CN': '语言',
        'en-US': 'Lang',
      },
      localList: {
        'zh-CN': '中文简体',
        'en-US': 'English',
      },
    };
  },
  watch: {
    lang(lang) {
      this.$emit('on-change', lang);
    },
  },
  computed: {
    title() {
      return this.langList[this.lang];
    },
  },
  methods: {
    handleLangFunc(lang) {
      this.$emit('on-change', lang);
    },
  },
};
</script>
<style scoped>
  .menu-enter-active{
    transition: all 0.5s ease;
  }
  .menu-leave-active{
    transition: all 0.5s cubic-bezier(.42, 0, .58, 1);
  }
  .menu-enter, .menu-leave-to{
    transform: translateY(-10%);
    opacity: 0;
  }
  .lang{
    display: inline-block;
    margin-right: 45px;
    cursor: pointer;
  }
  .lang-title{
    color: #ffffff;
    margin-right: 7px;
    font-size: 16px;
  }
  .lang-icon{
    vertical-align: middle;
  }
  .select-dropdown{
    margin: 5px 0;
    padding: 5px 0;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 6px rgba(0,0,0,.2);
    transform-origin: center top 0;
    position: absolute;
    z-index: 900;
  }
  .select-dropdown ul li{
    padding: 7px 16px;
    clear: both;
    white-space: nowrap;
    list-style: none;
    cursor: pointer;
    line-height: normal;
  }
  .select-dropdown ul li span{
    color: #515a6e;
    font-size: 12px!important;
  }
  .select-dropdown ul li:hover span{
    color: #002684;
  }
</style>
