feat: 分类联调
This commit is contained in:
parent
4ca8d1d0ed
commit
62446e075b
@ -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>(
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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,
|
||||
})),
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@ -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">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user