From 334c0800fa4d86a5db1cab230f64fb31f6d6bfda Mon Sep 17 00:00:00 2001 From: bobobobo <1055026847@qq.com> Date: Wed, 24 Dec 2025 22:21:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9F=8E=E5=88=97=E8=A1=A8=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/mall.js | 18 ++++ composables/useAuthUser.js | 16 +++ pages/mall/list.vue | 190 +++++++++++++++++++++++++--------- pages/my-index/my-index.vue | 11 +- pages/news-list/news-list.vue | 7 +- stores/user.js | 21 ++-- utils/request.js | 1 + utils/storage.js | 2 +- 8 files changed, 202 insertions(+), 64 deletions(-) create mode 100644 api/mall.js create mode 100644 composables/useAuthUser.js diff --git a/api/mall.js b/api/mall.js new file mode 100644 index 0000000..70a6e65 --- /dev/null +++ b/api/mall.js @@ -0,0 +1,18 @@ +import http from '@/utils/request' + +/** 分类 */ +export const getCategory = () => { + return http({ + url: '/api/service/productCategory/list', + method: 'get' + }) +} + +/** 商品列表 */ +export const getProductList = data => { + return http({ + url: '/api/service/product/list', + method: 'get', + data + }) +} diff --git a/composables/useAuthUser.js b/composables/useAuthUser.js new file mode 100644 index 0000000..f51432a --- /dev/null +++ b/composables/useAuthUser.js @@ -0,0 +1,16 @@ +import { storeToRefs } from 'pinia' +import { useUserStore } from '@/stores/user' + +/** + * 统一提供响应式的用户信息和相关操作 + */ +export const useAuthUser = () => { + const userStore = useUserStore() + + // 响应式状态(state & getters) + const { userInfo } = storeToRefs(userStore) + + return { + userInfo + } +} diff --git a/pages/mall/list.vue b/pages/mall/list.vue index 714f0ed..018b09a 100644 --- a/pages/mall/list.vue +++ b/pages/mall/list.vue @@ -1,39 +1,65 @@