charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/components/layout/components/appHeader/index.vue
@@ -4,29 +4,55 @@
    <div class="header-user-info">
      <div class="avatar"><el-avatar icon="el-icon-user-solid"></el-avatar></div>
      <el-dropdown @command="handleCommand">
        <div class="el-dropdown-link">{{ username }}<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></div>
        <div class="el-dropdown-link">你好  {{ username }}<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></div>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="logout">退出</el-dropdown-item>
          <el-dropdown-item @click.native="updatePwd">
            <!--<d2-icon name="unlock" class="d2-mr-5" />-->
            修改密码
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <UpdatePassWord :editCommonConfig="editConfig"></UpdatePassWord>
  </div>
</template>
<script>
import Cookies from "js-cookie"
import UpdatePassWord from "./components/updatePassWord"
import {getApsPage} from '@/common/untils/index.js'
export default {
  name: "SalesLead",
  props: {
    headerTitle: String
  },
  components:{
    UpdatePassWord,
  },
  data() {
    return {
      username: ""
      username: "",
      editConfig:{
        dialogVisible:false,
        userId:"",
      }
    }
  },
  created(){
    const userObj = Cookies.get('userObj');
    console.log(Cookies.get(),'==userObj')
    if (userObj) {
      let userInfo = JSON.parse(userObj);
      this.editConfig.userId=userInfo.id
      this.username=userInfo.nickName
    } else {
      console.log('Object not found in cookie');
    }
  },
  mounted() {
    this.username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
    // this.username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
  },
  methods: {
    environmentType() {
@@ -41,16 +67,16 @@
      return type
    },
    getApsPage() {
   /* getApsPage() {
      // 首页部署在各个环境的端口
      const loginPathMap = {
      /!*const loginPathMap = {
        prod: `//${window.location.hostname}:9080`,
        test: `//192.168.20.119:9080`,
        // 想跳到本地启动的登录页的话需要把dev改成你本地项目路径
        dev: `//192.168.8.107:8080`
      }
      return loginPathMap[this.environmentType()]
    },
      return loginPathMap[this.environmentType()]*!/
    },*/
    handleCommand(command) {
      console.log(command)
      if (command === "logout") {
@@ -60,23 +86,26 @@
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            Cookies.remove("token")
        }).then(() => {
            Cookies.remove("token");
            // window.location.href = 'http://localhost:8080/login'; //本地的智慧工厂-登录页
            window.location.href = "http:" + this.getApsPage() + "/login"
            this.$message({
              type: "success",
              message: "注销成功!"
            })
          })
          .catch(() => {
            });
            setTimeout(()=>{
                window.open(`//${getApsPage()}/login`);
            },500);
          }).catch(() => {
            this.$message({
              type: "info",
              message: "已取消注销"
            })
          })
      }
    },
    updatePwd(){
      this.editConfig.dialogVisible=true
    }
  }
}