| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <!-- 头部信息的组件 -->
- <el-header class="el-header">
- <header class="page-home-header">
- <div class="page-home-left">
- <span class="name">欢迎你, {{ nameLeft }}</span>
- <span>{{ week }}</span
- > <span>{{ data_show }}</span>
- </div>
- <div class="page-home-right">
- <div class="head-portrait">
- <img src="../../../assets/OIP-C.jpg" alt="头像" />
- </div>
- <span class="admin">{{ nameRight }}</span>
- <span class="line"></span>
- <i class="el-icon-switch-button out" @click="output"></i>
- </div>
- </header>
- </el-header>
- </template>
- <script>
- export default {
- name: 'NavBar',
- data () {
- return {
- nameLeft: '管理员', // 左边名字
- nameRight: '管理员', // 右边名字
- // headPortrait:"../../assets/OIP-C.jpg",//用户图片
- week: '', // 左边周
- data_show: '' // 左边时间
- }
- },
- mounted () {
- this.getDataTime()
- },
- methods: {
- // 获取当前时间
- getDataTime () {
- const wk = new Date().getDay()
- const yy = new Date().getFullYear()
- const mm = new Date().getMonth() + 1
- const dd = new Date().getDate()
- const weeks = [
- '星期日',
- '星期一',
- '星期二',
- '星期三',
- '星期四',
- '星期五',
- '星期六'
- ]
- this.week = weeks[wk]
- this.data_show = yy + '年' + mm + '月' + dd + '日'
- },
- // 用户退出
- output () {
- this.$confirm('确定要退出系统吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'error'
- })
- .then(() => {
- // 点击确定的操作(调用接口)
- // this.jiashuzu.splice(index, 1);
- sessionStorage.removeItem('token')
- this.$axios('/api/user/logout/', 'GET').then((data) => {
- if (data) {
- this.$message({
- type: 'success',
- message: '已成功退出'
- })
- this.$router.go(0)
- window.sessionStorage.clear()
- } else {
- this.$message({
- type: 'error',
- message: '请稍后再试或者直接关闭浏览器'
- })
- }
- })
- })
- .catch(() => {
- // 点取消的提示
- this.$message({
- type: 'success',
- message: '已取消退出'
- })
- })
- }
- }
- }
- </script>
- <style scoped lang="less">
- .el-header {
- width: 100%;
- // border: 1px solid red;
- background-color: #040e1b;
- // color: #333;
- text-align: center;
- line-height: 60px;
- }
- .page-home-header {
- width: 100%;
- // min-width: 1400px;
- min-width: 1291px;
- height: 60px;
- box-sizing: border-box;
- display: flex;
- justify-content: space-between;
- align-items: center;
- // border-bottom: 1px solid #ecf0f8;
- font-size: 16px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #ffffff;
- background: #040e1b;
- // box-shadow: 0px 1px 50px 0px rgba(210, 214, 223, 0.7);
- .name {
- margin-right: 25px;
- }
- .admin {
- cursor: pointer;
- }
- .page-home-right {
- display: flex;
- // width: 149px;
- align-items: center;
- .head-portrait {
- width: 38px;
- height: 38px;
- box-sizing: border-box;
- img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- border-radius: 50%;
- }
- }
- .admin {
- margin: 0 20px;
- }
- .line {
- width: 1px;
- height: 36px;
- background-color: #ccc;
- margin-right: 15px;
- }
- .out {
- width: 40px;
- height: 40px;
- font-size: 35px;
- text-align: center;
- line-height: 40px;
- cursor: pointer;
- }
- }
- }
- </style>
|