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

View File

@ -129,15 +129,6 @@ export default {
if (currWidth <= 1200) { if (currWidth <= 1200) {
this.sliceNum = 2; 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"); this.domainLogo = localStorage.getItem("icon");
let link = let link =
document.querySelector("link[rel*='icon']") || document.querySelector("link[rel*='icon']") ||
@ -147,10 +138,6 @@ export default {
link.rel = "shortcut icon"; link.rel = "shortcut icon";
document.getElementsByTagName("head")[0].appendChild(link); document.getElementsByTagName("head")[0].appendChild(link);
window.document.title = localStorage.getItem("title") + " - 运营后台"; window.document.title = localStorage.getItem("title") + " - 运营后台";
}
}
// //
getNoticePage({}).then((res) => { getNoticePage({}).then((res) => {
if (res.success) { 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) { handleClickUserDropdown(name) {
// //

View File

@ -1,14 +1,71 @@
<template> <template>
<div> <div>
<Row class="header"> <Row class="header">
<img src="../../assets/logo.png" class="logo" width="220px"> <img :src="domainLogo" class="logo" width="220px" />
</Row> </Row>
</div> </div>
</template> </template>
<script> <script>
import { getBaseSite } from "@/api/common.js";
export default { 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> </script>

View File

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

View File

@ -16,3 +16,9 @@ export const getRegion = (params) => {
export function getIMDetail () { export function getIMDetail () {
return getRequest(`${commonUrl}/common/common/IM`); 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="main">
<div class="sidebar-menu-con menu-bar"> <div class="sidebar-menu-con menu-bar">
<div class="logo-con"> <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> </div>
<shrinkable-menu></shrinkable-menu> <shrinkable-menu></shrinkable-menu>
</div> </div>
<!-- 顶部标题栏主体 --> <!-- 顶部标题栏主体 -->
<div class="main-header-con"> <div class="main-header-con">
<div class="main-header"> <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"> <div class="user-dropdown-menu-con">
<Row type="flex" justify="end" align="middle" class="user-dropdown-innercon"> <Row
<Dropdown transfer trigger="hover" @on-click="handleClickUserDropdown"> type="flex"
justify="end"
align="middle"
class="user-dropdown-innercon"
>
<Dropdown
transfer
trigger="hover"
@on-click="handleClickUserDropdown"
>
<div class="dropList"> <div class="dropList">
<span class="main-user-name">{{ userInfo.storeName }}</span> <span class="main-user-name">{{ userInfo.storeName }}</span>
<Icon type="md-arrow-dropdown" /> <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> </div>
<DropdownMenu slot="list"> <DropdownMenu slot="list">
<DropdownItem name="changePass">修改密码</DropdownItem> <DropdownItem name="changePass">修改密码</DropdownItem>
@ -71,6 +89,7 @@ export default {
sliceNum: 5, // nav sliceNum: 5, // nav
userInfo: {}, // userInfo: {}, //
navType: 1, // nav navType: 1, // nav
storeSideLogo: "", //logo
}; };
}, },
computed: { computed: {
@ -98,6 +117,16 @@ export default {
if (pathArr.length >= 2) { if (pathArr.length >= 2) {
this.$store.commit("addOpenSubmenu", pathArr[1].name); 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")); let userInfo = JSON.parse(Cookies.get("userInfoSeller"));
this.userInfo = userInfo; this.userInfo = userInfo;

View File

@ -1,14 +1,77 @@
<template> <template>
<div> <div>
<Row class="header"> <Row class="header">
<img class="logo" src="@/assets/logo.png" > <img class="logo" :src="storeSideLogo" />
</Row> </Row>
</div> </div>
</template> </template>
<script> <script>
import { getBaseSite } from "@/api/common.js";
export default { export default {
name: "header", 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> </script>