<template>
  <div class="tabbar">
    <van-tabbar v-model="value">
      <van-tabbar-item>
        <span>首页</span>
        <i slot="icon" class="icon icon-daohang-shouye"></i>
      </van-tabbar-item>
      <van-tabbar-item>
        <span>搜房</span>
        <i slot="icon" class="icon icon-daohang-zhaofang"></i>
      </van-tabbar-item>
      <van-tabbar-item>
        <span>客服</span>
        <i slot="icon" class="icon icon-daohang-kefu"></i>
     </van-tabbar-item>
      <van-tabbar-item>
        <span>我的</span>
        <i slot="icon" class="icon icon-daohang-wode"></i>
     </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  name: "Tabbar",
  props: {
    selected: Number
  },
  data() {
    return {
      value: this.selected
    };
  },
  watch: {
    value: function(val) {
      let lang = this.$store.state.langStr;
      let cityItem = this.$util.storage.fetch("CityItem");
      if (!cityItem) {
        this.$Toast("请选择城市");
        setTimeout(() => {
          this.$router.push({
            path: `/${lang}/guide`
          });
        }, 1000);
        return;
      }
      let city = "/" + cityItem.other_name;
      switch (val) {
        case 0:
          this.$router.push("/" + lang + city);
          break;
        case 1:
          this.$router.push("/" + lang + city + "/filter");
          break;
        case 2:
          this.$router.push("/" + lang + "/service");
          break;
        case 3:
          this.$router.push("/" + lang + "/user");
          break;
      }
    }
  }
};
</script>

<style>
</style>
