This commit is contained in:
GaoHao
2025-04-08 11:19:31 +08:00
16 changed files with 396 additions and 148 deletions

View File

@@ -1,34 +1,67 @@
<template>
<div class="logo">
<transition name="el-fade-in-linear" mode="out-in">
<router-link :key="+collapse" class="wh-full flex-center" to="/">
<img :src="userStore.userInfo.logo" class="w20px h20px" />
<!-- <span v-if="!collapse" class="title">{{ userStore.userInfo.shopName }}</span> -->
<el-dropdown trigger="click">
<span class="el-dropdown-link">
<span v-if="!collapse" class="title">{{ userStore.userInfo.shopName }}</span>
<el-icon class="el-icon--right">
<arrow-down />
</el-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>门店 1</el-dropdown-item>
<el-dropdown-item>门店 2</el-dropdown-item>
<el-dropdown-item>门店 3</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</router-link>
</transition>
<div class="logo wh-full flex-center">
<!-- <transition name="el-fade-in-linear" mode="out-in"> -->
<!-- <router-link :key="+collapse" class="wh-full flex-center" to="/"> -->
<img :src="state.userInfo.logo" class="w20px h20px" />
<!-- <span v-if="!collapse" class="title">{{ userStore.userInfo.shopName }}</span> -->
<el-dropdown trigger="click" @command="handleCommand">
<span class="el-dropdown-link">
<span v-if="!collapse" class="title">{{ state.shopName }}</span>
<el-icon class="el-icon--right">
<arrow-down />
</el-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
:command="item.shopId"
v-for="(item,index) in state.branchList" :key="index"
> {{ item.shopName }}</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- </router-link> -->
<!-- </transition> -->
</div>
</template>
<script lang="ts" setup>
<script setup>
import defaultSettings from "@/settings";
import { useUserStore } from "@/store";
import ShopApi from "@/api/account/shop";
const userStore = useUserStore();
const state = reactive({
branchList: [],
userInfo: useUserStore().userInfo,
shopName: useUserStore().userInfo.shopName
});
onMounted(() => {
geiShopList()
});
async function geiShopList() {
let res = await ShopApi.getBranchList()
state.branchList = res;
if ( !localStorage.getItem("shopName") ) {
state.shopName = state.branchList[0].shopName
// localStorage.setItem("shopId", state.branchList[0].shopId )
localStorage.setItem("shopName", state.branchList[0].shopName )
} else {
state.shopName = localStorage.getItem("shopName")
}
}
function handleCommand(command) {
console.log(command)
let res = state.branchList.filter(v=> v.shopId == command)[0]
// localStorage.setItem("shopId", res.shopId )
localStorage.setItem("shopName", res.shopName )
state.shopName = res.shopName
console.log(res)
console.log(command)
}
defineProps({
collapse: {
@@ -43,6 +76,7 @@ defineProps({
width: 100%;
height: $navbar-height;
background-color: $sidebar-logo-background;
cursor: pointer;
.title {
flex-shrink: 0;