<template>
  <div id="container">
    <div>
        <el-dropdown @command="handleCommand">
          <span class="el-dropdown-link">
            <el-icon :size="20" color="#fff">
            <UserFilled />
            </el-icon>
            <span style="padding: 0 6px;">
              {{ $store.state.userInfo.id == touristUserId ? "游客" : $store.state.userInfo.username}}
            </span>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item command="login">登录</el-dropdown-item>
              <el-dropdown-item command="register">注册用户</el-dropdown-item>
              <el-dropdown-item command="upPassword">修改密码</el-dropdown-item>
              <el-dropdown-item command="logout">退出</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
    </div>
    <el-dialog v-model="dialogLoginVisible" width="500">
      <Login :close="closeLoginDialog" />
    </el-dialog>
  </div>
</template>

<script>
import Login from "@/components/login/login.vue";
import encrypt‌ from "@/utils/encrypt‌";
export default {
  components: {
    Login,
  },
  data() {
    return {
      touristUserId:systemConfig.touristUserId,
      dialogLoginVisible: false,
    };
  },
  mounted() {},
  methods: {
    closeLoginDialog() {
      console.log("closeLoginDialog");
      this.dialogLoginVisible = false;
    },
    handleCommand(command) {
      if (command == "login") {
        this.dialogLoginVisible = true;
      } else if(command == "register"){
        
      } else if(command == "upPassword"){
        
      } else {
        encrypt‌().then(() => {
          this.$message({
            type: "success",
            message: "退出成功",
          });
        }).catch((err) => {
          this.$message({
            type: "error",
            message: err,
          });
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
    .container{
        padding: 0;
        margin: 0;
    }
    .el-dropdown-link {
        cursor: pointer;
        color: #fff;
        display: flex;
        align-items: center;
        border: 0;
    }
    .el-dropdown,.el-dropdown * {
    outline: none !important; /* 确保下拉触发器没有轮廓 */
    }

</style>
