修改商家logo没有更换的问题

master
mhhhh 2022-06-01 10:13:53 +08:00
parent 21289f5a92
commit 0c0c903529
7 changed files with 184 additions and 63 deletions

View File

@ -14,19 +14,19 @@ export default {
},
methods:{
init(){
if(!localStorage.getItem("siteName")||!localStorage.getItem("logoImg")||!localStorage.getItem("sitelogo_expiration_time")) {
if(!storage.getItem("siteName")||!storage.getItem("logoImg")||!storage.getItem("sitelogo_expiration_time")) {
this.getSite();
}else{
//
if (new Date() > localStorage.getItem("sitelogo_expiration_time")) {
if (new Date() > storage.getItem("sitelogo_expiration_time")) {
this.getSite();
return;
}else{
window.document.title = localStorage.getItem("siteName");
window.document.title = storage.getItem("siteName");
//icon
let link =document.querySelector("link[rel*='icon']") ||document.createElement("link");
link.type = "image/x-icon";
link.href = localStorage.getItem("logoImg");
link.href = storage.getItem("logoImg");
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
}
@ -41,10 +41,10 @@ export default {
//
var expirationTime = new Date().setHours(new Date().getHours() + 1);
//
localStorage.setItem("sitelogo_expiration_time", expirationTime);
storage.setItem("sitelogo_expiration_time", expirationTime);
//
localStorage.setItem('siteName', data.siteName);
localStorage.setItem('logoImg', data.buyerSideLogo);
storage.setItem('siteName', data.siteName);
storage.setItem('logoImg', data.buyerSideLogo);
window.document.title = data.siteName;
//icon

View File

@ -129,28 +129,15 @@ export default {
if (currWidth <= 1200) {
this.sliceNum = 2;
}
if(!localStorage.getItem("icon")||!localStorage.getItem("title")||!localStorage.getItem("icontitle_expiration_time")) {
this.getSite();
}else{
//
if (new Date() > localStorage.getItem("icontitle_expiration_time")) {
this.getSite();
return;
}else{
this.domainLogo = localStorage.getItem("icon");
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = localStorage.getItem("icon");
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
window.document.title = localStorage.getItem("title") + " - 运营后台";
}
}
this.domainLogo = localStorage.getItem("icon");
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = localStorage.getItem("icon");
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
window.document.title = localStorage.getItem("title") + " - 运营后台";
//
getNoticePage({}).then((res) => {
if (res.success) {
@ -160,28 +147,7 @@ export default {
}
});
},
getSite(){
//domainLogo
getBaseSite().then((res) => {
const { domainLogo, siteName } = JSON.parse(res.result.settingValue);
this.domainLogo = domainLogo;
//
var expirationTime = new Date().setHours(new Date().getHours() + 1);
//
localStorage.setItem("icontitle_expiration_time", expirationTime);
//
localStorage.setItem('icon', domainLogo);
localStorage.setItem('title', siteName);
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = domainLogo;
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
window.document.title = siteName + " - 运营后台";
})
},
//
handleClickUserDropdown(name) {
//

View File

@ -1,14 +1,71 @@
<template>
<div>
<Row class="header">
<img src="../../assets/logo.png" class="logo" width="220px">
<img :src="domainLogo" class="logo" width="220px" />
</Row>
</div>
</template>
<script>
import { getBaseSite } from "@/api/common.js";
export default {
data() {
return {
domainLogo: require("@/assets/logo.png"),
};
},
methods: {
init() {
if (
!localStorage.getItem("icon") ||
!localStorage.getItem("title") ||
!localStorage.getItem("icontitle_expiration_time")
) {
this.getSite();
} else {
//
if (new Date() > localStorage.getItem("icontitle_expiration_time")) {
this.getSite();
return;
} else {
this.domainLogo = localStorage.getItem("icon");
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = localStorage.getItem("icon");
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
window.document.title = localStorage.getItem("title") + " - 运营后台";
}
}
},
getSite() {
//domainLogo
getBaseSite().then((res) => {
const { domainLogo, siteName } = JSON.parse(res.result.settingValue);
this.domainLogo = domainLogo;
//
var expirationTime = new Date().setHours(new Date().getHours() + 1);
//
localStorage.setItem("icontitle_expiration_time", expirationTime);
//
localStorage.setItem("icon", domainLogo);
localStorage.setItem("title", siteName);
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = domainLogo;
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
window.document.title = siteName + " - 运营后台";
});
},
},
mounted() {
this.init();
},
};
</script>

View File

@ -25,11 +25,11 @@
<Button @click="onClickImg('buyerSideLogo')"></Button>
</div>
</FormItem>
<FormItem label="商家端Logo" prop="sellerSideLogo">
<FormItem label="商家端Logo" prop="storeSideLogo">
<div class="label-item-upload">
<img v-if="formValidate.sellerSideLogo" class="img" :src="formValidate.sellerSideLogo" />
<img v-if="formValidate.storeSideLogo" class="img" :src="formValidate.storeSideLogo" />
<img v-else class="img" src="../../../../assets/emptyImg.png" alt="">
<Button @click="onClickImg('sellerSideLogo')"></Button>
<Button @click="onClickImg('storeSideLogo')"></Button>
</div>
</FormItem>
@ -72,7 +72,7 @@ export default {
buyerSideLogo: "",
domainLogo: "",
icp: "",
sellerSideLogo: "",
storeSideLogo: "",
siteName: "",
staticPageAddress: "",
staticPageWapAddress: "",

View File

@ -16,3 +16,9 @@ export const getRegion = (params) => {
export function getIMDetail () {
return getRequest(`${commonUrl}/common/common/IM`);
}
//获取图片logo
export function getBaseSite () {
return getRequest(`${commonUrl}/common/common/site`);
}

View File

@ -6,22 +6,40 @@
<div class="main">
<div class="sidebar-menu-con menu-bar">
<div class="logo-con">
<img src="../assets/logo.png" key="max-logo" />
<!-- <img src="../assets/logo.png" key="max-logo" /> -->
<img :src="storeSideLogo" key="max-logo" />
</div>
<shrinkable-menu></shrinkable-menu>
</div>
<!-- 顶部标题栏主体 -->
<div class="main-header-con">
<div class="main-header">
<div :class="{'header-avator-con':navType!=4, 'header-avator-con nav4':navType == 4}">
<div
:class="{
'header-avator-con': navType != 4,
'header-avator-con nav4': navType == 4,
}"
>
<!-- 用户头像 -->
<div class="user-dropdown-menu-con">
<Row type="flex" justify="end" align="middle" class="user-dropdown-innercon">
<Dropdown transfer trigger="hover" @on-click="handleClickUserDropdown">
<Row
type="flex"
justify="end"
align="middle"
class="user-dropdown-innercon"
>
<Dropdown
transfer
trigger="hover"
@on-click="handleClickUserDropdown"
>
<div class="dropList">
<span class="main-user-name">{{ userInfo.storeName }}</span>
<Icon type="md-arrow-dropdown" />
<Avatar :src="userInfo.storeLogo" style="background: #fff;margin-left: 10px;"></Avatar>
<Avatar
:src="userInfo.storeLogo"
style="background: #fff; margin-left: 10px"
></Avatar>
</div>
<DropdownMenu slot="list">
<DropdownItem name="changePass">修改密码</DropdownItem>
@ -71,6 +89,7 @@ export default {
sliceNum: 5, // nav
userInfo: {}, //
navType: 1, // nav
storeSideLogo: "", //logo
};
},
computed: {
@ -98,6 +117,16 @@ export default {
if (pathArr.length >= 2) {
this.$store.commit("addOpenSubmenu", pathArr[1].name);
}
this.storeSideLogo = localStorage.getItem("sellerlogoImg");
window.document.title = localStorage.getItem("sellersiteName");
//icon
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = localStorage.getItem("sellerlogoImg");
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
let userInfo = JSON.parse(Cookies.get("userInfoSeller"));
this.userInfo = userInfo;

View File

@ -1,14 +1,77 @@
<template>
<div>
<Row class="header">
<img class="logo" src="@/assets/logo.png" >
<img class="logo" :src="storeSideLogo" />
</Row>
</div>
</template>
<script>
import { getBaseSite } from "@/api/common.js";
export default {
name: "header",
data(){
return{
storeSideLogo: require('@/assets/logo.png')
}
},
methods: {
init() {
if (
!localStorage.getItem("sellersiteName") ||
!localStorage.getItem("sellerlogoImg") ||
!localStorage.getItem("seller_expiration_time")
) {
this.getSite();
} else {
//
if (new Date() > localStorage.getItem("seller_expiration_time")) {
this.getSite();
return;
} else {
this.storeSideLogo = localStorage.getItem("sellerlogoImg");
window.document.title = localStorage.getItem("sellersiteName");
//icon
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = localStorage.getItem("sellerlogoImg");
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
}
}
},
getSite() {
//
getBaseSite().then((res) => {
if (res.success && res.result.settingValue) {
let data = JSON.parse(res.result.settingValue);
//
var expirationTime = new Date().setHours(new Date().getHours() + 1);
//
localStorage.setItem("seller_expiration_time", expirationTime);
//
localStorage.setItem("sellersiteName", data.siteName);
localStorage.setItem("sellerlogoImg", data.storeSideLogo);
console.log(data,'datadadada')
window.document.title = data.siteName;
//icon
let link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
link.type = "image/x-icon";
link.href = data.storeSideLogo;
link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link);
}
});
},
},
mounted() {
this.init();
},
};
</script>