diff --git a/src/api/auth.ts b/src/api/auth.ts index d15088f..5e56bbe 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -17,4 +17,11 @@ export const login = (params: LoginParams): Promise>> => { + return http.post('/logout') } \ No newline at end of file diff --git a/src/store/auth.ts b/src/store/auth.ts index 760bcaf..0073b8f 100644 --- a/src/store/auth.ts +++ b/src/store/auth.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia' -import { login } from '@/api/auth' +import { login, logout as logoutApi } from '@/api/auth' import type { LoginParams } from '@/types' interface AuthState { @@ -55,15 +55,23 @@ export const useAuthStore = defineStore('auth', { /** * 用户登出 */ - logout() { - this.token = null - this.userInfo = null - this.isAuthenticated = false - - // 清除localStorage中的认证状态 - localStorage.removeItem('isAuthenticated') - - // 注意:这里不清除保存的用户名和密码,以便下次自动填充 + async logout() { + try { + // 调用后端logout接口清除session + await logoutApi() + } catch (error) { + console.warn('服务器退出登录失败,仅清除本地状态:', error) + } finally { + // 清除本地状态 + this.token = null + this.userInfo = null + this.isAuthenticated = false + + // 清除localStorage中的认证状态 + localStorage.removeItem('isAuthenticated') + + // 注意:这里不清除保存的用户名和密码,以便下次自动填充 + } }, /** diff --git a/src/views/Detail/index.vue b/src/views/Detail/index.vue index 86493ba..f3123b0 100644 --- a/src/views/Detail/index.vue +++ b/src/views/Detail/index.vue @@ -188,6 +188,10 @@ 单价 {{ formatAmount(product.price) }} +
+ 折扣 + {{ getProductDiscountRate(product.discount) }} +
税率 @@ -233,6 +237,10 @@ 单价 {{ formatAmount(product.price) }}
+
+ 折扣 + {{ getProductDiscountRate(product.discount) }} +
税率 @@ -278,6 +286,10 @@ 单价 {{ formatAmount(product.price) }}
+
+ 折扣 + {{ getProductDiscountRate(product.discount) }} +
税率 @@ -617,6 +629,9 @@ const getTotalAmount = () => { return total } +const getProductDiscountRate=(discount: number)=>{ + return (discount * 100).toFixed(1) + '%' +} // 获取现金折扣率 const getDiscountRate = () => { if (!currentOrderInfo.value || !currentOrderInfo.value.discountFold) { diff --git a/src/views/List/index.vue b/src/views/List/index.vue index c88c084..1cf3d7f 100644 --- a/src/views/List/index.vue +++ b/src/views/List/index.vue @@ -1,5 +1,23 @@