feat 对金额商品分类

This commit is contained in:
lwh 2023-07-09 00:35:00 +08:00
parent 7612ee24b9
commit 03367933d0
5 changed files with 31 additions and 19 deletions

View File

@ -11,6 +11,7 @@
<c-tabbar
wx:if="{{isSlotRight}}"
activeKey="{{subActiveKey}}"
tabList="{{category[activeKey].children}}"
bindchange="onChildChange"
showMore
>
@ -47,7 +48,7 @@
bindtap="changCategory"
data-item="{{item}}"
>
<t-image src="{{item.thumbnail}}" t-class="image" />
<image src="{{item.thumbnail}}" class="item-image" />
<view class="flex goods-category-normal-item-container-item-title">
{{item.name}}
</view>

View File

@ -100,3 +100,10 @@
font-size: 24rpx;
color: #222427;
}
.item-image{
width: 180rpx;
height: 180rpx;
object-fit: contain;
overflow: hidden;
}

View File

@ -1,11 +1,11 @@
import { getCategoryList } from '../../../services/good/fetchCategoryList';
import { getGoodsCategoryTreeList } from '../../../services/good/fetchCategoryList';
Page({
data: {
list: [],
},
async init() {
try {
const result = await getCategoryList();
const result = await getGoodsCategoryTreeList();
this.setData({
list: result,
});

View File

@ -1,6 +1,7 @@
<view class="wrap">
<goods-category
level="{{3}}"
level="{{2}}"
isSlotRight="{{false}}"
custom-class="goods-category-class"
category="{{list}}"
bind:changeCategory="onChange"

View File

@ -1,18 +1,21 @@
import { config } from '../../config/index';
import {
request
} from '../_utils/request';
/** 获取商品列表 */
function mockFetchGoodCategory() {
const { delay } = require('../_utils/delay');
const { getCategoryList } = require('../../model/category');
return delay().then(() => getCategoryList());
}
/** 获取商品列表 */
export function getCategoryList() {
if (config.useMock) {
return mockFetchGoodCategory();
}
return new Promise((resolve) => {
resolve('real api');
/** 获取经营类目列表 */
export function getGoodsCategoryTreeList() {
return new Promise((resolve, reject) => {
request({
url: `GoodsCategoryApi/getGoodsCategoryTreeList`,
method: 'GET',
success: function (res) {
let list = res.data;
resolve(list);
},
fail: function (error) {
reject(error);
}
});
});
}