feat: 分类联调

This commit is contained in:
zc 2025-10-26 19:25:21 +08:00
parent 4ca8d1d0ed
commit 62446e075b
5 changed files with 35 additions and 8 deletions

View File

@ -10,13 +10,23 @@ export const apiGetHome = (data: any) => {
});
};
// 获取首页数据
// 获取商品列表数据
export const apiGetCommodityList = (data: any) => {
return httpRequest.post<any>(`${baseUrl}/api-interface/app/index/page/list`, {
...data,
});
};
// 获取购物车列表数据
export const apiGetCartList = (data: any) => {
return httpRequest.post<any>(
`${baseUrl}/api-interface/app/shipping/cart/list`,
{
...data,
}
);
};
// 获取首页数据
export const apiGetAppCategoryList = () => {
return httpRequest.post<any>(

View File

@ -183,10 +183,6 @@ Page({
});
},
handleGetAppCategory() {
console.warn(
'----- my data is getGlobalData("categoryId"): ',
getGlobalData("categoryId")
);
const initCategoryId = getGlobalData("categoryId");
apiGetAppCategoryList().then((res: any) => {
console.warn("----- my data is res2333: ", res);

View File

@ -16,7 +16,7 @@
</view>
<!-- 分类图标区 -->
<view class="category-grid home-page-block-gap">
<view class="category-item" wx:for="{{categories}}" wx:key="id" data-id="{{item.categoryId}}" bindtap="onGoCategory">
<view class="category-item" wx:for="{{categories}}" wx:key="id" data-id="{{item.id}}" bindtap="onGoCategory">
<image class="category-icon" src="{{item.icon}}" />
<text class="category-name">{{item.name}}</text>
</view>

View File

@ -1,3 +1,5 @@
import { apiGetCartList } from "../../api/index/index";
// pages/index/index.ts
Page({
data: {
@ -62,4 +64,22 @@ Page({
const data = this.data.commodities.filter((item) => item.id !== id);
this.setData({ commodities: data });
},
onShow() {
apiGetCartList({ buyerId: 2 }).then((res: any) => {
console.warn("----- my data is res2555: ", res);
this.setData({
commodities: res.data.rows.map((item: any) => ({
id: item.id,
name: item.productName,
icon: item.icon,
originalPrice: item.originalPrice,
price: item.singlePrice,
attribute: JSON.parse(item.skuInfo)
.map((item) => item.propertyValue)
.join("-"),
active: false,
})),
});
});
},
});

View File

@ -12,10 +12,11 @@
</view>
<view class="item__texts">
<view class="item__title">{{item.name}}</view>
<view class="item__attribute">我是属性</view>
<view class="item__attribute">{{item.attribute}}</view>
<view class="item__line">
<view class="line__price">
<view class="line__price__actual">¥<text>20</text>.00</view>
<!-- <view class="line__price__actual">¥<text>20</text>.00</view> -->
<view class="line__price__actual">¥{{item.price}}</view>
<view class="line__price__origin">¥39.00</view>
</view>
<view class="line__num">