DESKTOP-812G6RA\PROW_006
9 days ago ee0581277156325f60fe3a1edfd8ac1645a77ec6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<template>
  <div class="home">
    <el-container>
      <el-header>
        <div class="top">
          <div class="left">
            <el-menu
              :default-active="$route.id"
              class="el-menu-demo"
              mode="horizontal"
              @select="handleSelect"
              background-color="#f59b24"
              text-color="#fff"
              active-text-color="#409EFF"
              router
            >
              <el-menu-item
                v-for="(item, index) in nav"
                :key="index"
                :index="item.id"
              >
                <template slot="title"
                  ><div class="menu-show">
                    <span :class="item.icon"></span><div class="menu-title">{{ item.title }}</div>
                  </div></template
                >
              </el-menu-item>
            </el-menu>
          </div>
          <div class="serch">
            <el-input
              placeholder="搜索关键字"
              suffix-icon="el-icon-search"
              v-model="input1"
              clearable
            >
            </el-input>
          </div>
          <div class="right">
            <div @click="goHome">
              <img src="../../public/img/order/home.gif" alt="">
            </div>
            <div class="right-msg">
              <el-dropdown trigger="click">
                <span class="el-dropdown-link">
                  <el-badge class="mark" :value="15"
                    ><img src="../../public/img/order/msg.gif" alt=""></el-badge>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item class="clearfix">
                    评论
                    <el-badge class="mark" :value="12" />
                  </el-dropdown-item>
                  <el-dropdown-item class="clearfix">
                    回复
                    <el-badge class="mark" :value="3" />
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
            <div class="right-avtar">
              <el-dropdown trigger="click" >
                <span class="el-dropdown-link">
                  <div class="avtar-quit">
                    <el-avatar :size="30" :src="circleUrl"></el-avatar>
                    <span class="el-icon-arrow-down el-icon--right"></span>
                  </div>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item class="clearfix" 
                    ><span @click="logout">退出登录</span></el-dropdown-item
                  >
                  <el-dropdown-item class="clearfix" >修改密码</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </div>
        </div>
      </el-header>
      <el-main>
        <el-tabs
          v-model="activeIndex"
          closable
          @tab-click="tabClick"
          v-if="options.length"
          @tab-remove="tabRemove"
          type="border-card"
        >
          <el-tab-pane
            :key="item.route"
            v-for="(item) in options"
            :label="item.name"
            :name="item.route"
          >
            <router-view>
              <!-- 这里是不被缓存的视图组件 -->
            </router-view>
          </el-tab-pane>
        </el-tabs>
 
        <!-- <transition name="fade" mode="out-in">
          <keep-alive>
            <router-view v-if="$route.meta.keepAlive">
           
            </router-view>
          </keep-alive>
        </transition>
        <transition name="fade" mode="out-in">
          <router-view v-if="!$route.meta.keepAlive">
          
          </router-view>
        </transition> -->
      </el-main>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      nav: [
         { id: "/daytask", icon: "el-icon-setting", title: "当日任务" },
          { id: "/task", icon: "el-icon-setting", title: "任务列表" },
          { id: "/PersonalCenter", icon: "el-icon-setting", title: "个人中心" },
       
        
      ],
      
      input1: "",
      circleUrl:
        "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
    };
  },
 
  computed: {
    options() {
      return this.$store.state.options;
    },
    activeIndex: {
      get() {
        return this.$store.state.activeIndex;
      },
      set(val) {
        this.$store.commit("set_active_index", val);
      },
    },
  },
  watch: {
    $route(to) {
      let flag = false;
      for (let option of this.options) {
        if (option.route === to.path) {
          flag = true;
          this.$store.commit("set_active_index", to.path);
          break;
        }
      }
      if (!flag) {
        this.$store.commit("add_tabs", { route: to.path, name: to.name });
        this.$store.commit("set_active_index", to.path);
      }
    },
  },
  methods: {
    logout() {
  
        this.$axios.post("/api/Account/LogoutApi").then(res=>{
            if(res.data.IsSuccess){
              this.$message({message:res.data.Content,type:'success'});
              window.sessionStorage.removeItem('token');
              window.sessionStorage.removeItem('user');
               this.$router.push("/");
            }
        }).catch(err=>{
            console.log(err);
        })
    },
    goHome(){
        this.$router.push("/");
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    // tab切换时,动态的切换路由
    tabClick(tab) {
      let path = this.activeIndex;
   
      this.$router.replace({ path: path });
    },
    tabRemove(targetName) {
      // 首页不可删除
      if (targetName == "/order") {
        return;
      }
      this.$store.commit("delete_tabs", targetName);
      if (this.activeIndex === targetName) {
        // 设置当前激活的路由
        if (this.options && this.options.length >= 1) {
          this.$store.commit(
            "set_active_index",
            this.options[this.options.length - 1].route
          );
          this.$router.replace({ path: this.activeIndex });
        } else {
          this.$router.replace({ path: "/order" });
        }
      }
    },
  },
};
</script>
<style lang="less" scoped>
.el-header,
.el-footer {
  background-color: #f59b24;
  color: #fff;
  height: 49px !important;
  // text-align: center;
  //   line-height: 60px;
}
.left{
  // padding-left: 88px;
  overflow: hidden;
}
.left,
.top,
.right {
  display: flex;
  align-items: center;
}
.top {
  justify-content: space-between;
  height: 49px  !important;
  box-sizing: border-box;
}
.top i {
  font-size: 25px;
  color: #fff;
}
.menu-show {
  display: flex;
  align-items: center;
}
.menu-show span {
  margin-right: 13px;
  font-size: 25px;
  margin-left: 50px;
}
.right-msg {
  padding: 0 20px;
}
.right-msg {
  /deep/.el-badge__content.is-fixed {
    transform: translateY(-36%) translateX(80%);
  }
}
.right-avtar .avtar-quit {
  display: flex;
  align-items: center;
  color: #fff;
}
.el-main{
    padding: 0px;
}
.serch{
  /deep/.el-input{
    width: 255px;
  }
  /deep/.el-input__inner{
      height: 27px;
      line-height: 27px;
  }
  /deep/.el-input__icon{
    line-height: 27px;
  }
 
}
@media screen and(max-width:1299px) {
  .menu-show .menu-title{
    display: none;
  }
  .menu-show span {
  margin-right: 0px;
  margin-left: 0px;
  }
  .left{
  padding-left: 0px;
  }
  .menu-show{
    display: block;
  }
}
 
</style>