| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <div class="flex">
- <div class="flex-align-center">
- <el-popover
- placement="top"
- width="400">
- <div class="app-flex flex-between">
- <p class="appLink" v-for="app in menuApp" :key="app.index">{{app.systemappname}}</p>
- </div>
- <div slot="reference" class="search_panel">
- <input placeholder="输入搜索内容"/>
- <i class="el-icon-search"></i>
- </div>
- </el-popover>
-
- <div class="weather">
- <p>今日天气:{{weather.daily?weather.daily[0].dayText:""}}</p>
- <p>{{weather.daily?weather.daily[0].low:""}}℃~{{weather.daily?weather.daily[0].high:""}}℃</p>
- </div>
- </div>
- <div class="right-operation">
- <el-dropdown>
- <span class="el-dropdown-link">
- <div class="flex">
- {{siteinfo.enterprisename}}<i class="el-icon-arrow-down el-icon--right"></i>
- </div>
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item @click.native="$router.replace({path:'/user_center'})">个人中心</el-dropdown-item>
- <el-dropdown-item v-if="canChangeSite" @click.native="$router.replace({path:'/accounts'})">切换账号</el-dropdown-item>
- <el-dropdown-item divided @click.native="loginOut()">退出登录</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- </template>
- <script>
- import {mapGetters} from 'vuex'
- import axios from 'axios'
- export default {
- data () {
- return {
- accountInfo:{},
- url:"http://weather.cma.cn/api/weather/view?stationid=",
- weather:{}
- }
- },
- computed:{
- ...mapGetters({
- siteinfo:'siteinfo',
- menuApp:'menuApp'
- }),
- canChangeSite () {
- let accounts = JSON.parse(sessionStorage.getItem('account_list'))
- if (accounts.length > 1) return true
- }
- },
- methods:{
- async getWeather () {
- const res = await axios.get(this.url)
- console.log(res)
- this.weather = res.data.data
- },
- siteInfos () {
- this.$store.dispatch('querySiteInfo',{
- "classname": "webmanage.site.site",
- "method": "querySite",
- "content": {}
- })
- },
- loginOut () {
- this.$confirm('是否要退出当前账号?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$router.push('/')
- sessionStorage.clear()
- // location.reload(true);
- }).catch((err) => {
- console.log(err)
- this.$message({
- type: 'info',
- message: '已取消'
- });
- });
-
- },
- changeAccount () {
- this.$router.push('/accounts')
- }
- },
- mounted () {
- this.siteInfos()
- this.getWeather()
- this.accountInfo = JSON.parse(sessionStorage.getItem('active_account'))
- },
- }
- </script>
- <style>
- .el-header{
- height: 50px !important;
- }
- .search_panel{
- position: relative;
- }
- .search_panel i{
- position: absolute;
- right:0px;
- height: 30px;
- width: 30px;
- text-align: center;
- line-height: 30px;
- color:#333
- }
- .search_panel input{
- background: none;
- height: 30px;
- line-height: 30px;
- width: 400px;
- padding: 0 30px 0 10px;
- border: 1px solid #f1f2f3;
- border-radius: 5px;
- outline: none;
- }
- .search_panel input::placeholder{
- color:#fff;
- }
- .search_panel input:focus{
- background: #fff;
- }
- .search_panel input:focus::placeholder{
- color:#333;
- }
- </style>
- <style scoped>
- .flex{
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: none;
- color:#fff
- }
- .logo{
- }
- .right-operation{
- padding: 0 20px;
- }
- .search_panel{
- margin: 16px 0;
- }
- .weather{
- font-size: 14px;
- margin-left:16px;
- color:#f1f2f3
- }
- .appLink{
- padding:2px 5px;
- border:1px solid #f1f2f3;
- border-radius: 5px;
- margin-bottom: 10px;
- cursor: pointer;
- }
- .app-flex{
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- font-size: 12px;
- }
- </style>
|