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, params: params,
}); });
}, },
getBranchChange(id: PageQuery) {
return request<any, ShopInfoEditDTO[]>({
url: `${baseURL}/change/${id}`,
method: "post",
});
},
add(data: ShopInfoEditDTO) { add(data: ShopInfoEditDTO) {
return request<any, ShopInfoEditDTO>({ return request<any, ShopInfoEditDTO>({
url: `${baseURL}`, url: `${baseURL}`,

View File

@ -5,18 +5,16 @@
<img :src="state.userInfo.logo" class="w20px h20px" /> <img :src="state.userInfo.logo" class="w20px h20px" />
<!-- <span v-if="!collapse" class="title">{{ userStore.userInfo.shopName }}</span> --> <!-- <span v-if="!collapse" class="title">{{ userStore.userInfo.shopName }}</span> -->
<el-dropdown trigger="click" @command="handleCommand"> <el-dropdown trigger="click" @command="handleCommand">
<span class="el-dropdown-link"> <div class="el-dropdown-link" style="display: flex;">
<span v-if="!collapse" class="title">{{ state.shopName }}</span> <div v-if="!collapse" class="title">{{ state.shopName }}</div>
<el-icon class="el-icon--right"> <el-icon class="el-icon--right">
<arrow-down /> <arrow-down />
</el-icon> </el-icon>
</span> </div>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item <el-dropdown-item :command="item.shopId" v-for="(item, index) in state.branchList" :key="index"> {{
:command="item.shopId" item.shopName }}</el-dropdown-item>
v-for="(item,index) in state.branchList" :key="index"
> {{ item.shopName }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
@ -43,22 +41,24 @@ onMounted(() => {
async function geiShopList() { async function geiShopList() {
let res = await ShopApi.getBranchList() let res = await ShopApi.getBranchList()
state.branchList = res; state.branchList = res;
if ( !localStorage.getItem("shopName") ) { if (!localStorage.getItem("shopName")) {
state.shopName = state.branchList[0].shopName state.shopName = state.branchList[0].shopName
// localStorage.setItem("shopId", state.branchList[0].shopId ) localStorage.setItem("branch_shopId", data.shopInfo.id)
localStorage.setItem("shopName", state.branchList[0].shopName ) localStorage.setItem("shopName", state.branchList[0].shopName)
} else { } else {
state.shopName = localStorage.getItem("shopName") state.shopName = localStorage.getItem("shopName")
} }
} }
function handleCommand(command) { async function handleCommand(command) {
console.log(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("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 state.shopName = res.shopName
location.reload()
console.log(res) console.log(res)
console.log(command) console.log(command)
} }
@ -87,7 +87,7 @@ defineProps({
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; 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) => { return new Promise<void>((resolve, reject) => {
AuthAPI.login(loginRequest) AuthAPI.login(loginRequest)
.then((data) => { .then((data) => {
isShopAdmin.value = data.loginType == 0 ? true : false; isShopAdmin.value = data.loginType == 0 ? true : false;
Object.assign(userInfo.value, { ...data.shopInfo, shopId: data.shopInfo.id }); Object.assign(userInfo.value, { ...data.shopInfo, shopId: data.shopInfo.id });
promissionList.value = data.promissionList; promissionList.value = data.promissionList;
const token = data.tokenInfo.tokenValue; const token = data.tokenInfo.tokenValue;
setToken(token); setToken(token);
setRefreshToken(token); setRefreshToken(token);
localStorage.setItem("shopId", "" + data.shopInfo.id);
localStorage.setItem("branch_shopId",data.shopInfo.id)
resolve(); resolve();
}) })
.catch((error) => { .catch((error) => {
@ -59,6 +60,7 @@ export const useUserStore = defineStore("user", () => {
reject("Verification failed, please Login again."); reject("Verification failed, please Login again.");
return; return;
} }
console.log(userInfo)
localStorage.setItem("shopId", "" + userInfo.value.shopId); localStorage.setItem("shopId", "" + userInfo.value.shopId);
Object.assign(userInfo.value, { ...data, roles: [], promissionList: [], shopId: userInfo.value.shopId }); Object.assign(userInfo.value, { ...data, roles: [], promissionList: [], shopId: userInfo.value.shopId });
resolve(userInfo.value); resolve(userInfo.value);

View File

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

View File

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

View File

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