From 19e4c8bf086f0b154f3eb705a56ea98f281970bc Mon Sep 17 00:00:00 2001
From: Sun_sun <469361609@qq.com>
Date: Thu, 23 Oct 2025 17:25:39 +0800
Subject: [PATCH] =?UTF-8?q?2025-10-24=20=E8=B4=AD=E7=89=A9=E8=BD=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/mall.js | 11 +-
pages.json | 36 +++--
pages/home/mallDetail.vue | 2 +-
pages/home/pay.vue | 15 --
pages/my/car.vue | 285 ++++++++++++++++++++++++++++++++++++--
static/icon/delete.png | Bin 0 -> 673 bytes
util/api.js | 4 +
7 files changed, 302 insertions(+), 51 deletions(-)
create mode 100644 static/icon/delete.png
diff --git a/api/mall.js b/api/mall.js
index d612d68..60f5a1d 100644
--- a/api/mall.js
+++ b/api/mall.js
@@ -9,11 +9,16 @@ export const mallAPI = {
getCategory: () => http.get(baseUrl + '/api/category'),
getMallDetail: (id) => http.get(baseUrl + '/api/products/' + id),
getRecommended: (id) => http.get(baseUrl + `/api/products/${id}/recommended`), // 推荐商品
- addCart: (data) => http.post(baseUrl +"/api/cart/add", data), // 添加购物车
- createOrder: (data) => http.post(baseUrl + `/api/orders/create-from-cart`,data), // 创建订单
+ createOrder: (data) => http.post(baseUrl + `/api/orders/create-from-cart`, data), // 创建订单
getOrder: (orderId) => http.get(baseUrl + `/api/orders/pending-payment/${orderId}`), // 获取订单
payment: (data) => http.post(baseUrl + "/api/orders/confirm-payment", data), // 支付订单
- getCouponList: (uid) => http.get(baseUrl + `/api/coupon/user/${uid}`)
+ getCouponList: (uid) => http.get(baseUrl + `/api/coupon/user/${uid}`), // 获取优惠券列表
+
+ // 购物车
+ getCartList: () => http.get(baseUrl + "/api/cart"), // 获取购物车列表
+ addCart: (data) => http.post(baseUrl + "/api/cart/add", data), // 添加购物车
+ editCartQuantity: (item) => http.put(baseUrl + `/api/cart/${item.id}`, {quantity: item.quantity}), // 修改数量
+ deleteCart: (id) => http.delete(baseUrl + `/api/cart/${id}`), // 删除
}
export default {
diff --git a/pages.json b/pages.json
index f65ae3e..162ab45 100644
--- a/pages.json
+++ b/pages.json
@@ -138,41 +138,37 @@
}
},
{
- "path" : "pages/home/pay",
- "style" :
- {
- "navigationBarTitleText" : "确认订单",
+ "path": "pages/home/pay",
+ "style": {
+ "navigationBarTitleText": "确认订单",
"backgroundColor": "#E4ECFF",
"enablePullDownRefresh": true
}
},
{
- "path" : "pages/my/order",
- "style" :
- {
- "navigationBarTitleText" : "我的订单"
+ "path": "pages/my/order",
+ "style": {
+ "navigationBarTitleText": "我的订单"
}
},
{
- "path" : "pages/home/mallSearch",
- "style" :
- {
- "navigationBarTitleText" : "搜索商品",
+ "path": "pages/home/mallSearch",
+ "style": {
+ "navigationBarTitleText": "搜索商品",
"navigationStyle": "custom"
}
},
{
- "path" : "pages/my/getCoupons",
- "style" :
- {
- "navigationBarTitleText" : "领券中心"
+ "path": "pages/my/getCoupons",
+ "style": {
+ "navigationBarTitleText": "领券中心"
}
},
{
- "path" : "pages/my/car",
- "style" :
- {
- "navigationBarTitleText" : "购物车"
+ "path": "pages/my/car",
+ "style": {
+ "navigationBarTitleText": "购物车",
+ "navigationStyle": "custom"
}
}
],
diff --git a/pages/home/mallDetail.vue b/pages/home/mallDetail.vue
index 9a2d60c..a93e8d1 100644
--- a/pages/home/mallDetail.vue
+++ b/pages/home/mallDetail.vue
@@ -351,7 +351,7 @@
if (res.success) {
msgRef.value.show({
title: '已加入购物车',
- type: 'error'
+ type: 'success'
})
} else {
msgRef.value.show({
diff --git a/pages/home/pay.vue b/pages/home/pay.vue
index 2d9cd87..7b851e3 100644
--- a/pages/home/pay.vue
+++ b/pages/home/pay.vue
@@ -174,20 +174,6 @@
uni.navigateBack();
}
- const instance = getCurrentInstance();
- const scrollHeight = ref(0)
- const loadHeight = () => {
- uni.getSystemInfo({
- success(res) {
- let screenHeight = res.screenHeight
- uni.createSelectorQuery().in(instance.proxy).select("#boxBottom").boundingClientRect((
- data) => {
- scrollHeight.value = screenHeight - data.height
- }).exec()
- }
- })
- }
-
// 收获地址
const showSelectAddress = ref(false)
const addressOptions = ref([])
@@ -487,7 +473,6 @@
})
onMounted(() => {
- loadHeight()
userId.value = uni.getStorageSync("user").id
loadData()
loadCoupon()
diff --git a/pages/my/car.vue b/pages/my/car.vue
index 8183fd0..e4c0502 100644
--- a/pages/my/car.vue
+++ b/pages/my/car.vue
@@ -1,22 +1,283 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.product.name}}
+
+
+ {{item.product.rongdou_price}}
+
+
+
+ {{item.product.points_price}}
+
+
+
+
+
+
+
+ x{{item.quantity}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 全选
+
+ 合计:豆{{rongdou}} 分{{point}}
+ {{isManage?'删除':'结算'}}
+
+
+
+
+
+
+
-
-
+ .right-menu {
+ display: flex;
+ margin-right: 24rpx;
+ font-family: Work Sans;
+ font-weight: 500;
+ font-style: Medium;
+ font-size: 32rpx;
+ leading-trim: NONE;
+ line-height: 100%;
+ letter-spacing: -2%;
+
+ .del-text {
+ color: red;
+ }
+
+ .add-text {
+ color: #305DEF;
+ }
+ }
+
+ .cart-list {
+ .cart-item {
+ display: flex;
+ background: #E3ECFF;
+ padding: 20rpx;
+ margin-bottom: 10rpx;
+
+ .left {
+ display: flex;
+ justify-content: center;
+ }
+
+ .right {
+ flex: 1;
+ margin-left: 20rpx;
+
+ .icon {
+ width: 30rpx;
+ height: 30rpx;
+ }
+ }
+ }
+
+ .box-div {
+ padding: 60rpx 0;
+ }
+ }
+
+
+ .box-bottom {
+ width: 100%;
+ padding: 20rpx 40rpx;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ position: absolute;
+ bottom: 0;
+ background: #F5F8FF;
+
+ .right {
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+ }
+ }
+ }
+
\ No newline at end of file
diff --git a/static/icon/delete.png b/static/icon/delete.png
new file mode 100644
index 0000000000000000000000000000000000000000..e45f6fb08bcefa714d2792ade2e74381d22e0b6d
GIT binary patch
literal 673
zcmV;S0$%-zP)
zc8+yW^xP{{qnA5>p`Wk0E}(fj$al&qG>^m`qdGm9(=Ba{)c?u2Xzs=TOmPHhcvTN#
zGO2f02gK@)Kun)vUsjhx{b
z47euVOOI{*VmGS|X%joy@pQppIdibanysVpVlIt9E{#AgjX*A3fs=qJ0V_Dt!4sI^
zJUzZptoxMJ+qT>w$X}phX9ld@jEsxvFqoU~0F9GysVp$R-&;5(4yK=jwk^^i
zdPJ-O`aYPbj>=~xh3XI8^`)U?x*P6dx%d>)Zt5D#O&qBd#8SR*DKe>9>g}ZhRUVJB
zqR=OM>LarW6*8`svjyJ4rw3zg|1BzEb=FEK;n<^mW*e00000NkvXX
Hu0mjfp&Kdj
literal 0
HcmV?d00001
diff --git a/util/api.js b/util/api.js
index 52c2491..e713970 100644
--- a/util/api.js
+++ b/util/api.js
@@ -208,6 +208,10 @@ const handleError = (errorInfo) => {
})
// uToast.warning(data.message || '您的账户尚未激活,请完成支付后再使用')
}
+ } else if (!data.success) {
+ uni.redirectTo({
+ url: '/pages/login/login'
+ })
} else {
// uToast.error(data.message || '权限不足')
uni.showToast({