This commit is contained in:
GaoHao 2025-04-08 17:49:23 +08:00
commit 1cc9949cd8
6 changed files with 38 additions and 62 deletions

View File

@ -17,6 +17,12 @@ const ShopApi = {
params: params,
});
},
getBranchChange(id: PageQuery) {
return request<any, ShopInfoEditDTO[]>({
url: `${baseURL}/change/${id}`,
method: "post",
});
},
add(data: ShopInfoEditDTO) {
return request<any, ShopInfoEditDTO>({
url: `${baseURL}`,

View File

@ -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;
}
}

View File

@ -31,13 +31,14 @@ export const useUserStore = defineStore("user", () => {
return new Promise<void>((resolve, reject) => {
AuthAPI.login(loginRequest)
.then((data) => {
isShopAdmin.value = data.loginType == 0 ? true : false;
Object.assign(userInfo.value, { ...data.shopInfo, shopId: data.shopInfo.id });
promissionList.value = data.promissionList;
const token = data.tokenInfo.tokenValue;
setToken(token);
setRefreshToken(token);
localStorage.setItem("shopId", "" + data.shopInfo.id);
localStorage.setItem("branch_shopId",data.shopInfo.id)
resolve();
})
.catch((error) => {
@ -59,6 +60,7 @@ export const useUserStore = defineStore("user", () => {
reject("Verification failed, please Login again.");
return;
}
console.log(userInfo)
localStorage.setItem("shopId", "" + userInfo.value.shopId);
Object.assign(userInfo.value, { ...data, roles: [], promissionList: [], shopId: userInfo.value.shopId });
resolve(userInfo.value);

View File

@ -22,8 +22,8 @@ service.interceptors.request.use(
} else {
delete config.headers.token;
}
config.headers.shopId = config.headers.shopId || localStorage.getItem("shopId");
// config.headers.shopId = config.headers.shopId || useUserStoreHook().userInfo.id;
// config.headers.shopId = config.headers.shopId || localStorage.getItem("branch_shopId");
config.headers.shopId = config.headers.shopId || useUserStoreHook().userInfo.id;
return config;
},
(error) => Promise.reject(error)

View File

@ -1,13 +1,7 @@
<template>
<div class="login" :style="'background-image:url(' + Background + ');'">
<el-form
ref="loginForm"
:model="state.loginForm"
:rules="state.loginRules"
label-position="left"
label-width="0px"
class="login-form"
>
<el-form ref="loginForm" :model="state.loginForm" :rules="state.loginRules" label-position="left" label-width="0px"
class="login-form">
<h3 class="title">银收客后台管理</h3>
<el-form-item>
<el-radio-group v-model="state.loginForm.loginType">
@ -16,39 +10,19 @@
</el-radio-group>
</el-form-item>
<el-form-item prop="username">
<el-input
v-model="state.loginForm.username"
type="text"
auto-complete="off"
placeholder="商户号"
></el-input>
<el-input v-model="state.loginForm.username" type="text" auto-complete="off" placeholder="商户号"></el-input>
</el-form-item>
<el-form-item prop="staffUserName" v-if="state.loginForm.loginType == 1">
<el-input
v-model="state.loginForm.staffUserName"
type="text"
auto-complete="off"
placeholder="账号"
></el-input>
<el-input v-model="state.loginForm.staffUserName" type="text" auto-complete="off" placeholder="账号"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="state.loginForm.password"
type="password"
auto-complete="off"
placeholder="密码"
@keyup.enter="handleLogin"
></el-input>
<el-input v-model="state.loginForm.password" type="password" auto-complete="off" placeholder="密码"
@keyup.enter="handleLogin"></el-input>
</el-form-item>
<el-form-item prop="code">
<div class="code_wrap">
<el-input
v-model="state.loginForm.code"
auto-complete="off"
placeholder="验证码"
style="width: 63%"
@keyup.enter="handleLogin"
></el-input>
<el-input v-model="state.loginForm.code" auto-complete="off" placeholder="验证码" style="width: 63%"
@keyup.enter="handleLogin"></el-input>
<div class="login-code">
<img :src="state.codeUrl" @click="getCode" />
</div>
@ -56,13 +30,8 @@
</el-form-item>
<el-form-item style="width: 100%">
<el-button
:loading="state.loading"
size="default"
type="primary"
style="width: 100%"
@click.prevent="handleLogin"
>
<el-button :loading="state.loading" size="default" type="primary" style="width: 100%"
@click.prevent="handleLogin">
<span v-if="!state.loading"> </span>
<span v-else> 中...</span>
</el-button>
@ -198,13 +167,12 @@ function handleLogin() {
loginName: userStore.userInfo.phone,
token,
}).then((checkInfo) => {
console.log("checkInfo", checkInfo.userInfo);
console.log("checkInfo", checkInfo);
userStore.meituan_douyin_info = checkInfo.userInfo;
setDouyinToken(checkInfo.userInfo.token);
});
localStorage.removeItem("shopName")
await userStore.getUserInfo();
const { path, queryParams } = parseRedirect();
console.log(path, queryParams);

View File

@ -379,7 +379,7 @@ function show(obj,type) {
state.form = { ...obj };
}
if (obj && obj.mainId) {
state.form = { ...obj };
Object.assign(state.form, obj);
}
if( type ){
state.type = type