[测评系统]--前端(用户答题页面)
yj
2024-05-08 d8fc3ec09f864dc336b649f66a2c62345da12629
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
<template>
  <el-container>
    <el-header height="60" class="student-header header" :style="{'background-color': logo!='none'?'#fff':'#409eff'}">
      <div class="head-language" v-if="langFlag">
        <!--<lang-select class="right-menu-item" />-->
        <!--国际化的语言选择-->
        <!--<component :is="langSelect"></component>-->
      </div>
      <div class="head-user" style="float:left;">
        <el-dropdown trigger="click" placement="bottom">
          <el-image v-if="productType=='API_Fan'" :style="{'max-height': isMobile?'50px':'50px','margin-top':'5px','height':logoHeight+'px'}" :src="require('@/assets/logo-apifan.png')" fit="fill"></el-image>
          <el-image @load="imageLoad" @error="imageError" v-else-if="logo!='none'" :style="{'max-height': isMobile?'50px':'50px','margin-top':'5px','height':logoHeight+'px'}" :src="logo" fit="fill"></el-image>
          <el-badge v-else-if="logo=='none'" style="height: 50px;">
            <el-avatar  class="el-dropdown-avatar" size="medium"  :src="userInfo.imagePath === null ? require('@/assets/logo-t.jpg') : userInfo.imagePath"></el-avatar>
          </el-badge>
          <el-dropdown-menu slot="dropdown">
<!--            <el-dropdown-item divided>保存退出</el-dropdown-item>-->
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
    <el-main class="student-main" style="margin-top:20px;">
      <router-view/>
    </el-main>
    <el-footer height="340" class="student-footer">
    </el-footer>
  </el-container>
</template>
 
<script>
import LangSelect from '@/components/LangSelect'
import { mapMutations, mapState } from 'vuex'
export default {
  name: 'Layout',
  data () {
    return {
      defaultUrl: '/index',
      logoHeight: 50,
      logoUrl: null,
      userInfo: {
        imagePath: null
      },
      langSelect: 'langSelect',
      isMobile: /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obile|ini)/.test(navigator.userAgent)
    }
  },
  created () {
  },
  computed: {
 
  },
  methods: {
    logout: function () {
      window.opener = null
      window.open('about:blank', '_top').close()
    },
    getLogoHeight: function () {
 
    },
    imageLoad: function (e) {
      sessionStorage.setItem('logoUrl', this.logo)
      let that = this
      var img = new Image()
      img.onload = function () {
        that.logoHeight = img.height
        if (that.logoHeight > 50) {
          that.logoHeight = 50
        }
      }
      img.src = that.logo
    },
    imageError: function (e) {
      if (this.logo === null) {
        this.setLogo(sessionStorage.getItem('logoUrl'))
      }
    },
    ...mapMutations('user', ['setLogo'])
  },
  components: {
    'langSelect': LangSelect
  },
  computed: {
    ...mapState('user', { langFlag: state => state.langFlag }),
    ...mapState('user', { logo: state => state.logo }),
    ...mapState('exam', { productType: state => state.productType })
  }
}
</script>
 
<style lang="scss" scoped>
  .header {
    position: fixed;
    width: 100%;
    z-index: 1000;
    top: 0%;
 
  .head-language {
     position: absolute;
     bottom: 10px;
     right: 80px;
    }
  }
</style>