<template>
  <div class="nav-bar-container">
    <div class="left-panel">
      <vab-remix-icon class="logo" icon-class="logo" />
      <span class="hidden-xs-only">无症状人群胃癌筛查随访数据中心</span>
    </div>
    <div class="userInfo">
      <error-log></error-log>
      <!-- <avatar></avatar> -->
      <div class="fontSelect">
        <div
          v-for="(item, index) in fontList"
          :key="index"
          :class="['font', index == fontIndex ? 'active' : '']"
          @click="changeFont(index)"
        >
          <div class="label">
            {{ item.label }}
          </div>
        </div>
      </div>
      <div
        v-if="[0, 1, 2].includes(curSelectedIndex)"
        class="community"
        @click="openModalFlag"
      >
        <img src="~@/assets/img/DataCenter/shift.png" alt="" />
        {{ screeningList[curSelectedIndex].title }}
      </div>

      <div class="user">
        <img src="~@/assets/img/DataCenter/user.png" alt="" />
        <avatar></avatar>
      </div>
      <Badge :count="messageCount" :class-name="'badge'">
        <div class="user">
          <img src="~@/assets/img/DataCenter/message.png" alt="" />
          消息
        </div>
      </Badge>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex"

import {
  Avatar,
  Breadcrumb,
  ErrorLog,
  FullScreenBar,
  ThemeBar,
} from "@/layouts/components"

export default {
  name: "NavBar",
  components: {
    Avatar,
    Breadcrumb,
    ErrorLog,
    FullScreenBar,
    ThemeBar,
  },
  props: {
    curSelectedIndex: {
      type: Number,
      default: -1,
    },
  },
  data() {
    return {
      pulse: false,
      isDot: true,
      messageCount: 10,
      screeningList: [
        {
          title: "社区筛查",
          src: require("@/assets/img/DataCenter/shequ.png"),
        },
        {
          title: "医院筛查",
          src: require("@/assets/img/DataCenter/yiyuan.png"),
        },
        {
          title: "体检筛查",
          src: require("@/assets/img/DataCenter/tijian.png"),
        },
      ],
      fontList: [
        { fontSize: "12px", label: "A-" },
        { fontSize: "14px", label: "A" },
        { fontSize: "16px", label: "A+" },
      ],
      fontIndex: localStorage.getItem("fontIndex") || 1,
    }
  },
  computed: {
    ...mapGetters({
      collapse: "settings/collapse",
      visitedRoutes: "tagsBar/visitedRoutes",
      device: "settings/device",
      routes: "routes/routes",
      feedBackNumber: "user/feedBackNumber",
    }),
  },
  created() {},
  mounted() {},
  methods: {
    handleCollapse() {
      this.$store.dispatch("settings/changeCollapse")
    },
    viewMsg() {
      this.$router.push({ name: "Message" })
    },
    async refreshRoute() {
      this.$baseEventBus.$emit("reloadRouterView")
      this.pulse = true
      setTimeout(() => {
        this.pulse = false
      }, 1000)
    },
    openModalFlag() {
      this.$emit("openModalFlag")
    },
    changeFont(i) {
      this.fontIndex = i
      this.$store.commit("table/setFontIndex", i)
      localStorage.setItem("fontIndex", i)
    },
  },
}
</script>

<style lang="scss" scoped>
.nav-bar-container {
  position: relative;
  height: 74px;
  overflow: hidden;
  user-select: none;
  background: #4e68ff;
  box-shadow: $base-box-shadow;
  display: flex;
  justify-content: space-between;
  color: #fff;
  .left-panel {
    display: flex;
    align-items: center;
    justify-items: center;
    font-size: 24px;
    font-weight: 600;
    height: 74px;
    max-height: 74px;
    letter-spacing: 2px;

    .logo {
      margin-right: 20px;
      margin-left: 40px;
      font-size: 40px;
      vertical-align: middle;
    }
    .fold-unfold {
      margin-left: 10px;
      font-size: 20px;
      color: $base-color-gray;
      cursor: pointer;
    }

    ::v-deep {
      .breadcrumb-container {
        margin-left: 10px;
      }
    }
  }
  .userInfo {
    display: flex;
    align-items: center;
    padding-right: 40px;
    .fontSelect {
      display: flex;
      margin-right: 20px;
      .font {
        width: 40px;
        height: 40px;
        background: #4e68ff;
        border-radius: 4px;
        border: 1px solid #ffffff;
        text-align: center;
        line-height: 40px;
        cursor: pointer;
        margin-left: 20px;
      }
      .active {
        box-sizing: border-box;
        background: #ffffff;
        height: 40px;
        color: #4e68ff;
        padding: 1px;
        .label {
          height: 36px;
          border: 1px solid #4e68ff;
        }
      }
    }
    .community {
      width: 106px;
      height: 30px;
      white-space: nowrap;
      background: rgba(255, 255, 255, 0.1);
      color: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      img {
        margin-right: 4px;
        width: 18px;
        height: 18px;
      }
    }
    .user {
      white-space: nowrap;
      margin-left: 40px;
      height: 30px;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      color: #fff;
      img {
        margin-right: 4px;
        width: 18px;
        height: 18px;
      }
    }
  }
  // .right-panel {
  //   display: flex;
  //   align-content: center;
  //   align-items: center;
  //   justify-content: flex-end;
  //   height: 74px;
  // ::v-deep {
  //   .user-avatar {
  //     margin-top: 2px;
  //     margin-right: 5px;
  //     font-weight: 600;
  //     cursor: pointer;
  //   }

  //   .user-name {
  //     position: relative;
  //     margin-right: 35px;
  //     margin-left: 5px;
  //     font-weight: 600;
  //     cursor: pointer;
  //   }

  //   .user-name + i {
  //     position: absolute;
  //     top: 4px;
  //     right: 15px;
  //   }

  //   svg {
  //     width: 1em;
  //     height: 1em;
  //     margin-right: 20px;
  //     font-size: $base-font-size-big;
  //     color: $base-color-gray;
  //     cursor: pointer;
  //     fill: $base-color-gray;
  //   }

  //   button {
  //     svg {
  //       margin-right: 0;
  //       color: $base-color-white;
  //       cursor: pointer;
  //       fill: $base-color-white;
  //     }
  //   }

  //   .el-badge {
  //     margin-right: 20px;
  //     padding: 0 5px;
  //     svg {
  //       margin-right: 0px;
  //     }
  //   }
  // }
  // }
}
</style>
