From 591ed8b5d3a204725140be62e89d1124b674db77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8B=BE=E5=A3=B9?= <10942926+linzh1@user.noreply.gitee.com> Date: Wed, 20 Sep 2023 17:09:04 +0800 Subject: [PATCH] lzh --- src/request/api.js | 13 ++- src/router/index.js | 5 +- src/store/modules/userInfos.js | 7 +- src/views/Detail.vue | 24 +++++- src/views/Order.vue | 1 + src/views/User.vue | 148 ++++++++++++++++++++++++++++++--- 6 files changed, 183 insertions(+), 15 deletions(-) diff --git a/src/request/api.js b/src/request/api.js index 10a81fb..66f5e22 100644 --- a/src/request/api.js +++ b/src/request/api.js @@ -28,4 +28,15 @@ export const phoneReginAPI = (data) => request( ) // 获取用户信息 // /shop/userProfiles -export const userProfilesAPI = () =>request.get("/shop/userProfiles") \ No newline at end of file +export const userProfilesAPI = () =>request.get("/shop/userProfiles") + +export const cartAddAPI = (data) => request( + { + method:'POST', + url:'/shop/carts/add', + data, + headers:{ + 'Content-Type': 'application/x-www-form-urlencoded' + } + } + ) \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 4f9adbd..86c37bc 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -15,7 +15,10 @@ component:()=>import("../views/Goods.vue") }, { path:"/user", -component:()=>import("../views/User.vue") +component:()=>import("../views/User.vue"), +children:[ + { path:"cart",component: () => import('../components/user/Cart.vue')} + ] }, { path:"/order", diff --git a/src/store/modules/userInfos.js b/src/store/modules/userInfos.js index 7aff794..1cc22bd 100644 --- a/src/store/modules/userInfos.js +++ b/src/store/modules/userInfos.js @@ -15,6 +15,7 @@ export const userInfos = defineStore('userInfos', { } } }, + getters: { initUserInfo(state) { return state.userInfo = { @@ -22,7 +23,11 @@ export const userInfos = defineStore('userInfos', { coin: 0, headImg } - } + }, + + initCartTotal(state){ + return (val) => state.cartTotal = val; + }, }, actions: { // 修改用户信息 diff --git a/src/views/Detail.vue b/src/views/Detail.vue index c392c24..6fe6bf5 100644 --- a/src/views/Detail.vue +++ b/src/views/Detail.vue @@ -49,7 +49,7 @@