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 @@ - - + .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 0000000..e45f6fb Binary files /dev/null and b/static/icon/delete.png differ 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({