切换店铺

This commit is contained in:
duan 2024-11-22 16:52:24 +08:00
parent c94acd899a
commit a7a9c42126
4 changed files with 106 additions and 3 deletions

View File

@ -15,12 +15,27 @@ export function getInfo() {
});
}
export function changChildShop(data) {
return request({
url: "/api/tbShopInfo/changChildShop",
method: "post",
data
});
}
export function getCodeImg(header) {
return request({
url: "auth/code",
method: "get"
});
}
export function getqueryChildShop(params) {
return request({
url: "api/tbShopInfo/queryChildShop",
method: "get",
params
});
}
export function logout() {
return request({

View File

@ -7,9 +7,40 @@
<i class="el-icon-arrow-down icon"></i>
</div>
<div v-else key="expand" class="sidebar-logo-link">
<img v-if="logo" :src="logo || Avatar" class="sidebar-logo">
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
<div class="avatar-wrapper">
<img :src="logo || Avatar" class="sidebar-logo">
<span class="shop_name">{{ shopName }}</span>
<i class="el-icon-arrow-down icon"></i>
</div>
<el-dropdown-menu slot="dropdown">
<!-- <span style="display:block;" @click="show = true">
<el-dropdown-item>
布局设置
</el-dropdown-item>
</span>
<router-link to="/shop/shop/shop_configuration">
<el-dropdown-item>
店铺配置
</el-dropdown-item>
</router-link>-->
<span v-for="(item, index) in list" :key="index">
<el-dropdown-item :disabled="item.tubeType==0">
<div style="display: flex;align-items: center;" @click="switchshopName(item.id)">
<i class="el-icon-check" style="color: #46a6ff;" v-if="item.id == shopId"></i>
<div v-if="mainId == item.id" style="line-height: 20px;text-align: center;">()</div>
{{ item.shopName }}
</div>
</el-dropdown-item>
</span>
</el-dropdown-menu>
</el-dropdown>
<!-- <img v-if="logo" :src="logo || Avatar" class="sidebar-logo">
<h1 class="sidebar-title">{{ shopName }} </h1>
<i class="el-icon-arrow-down icon"></i>
<i class="el-icon-arrow-down icon"></i> -->
</div>
</transition>
</div>
@ -17,6 +48,9 @@
<script>
import Avatar from '@/assets/images/avatar.png'
import { getqueryChildShop, changChildShop } from '@/api/login.js'
import { setToken } from "@/utils/auth";
export default {
name: 'SidebarLogo',
props: {
@ -30,6 +64,32 @@ export default {
shopName: localStorage.getItem('shopName'),
Avatar,
logo: localStorage.getItem('logo'),
list: [],
mainId: localStorage.getItem("mainId"),
shopId: localStorage.getItem("shopId"),
}
},
mounted() {
this.getlist()
},
methods: {
async getlist() {
const res = await getqueryChildShop({
id: this.mainId
})
this.list = res
},
async switchshopName(id) {
const res = await changChildShop({
id
})
localStorage.setItem("shopId", res.shopId);
localStorage.setItem("logo", res.logo);
localStorage.setItem("loginType", res.loginType);
localStorage.setItem("mainId", res.mainId);
localStorage.setItem("shopName", res.shopName);
setToken(res.token);
location.reload();
}
}
}
@ -96,4 +156,32 @@ h1 {
}
}
}
.avatar-container {
display: flex;
align-items: center;
.avatar-wrapper {
position: relative;
display: flex;
align-items: center;
.user-avatar {
cursor: pointer;
width: 40px;
height: 40px;
border-radius: 50%;
}
.el-icon-caret-bottom {
font-size: 12px;
margin-left: 6px;
}
.shop_name {
font-size: 16px;
// margin-left: 10px;
}
}
}
</style>

View File

@ -43,6 +43,7 @@ const user = {
localStorage.setItem("logo", res.logo);
localStorage.setItem("loginType", res.loginType);
localStorage.setItem("userInfo", JSON.stringify(res.user.user));
localStorage.setItem("mainId", res.mainId);
setToken(res.token, rememberMe);
commit("SET_TOKEN", res.token);
setUserInfo(res.user, commit);

View File

@ -179,7 +179,6 @@ export default {
this.$store.dispatch('Login', user).then(() => {
this.loading = false
//
localStorage.setItem('MerchantId', JSON.stringify({
merchantName: this.loginForm.merchantName,
username: this.loginForm.username,