优化登录页面
This commit is contained in:
@@ -40,3 +40,15 @@ export function logout(data) {
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺详情
|
||||||
|
* @param {*}
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function shopInfoDetail() {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: `${BASE_URL}/shopInfo/detail`
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// 导入 Pinia 的仓库创建函数
|
// 导入 Pinia 的仓库创建函数
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { login as apiLogin, logout as apiLogout } from '@/api/account.js'
|
import { login as apiLogin, logout as apiLogout, shopInfoDetail } from '@/api/account.js'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', {
|
export const useUserStore = defineStore('user', {
|
||||||
@@ -44,13 +44,13 @@ export const useUserStore = defineStore('user', {
|
|||||||
try {
|
try {
|
||||||
await apiLogout()
|
await apiLogout()
|
||||||
// 登出成功后尝试关闭 websocket(若已存在)
|
// 登出成功后尝试关闭 websocket(若已存在)
|
||||||
// try {
|
try {
|
||||||
// const mod = await import('@/stores/socket')
|
const mod = await import('@/stores/socket')
|
||||||
// const socketStore = mod.useSocketStore()
|
const socketStore = mod.useSocketStore()
|
||||||
// socketStore.close()
|
socketStore.close()
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// console.warn('close socket failed', e)
|
console.warn('close socket failed', e)
|
||||||
// }
|
}
|
||||||
|
|
||||||
this.token = ''
|
this.token = ''
|
||||||
this.shopInfo = ''
|
this.shopInfo = ''
|
||||||
@@ -67,6 +67,15 @@ export const useUserStore = defineStore('user', {
|
|||||||
})
|
})
|
||||||
.catch(() => { })
|
.catch(() => { })
|
||||||
},
|
},
|
||||||
|
// 更新店铺信息
|
||||||
|
async updateShopInfo() {
|
||||||
|
try {
|
||||||
|
const res = await shopInfoDetail()
|
||||||
|
this.shopInfo = res
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 核心:开启持久化,确保 Token 保存在 localStorage
|
// 核心:开启持久化,确保 Token 保存在 localStorage
|
||||||
persist: {
|
persist: {
|
||||||
|
|||||||
@@ -48,8 +48,8 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="table_list_wrap" v-if="checkType == 1">
|
<div class="table_list_wrap" v-if="checkType == 1">
|
||||||
<div class="item" :class="{ empty: tableList.length <= 0 }">
|
<div class="item">
|
||||||
<div class="list">
|
<div class="list" :class="{ empty: tableList.length <= 0 }">
|
||||||
<div class="tab_item" :class="{ active: index === selectItemIndex }"
|
<div class="tab_item" :class="{ active: index === selectItemIndex }"
|
||||||
v-for="(item, index) in tableList" :key="item.orderId" @click="changeTableItem(index)">
|
v-for="(item, index) in tableList" :key="item.orderId" @click="changeTableItem(index)">
|
||||||
<div class="tab_header_wrap">
|
<div class="tab_header_wrap">
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
<div class="table_info_wrap">
|
<div class="table_info_wrap">
|
||||||
<el-button type="primary">{{ tableList[selectItemIndex].tableName || '-' }} | {{
|
<el-button type="primary">{{ tableList[selectItemIndex].tableName || '-' }} | {{
|
||||||
tableList[selectItemIndex].areaName || '-'
|
tableList[selectItemIndex].areaName || '-'
|
||||||
}}</el-button>
|
}}</el-button>
|
||||||
<el-text>待出菜({{ tableList[selectItemIndex].pendingDishCount }})</el-text>
|
<el-text>待出菜({{ tableList[selectItemIndex].pendingDishCount }})</el-text>
|
||||||
<el-text>员工名称:{{ tableList[selectItemIndex].staffName || notStaff }}</el-text>
|
<el-text>员工名称:{{ tableList[selectItemIndex].staffName || notStaff }}</el-text>
|
||||||
<el-text>下单时间:{{ tableList[selectItemIndex].orderTime || '-' }}</el-text>
|
<el-text>下单时间:{{ tableList[selectItemIndex].orderTime || '-' }}</el-text>
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<div class="table" v-for="(item, index) in goodsTableData" :key="index">
|
<div class="table" v-for="(item, index) in goodsTableData" :key="index">
|
||||||
<div class="goods_table_title">
|
<div class="goods_table_title">
|
||||||
<span>{{ item.productName }} 待出菜({{ item.total
|
<span>{{ item.productName }} 待出菜({{ item.total
|
||||||
}})</span>
|
}})</span>
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="item.foodItems" border stripe>
|
<el-table :data="item.foodItems" border stripe>
|
||||||
<el-table-column label="下单台桌" prop="areaName">
|
<el-table-column label="下单台桌" prop="areaName">
|
||||||
@@ -174,6 +174,8 @@ import { useScanListener } from '@/composables/useScanListener'
|
|||||||
import { useSocketStore } from "@/stores/socket.js";
|
import { useSocketStore } from "@/stores/socket.js";
|
||||||
import { onUnmounted } from 'vue';
|
import { onUnmounted } from 'vue';
|
||||||
|
|
||||||
|
const userStore = useUserStore()
|
||||||
|
|
||||||
const socketStore = useSocketStore()
|
const socketStore = useSocketStore()
|
||||||
|
|
||||||
const unsub = socketStore.subscribe(msg => {
|
const unsub = socketStore.subscribe(msg => {
|
||||||
@@ -181,10 +183,11 @@ const unsub = socketStore.subscribe(msg => {
|
|||||||
if (msg.type == 'bc') {
|
if (msg.type == 'bc') {
|
||||||
checkTypeHandle({ value: checkType.value })
|
checkTypeHandle({ value: checkType.value })
|
||||||
}
|
}
|
||||||
|
if (msg.type == 'shopInfoUpdate') {
|
||||||
|
userStore.updateShopInfo()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
const notStaff = ref('管理员')
|
const notStaff = ref('管理员')
|
||||||
|
|
||||||
// 扫码获取扫码内容
|
// 扫码获取扫码内容
|
||||||
|
|||||||
Reference in New Issue
Block a user