From d8fc3ec09f864dc336b649f66a2c62345da12629 Mon Sep 17 00:00:00 2001
From: yj <2077506045@qq.com>
Date: 星期三, 08 五月 2024 18:02:19 +0800
Subject: [PATCH] 答题LOGO自定义功能
---
src/store/modules/user.js | 4 ++++
src/layout/index.vue | 41 ++++++++++++++++++++++++++++++++++-------
src/views/demography/login.vue | 8 ++++++++
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/src/layout/index.vue b/src/layout/index.vue
index 2e6a7e1..ca5a298 100644
--- a/src/layout/index.vue
+++ b/src/layout/index.vue
@@ -1,21 +1,21 @@
<template>
<el-container>
- <el-header height="60" class="student-header header" :style="{'background-color': productType==='API_Fan'?'#fff':'#409eff'}">
+ <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;">
- <span></span>
<el-dropdown trigger="click" placement="bottom">
- <el-image v-if="productType==='API_Fan'" :style="{'height': isMobile?'50px':'60px','margin-top':'5px'}" :src="require('@/assets/logo-apifan.png')" fit="fill"></el-image>
- <el-badge v-else style="height: 50px;">
+ <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-menu>
</el-dropdown>
</div>
</el-header>
@@ -29,12 +29,14 @@
<script>
import LangSelect from '@/components/LangSelect'
-import { mapState } from 'vuex'
+import { mapMutations, mapState } from 'vuex'
export default {
name: 'Layout',
data () {
return {
defaultUrl: '/index',
+ logoHeight: 50,
+ logoUrl: null,
userInfo: {
imagePath: null
},
@@ -44,17 +46,42 @@
},
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 })
}
}
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index bb42548..9bef01a 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -5,6 +5,7 @@
userName: Cookies.get('studentUserName'),
userInfo: Cookies.get('studentUserInfo'),
imagePath: Cookies.get('studentImagePath'),
+ logo: null,
messageCount: 0,
memberToken: Cookies.get('memberTocken'),
langType: 'English',
@@ -28,6 +29,9 @@
// mutations
const mutations = {
+ setLogo (state, logo) {
+ state.logo = logo
+ },
setUserName (state, userName) {
state.userName = userName
Cookies.set('studentUserName', userName, { expires: 30 })
diff --git a/src/views/demography/login.vue b/src/views/demography/login.vue
index 33851d6..d83388d 100644
--- a/src/views/demography/login.vue
+++ b/src/views/demography/login.vue
@@ -31,6 +31,13 @@
})
// 宸茬粡绛斿畬浜嗕笉鑳界瓟棰�
examPaperApi.selectTokenId(_this.paraMemberToken).then(re => {
+ if (re.response.logoUrl === null || re.response.logoUrl === '') {
+ _this.setLogo('none')
+ } else {
+ _this.setLogo(re.response.logoUrl)
+ }
+ console.log('response')
+ console.log(re.response)
_this.setProductType(re.response.productType)
if (re.response.finish === 1) {
_this.$router.push({ path: '/exam/finish', query: { name: '', content: _this.$t('finishMsg'), tokenId: _this.paraMemberToken } })
@@ -110,6 +117,7 @@
...mapMutations('exam', ['setReportTemplateId']),
...mapMutations('user', ['setLangType']),
...mapMutations('user', ['getLangType']),
+ ...mapMutations('user', ['setLogo']),
...mapMutations('exam', ['setProductType'])
},
--
Gitblit v1.9.1