多门店切换修改
This commit is contained in:
@@ -5,18 +5,16 @@
|
||||
<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>
|
||||
<div class="el-dropdown-link" style="display: flex;">
|
||||
<div v-if="!collapse" class="title">{{ state.shopName }}</div>
|
||||
<el-icon class="el-icon--right">
|
||||
<arrow-down />
|
||||
</el-icon>
|
||||
</span>
|
||||
</div>
|
||||
<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-item :command="item.shopId" v-for="(item, index) in state.branchList" :key="index"> {{
|
||||
item.shopName }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
@@ -43,22 +41,24 @@ onMounted(() => {
|
||||
async function geiShopList() {
|
||||
let res = await ShopApi.getBranchList()
|
||||
state.branchList = res;
|
||||
if ( !localStorage.getItem("shopName") ) {
|
||||
if (!localStorage.getItem("shopName")) {
|
||||
state.shopName = state.branchList[0].shopName
|
||||
// localStorage.setItem("shopId", state.branchList[0].shopId )
|
||||
localStorage.setItem("shopName", state.branchList[0].shopName )
|
||||
localStorage.setItem("branch_shopId", data.shopInfo.id)
|
||||
localStorage.setItem("shopName", state.branchList[0].shopName)
|
||||
} else {
|
||||
state.shopName = localStorage.getItem("shopName")
|
||||
}
|
||||
|
||||
}
|
||||
function handleCommand(command) {
|
||||
async function handleCommand(command) {
|
||||
console.log(command)
|
||||
let res = state.branchList.filter(v=> v.shopId == command)[0]
|
||||
let res = state.branchList.filter(v => v.shopId == command)[0]
|
||||
// localStorage.setItem("shopId", res.shopId )
|
||||
localStorage.setItem("shopName", res.shopName )
|
||||
await ShopApi.getBranchChange(res.shopId)
|
||||
// localStorage.setItem("branch_shopId", res.shopId)
|
||||
localStorage.setItem("shopName", res.shopName)
|
||||
state.shopName = res.shopName
|
||||
|
||||
location.reload()
|
||||
console.log(res)
|
||||
console.log(command)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ defineProps({
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 150px;
|
||||
max-width: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user