From 8a2d6949a4525f90e0e75f2f3f83c13b8830a758 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期五, 08 八月 2025 17:37:50 +0800
Subject: [PATCH] 修改商品广场和购物车
---
config/api.js | 16 ++++----
pages/cusbar/cart/cartList.vue | 3 +
pages/commodity-square/commoditySquare.vue | 99 +++++++++++++++++++++++++++++++++++++++----------
3 files changed, 89 insertions(+), 29 deletions(-)
diff --git a/config/api.js b/config/api.js
index 9db28a0..b409e36 100644
--- a/config/api.js
+++ b/config/api.js
@@ -4,10 +4,10 @@
*/
// 寮�鍙戠幆澧�
const dev = {
- im: "http://192.168.0.15:8885",
- common: "http://192.168.0.15:8890",
- buyer: "http://192.168.0.15:8888",
- store: "http://192.168.0.15:8889",
+ // im: "http://192.168.0.15:8885",
+ // common: "http://192.168.0.15:8890",
+ // buyer: "http://192.168.0.15:8888",
+ // store: "http://192.168.0.15:8889",
// im: "http://127.0.0.1:8885",
// common: "http://127.0.0.1:8890",
@@ -17,10 +17,10 @@
// common: "http://192.168.0.113:8890",
// buyer: "http://192.168.0.113:8888",
// im: "http://192.168.0.113:8885",
- // im: "https://myk.9village.cn",
- // common: "https://myk.9village.cn",
- // buyer: "https://myk.9village.cn",
- // store: "https://myk.9village.cn",
+ im: "https://myk.9village.cn",
+ common: "https://myk.9village.cn",
+ buyer: "https://myk.9village.cn",
+ store: "https://myk.9village.cn",
// im: "https://www.meiyikuang.com/mykapi",
// common: "https://www.meiyikuang.com/mykapi",
// buyer: "https://www.meiyikuang.com/mykapi",
diff --git a/pages/commodity-square/commoditySquare.vue b/pages/commodity-square/commoditySquare.vue
index 791daf2..f9c47a2 100644
--- a/pages/commodity-square/commoditySquare.vue
+++ b/pages/commodity-square/commoditySquare.vue
@@ -9,7 +9,8 @@
<view class="banner" style="margin-top: 14rpx;" v-if="bannerList.length>0">
<swiper :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000" :circular="true"
style="width: 100%;height: 160rpx;">
- <swiper-item v-for="item in bannerList" :key="item.id" @click="navigateGoodsInfo(item.skuId,item.goodsId)">
+ <swiper-item v-for="item in bannerList" :key="item.id"
+ @click="navigateGoodsInfo(item.skuId,item.goodsId)">
<view style="width: 100%; display: flex; align-items: center;justify-content: center;">
<image :src="item.showBannerUrl" mode="aspectFill"
style="width: 690rpx;height: 150rpx;border-radius: 24rpx;overflow: hidden;"></image>
@@ -78,8 +79,19 @@
</view>
<view class="squareFotter" style="width: 750rpx; display: flex;align-items: center;
justify-content: space-between;padding: 0 32rpx;box-sizing: border-box;">
- <view class="icon">
- <text class="iconfont"></text>
+ <view style="display: flex;align-items: center;justify-content: center;">
+ <view class="icon" style="position: relative;">
+ <text class="iconfont"></text>
+ <view style=" height: 36rpx;width:36rpx;display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #f9583b;border-radius: 100%; position: absolute;
+ top: -25rpx; right: -20rpx;color: #fff;font-size: 24rpx;">
+ {{priceInfo.num > 99?'路路路':priceInfo.num}}
+ </view>
+ </view>
+ <view style="margin-left: 10rpx;color: #e06c75;font-size: 48rpx;font-weight: bold;">
+ 锟{priceInfo.price}}</view>
</view>
<view class="settlement" @click="gotoCardList()">鍘荤粨绠�</view>
</view>
@@ -110,7 +122,11 @@
},
data() {
return {
- bannerList:[],
+ priceInfo: {
+ price: 0,
+ num: 0
+ },
+ bannerList: [],
canGoToCarList: false,
nums: 10,
searchInfo: '',
@@ -142,8 +158,7 @@
}
},
methods: {
- navigateGoodsInfo(skuId,goodsId){
- console.log(skuId,goodsId)
+ navigateGoodsInfo(skuId, goodsId) {
uni.navigateTo({
url: `/pages/product/goods?id=${skuId}&goodsId=${goodsId}`
});
@@ -153,8 +168,26 @@
url: '/pages/cusbar/cart/cartList'
})
},
- addCardNum(e, id) {
- this.goodsList.forEach(item => {
+ async addCardNum(e, id) {
+ // this.goodsList.forEach(item => {
+ // if (item.id === id) {
+ // if (item.cardNum) {
+ // item.cardNum++;
+ // } else {
+ // item.cardNum = 1;
+ // }
+ // this.flushDom = new Date().getMilliseconds();
+ // const data = {
+ // skuId: item.id,
+ // num: item.cardNum
+ // }
+ // await addCard(data)
+ // await this.getCartList();
+ // return;
+ // }
+ // })
+ for (let i = 0; i < this.goodsList.length; i++) {
+ const item = this.goodsList[i];
if (item.id === id) {
if (item.cardNum) {
item.cardNum++;
@@ -162,27 +195,27 @@
item.cardNum = 1;
}
this.flushDom = new Date().getMilliseconds();
- console.log("閫変腑鐨勫晢鍝佷负------------------->", JSON.stringify(item))
const data = {
skuId: item.id,
num: item.cardNum
}
- addCard(data)
+ await addCard(data)
+ await this.getCartList();
return;
}
- })
-
+ }
},
- miousCardNum(e, id) {
+ async miousCardNum(e, id) {
for (let i = 0; i < this.goodsList.length; i++) {
const item = this.goodsList[i];
if (item.id === id) {
if (item.cardNum && item.cardNum > 1) {
item.cardNum--;
} else {
- deleteSkuItem([id]);
+ await deleteSkuItem([id]);
item.cardNum = 0;
this.flushDom = new Date().getMilliseconds();
+ await this.getCartList();
break; // 閫�鍑烘暣涓惊鐜�
}
this.flushDom = new Date().getMilliseconds();
@@ -190,7 +223,8 @@
skuId: item.id,
num: item.cardNum
};
- addCard(data);
+ await addCard(data);
+ await this.getCartList();
break; // 閫�鍑烘暣涓惊鐜�
}
}
@@ -275,19 +309,19 @@
this.listHeight1 -= videoHeight;
}
}
- console.log(this[arrName][index].width, this[arrName][index].height)
+ // console.log(this[arrName][index].width, this[arrName][index].height)
this.flushDom = new Date();
},
goToGoodsInfo(id) {
const item = this.goodsList.find(item => id === item.id);
- console.log(item)
+ // console.log(item)
uni.navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`
});
},
//瑙﹀簳鑾峰彇鏁版嵁
async loadMoreData() {
- console.log("瑙﹀簳鍔犺浇------------銆�", this.maxPages)
+ // console.log("瑙﹀簳鍔犺浇------------銆�", this.maxPages)
if (this.getGoodsParam.pageNumber < this.maxPages) {
this.getGoodsParam.pageNumber++;
await this.getgoodsData()
@@ -308,10 +342,34 @@
async getBannerList() {
const bannerList = await getBannerList();
this.bannerList = bannerList.data.data
- console.log(this.bannerList)
+ // console.log(this.bannerList)
+ },
+ async getCartList() {
+ const cardInfos = await getCarts();
+ const cardList = cardInfos.data.result.cartList.flatMap(item => {
+ return item.skuList.map(sku => {
+ return (sku.goodsSku.id, {
+ skuId: sku.goodsSku.id,
+ num: sku.num,
+ price: sku.priceDetailDTO.flowPrice
+ })
+ })
+
+ })
+
+ this.priceInfo = cardList.reduce((newVal, current) => {
+ return {
+ num: newVal.num + current.num,
+ price: newVal.price + current.price
+ }
+ }, {
+ num: 0,
+ price: 0
+ })
},
async getgoodsData() {
const cardInfos = await getCarts();
+ // console.log('--------------------->', cardInfos)
// 澶勭悊璐墿杞︿俊鎭�
let cardMap = new Map();
this.canGoToCarList = cardInfos.data.result.cartList.length > 0
@@ -335,7 +393,7 @@
})
this.goodsList = [...this.goodsList, ...goodsList.data.result.records];
this.maxPages = goodsList.data.result.pages
- console.log('this.goodsList----------------------->', JSON.stringify(goodsList.data.result))
+ // console.log('this.goodsList----------------------->', JSON.stringify(goodsList.data.result))
},
async chooseCategory(id) {
@@ -357,6 +415,7 @@
},
async onLoad() {
+ await this.getCartList();
// 鑾峰彇鐘舵�佹爮楂樺害
const systemInfo = uni.getSystemInfoSync();
diff --git a/pages/cusbar/cart/cartList.vue b/pages/cusbar/cart/cartList.vue
index 183d6d8..da6bd4a 100644
--- a/pages/cusbar/cart/cartList.vue
+++ b/pages/cusbar/cart/cartList.vue
@@ -14,7 +14,7 @@
</view>
</view>
<!-- 搴楅摵鍟嗗搧淇℃伅 -->
- <div class="content" :style="{height: windowHeight - marginBottom - 50 + 'px'}">
+ <div class="content" :style="{height: windowHeight - marginBottom - 200 + 'px'}">
<div class="box box2" :class="{ invalid: isInvalid(item) }" v-for="(item, index) in cartDetail.cartList"
:key="index">
<view class="tab">
@@ -719,6 +719,7 @@
.content {
padding: 20rpx 0 20rpx 0;
margin-bottom: 80rpx;
+ overflow: auto;
}
.line {
--
Gitblit v1.8.0