拖旺项目:聊城公交辅助决策系统
master
2022-04-28 3f01dc7da4c12311ecb31ad8d5d7224dd27e52e3
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
<template>
    <div class="flex ju-sb header-pos">
        <div class="left-logo flex">
          <img alt="" class="logo-img" src="../../assets/png/logo.png">
        </div>
        <div class="center-tab ju-c flex">
          <dv-decoration-3 style="width:120px;height:20px;" />
            <div class="big-title ml10 mr10">智慧公交辅助决策系统</div>
          <dv-decoration-3 style="width:120px;height:20px;" />
        </div>
        <div class="ls-tab"></div>
        <div class="flex align-c color-white right-date ju-se">
            <div class="div-img">
                <div :style="{backgroundPosition: pos.x + 'px ' + pos.y + 'px'}" class="ear-img"></div>
            </div>
            <div class="flex">
                <span class="nowdata">{{nowDate}}</span>&nbsp;<span>{{nowWeek}}</span>
            </div>
            <div>{{userName}}</div>
            <img @click="outLogin" alt="" class="out-ligon-img" src="../../assets/png/out_login.png">
 
        </div>
    </div>
</template>
<script>
    import maputil from "../../unit/map"
    export default {
        name: 'HomeHeader',
        data() {
            return {
                timer: null,
                nowWeek: '',
                nowDate: '',
                userName: JSON.parse(localStorage.getItem('userInfo')).username,
                nowTime: '',
                pos: {
                    x: 0,
                    y: 0
                }
            }
        },
        created() {},
        computed: {},
        watch: {},
        methods: {
            outLogin() {
                this.$axios.post(this.$Interface.logout).then(res => {
                    localStorage.clear();
                    maputil.hideAllLayer();
                    this.$store.commit("SET_LineName", '411')
                    this.$router.push('login');
                })
            },
            setNowTimes() {
                let myDate = new Date();
                let wk = myDate.getDay();
                let yy = String(myDate.getFullYear());
                let mm = myDate.getMonth() + 1;
                let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate());
                let hou = String(myDate.getHours() < 10 ? '0' + myDate.getHours() : myDate.getHours());
                let min = String(myDate.getMinutes() < 10 ? '0' + myDate.getMinutes() : myDate.getMinutes());
                let sec = String(myDate.getSeconds() < 10 ? '0' + myDate.getSeconds() : myDate.getSeconds());
                let weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
                let week = weeks[wk];
                this.nowDate = yy + '-' + mm + '-' + dd;
                this.nowTime = hou + ':' + min + ':' + sec;
                this.nowWeek = week
            },
            pushItem(index, path) {
                this.$router.push(path);
            },
            getWeather() {
                let that = this;
                fetch("https://restapi.amap.com/v3/weather/weatherInfo?city=440400&key=c27285122eec70b6f5792c4a2970b8c2").then(response => {
                    response.json().then(function (data) {
                        if (data.info == "OK") {
                            switch (data.lives[0].weather) {
                                case "晴":
                                    that.pos.x = 0;
                                    that.pos.y = 0;
                                    break;
                                case "阴转晴":
                                    that.pos.x = -80;
                                    that.pos.y = 0;
                                    break;
                                case "阴":
                                    that.pos.x = -160;
                                    that.pos.y = 0;
                                    break;
                                case "晴间多云":
                                    that.pos.x = -240;
                                    that.pos.y = 0;
                                    break;
                                case "雨":
                                    that.pos.x = 0;
                                    that.pos.y = -80;
                                    break;
                                default:
                                    that.pos.x = 0;
                                    that.pos.y = 0;
                                    break;
                            }
                        }
 
                    });
                })
            }
        },
        mounted() {
            this.getWeather();
            this.setNowTimes()
        },
    }
</script>
<style scoped>
    .header-pos {
        width: 100%;
        position: relative;
        z-index: 111;
        height: 60px;
        line-height: 60px;
        min-width: 1366px;
        background: url("../../assets/newImg/bg_total.png") no-repeat center/cover;
    }
    .left-logo {
        width: 40%;
        align-items: center;
        padding-left: 30px;
    }
    .ls-tab{width:15%;}
 
    .center-tab {
        width: 44%;
        font-size: 22px;
        color: white;
        align-items: center;
    }
 
    .logo-img {
        width: 80px;
    }
    .big-title {
        color: #fff;
        font-size: 22px;
        font-family: 'YouSheBiaoTiHeiT'
    }
    .right-date {
        width: 25%;
    }
    .nowdata {
        font-family: 'Digital';
        font-size: 18px;
    }
    .out-ligon-img {
        width: 18px;
        height: 18px;
        cursor: pointer
    }
    .div-img {
        width: 42px;
        height: 30px;
    }
    .ear-img {
        width: 100%;
        height: 100%;
        background: url("../../assets/newImg/white30.png");
        background-repeat: no-repeat;
        display: block;
    }
</style>