feat 添加店铺商品类目接口对接
This commit is contained in:
parent
4d7db88e3c
commit
cd8590d259
@ -174,3 +174,7 @@
|
|||||||
font-size: 23rpx;
|
font-size: 23rpx;
|
||||||
color: #7e7e7e;
|
color: #7e7e7e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-tab-bar {
|
||||||
|
--td-tab-bar-active-bg: #ff0000; /* 设置选中状态的背景颜色为红色 */
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
import { goodsList } from "~/model/goods";
|
||||||
|
|
||||||
Component({
|
Component({
|
||||||
externalClasses: ['wr-class'],
|
externalClasses: ['wr-class'],
|
||||||
|
|
||||||
@ -50,6 +52,7 @@ Component({
|
|||||||
},
|
},
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
console.log(this.properties.goodsList);
|
||||||
this.genIndependentID(this.id || '');
|
this.genIndependentID(this.id || '');
|
||||||
this.setData({ type: this.properties.type });
|
this.setData({ type: this.properties.type });
|
||||||
},
|
},
|
||||||
|
@ -4,13 +4,11 @@ import {
|
|||||||
import {
|
import {
|
||||||
fetchShop
|
fetchShop
|
||||||
} from '~/services/shop/fetchShop';
|
} from '~/services/shop/fetchShop';
|
||||||
|
import {
|
||||||
|
fetchShopGoodsCategory
|
||||||
|
} from '~/services/shop/fetchShopGoodsCategory';
|
||||||
import Toast from 'tdesign-miniprogram/toast/index';
|
import Toast from 'tdesign-miniprogram/toast/index';
|
||||||
|
|
||||||
const image = 'https://tdesign.gtimg.com/miniprogram/images/example2.png';
|
|
||||||
const items = new Array(12).fill({
|
|
||||||
label: '标题文字',
|
|
||||||
image
|
|
||||||
}, 0, 12);
|
|
||||||
|
|
||||||
const initFilters = {
|
const initFilters = {
|
||||||
overall: 1,
|
overall: 1,
|
||||||
@ -22,6 +20,7 @@ const initFilters = {
|
|||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
goodsList: [],
|
goodsList: [],
|
||||||
|
shopCategoryGoodsList: [],
|
||||||
layout: 0,
|
layout: 0,
|
||||||
priceSorts: '',
|
priceSorts: '',
|
||||||
soldSorts: '',
|
soldSorts: '',
|
||||||
@ -51,48 +50,9 @@ Page({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
sideBarIndex: 1,
|
sideBarIndex: 0,
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
categories: [{
|
categories: [],
|
||||||
label: '选项一',
|
|
||||||
title: '标题一',
|
|
||||||
icon: 'app',
|
|
||||||
badgeProps: {},
|
|
||||||
items,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '选项二',
|
|
||||||
title: '标题二',
|
|
||||||
icon: 'app',
|
|
||||||
badgeProps: {
|
|
||||||
dot: true,
|
|
||||||
},
|
|
||||||
items: items.slice(0, 9),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '选项三',
|
|
||||||
title: '标题三',
|
|
||||||
icon: 'app',
|
|
||||||
badgeProps: {},
|
|
||||||
items: items.slice(0, 9),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '选项四',
|
|
||||||
title: '标题四',
|
|
||||||
icon: 'app',
|
|
||||||
badgeProps: {
|
|
||||||
count: 6,
|
|
||||||
},
|
|
||||||
items: items.slice(0, 6),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '选项五',
|
|
||||||
title: '标题五',
|
|
||||||
icon: 'app',
|
|
||||||
badgeProps: {},
|
|
||||||
items: items.slice(0, 3),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
offsetTopList: [],
|
offsetTopList: [],
|
||||||
@ -138,7 +98,7 @@ Page({
|
|||||||
goodsSort: 0, // 0 综合,1 价格
|
goodsSort: 0, // 0 综合,1 价格
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 6,
|
pageSize: 6,
|
||||||
shopGuid: shopGuid
|
shopGuid: shopGuid,
|
||||||
// keyword: keywords,
|
// keyword: keywords,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -232,6 +192,8 @@ Page({
|
|||||||
hasLoaded: true,
|
hasLoaded: true,
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(query) {
|
onLoad(query) {
|
||||||
@ -242,23 +204,7 @@ Page({
|
|||||||
shopGuid: shopGuid,
|
shopGuid: shopGuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.init(true);
|
this.init(true)
|
||||||
|
|
||||||
const query2 = wx.createSelectorQuery().in(this);
|
|
||||||
const {
|
|
||||||
sideBarIndex
|
|
||||||
} = this.data;
|
|
||||||
|
|
||||||
query2
|
|
||||||
.selectAll('.title')
|
|
||||||
.boundingClientRect((rects) => {
|
|
||||||
this.offsetTopList = rects.map((item) => item.top);
|
|
||||||
console.log(this.offsetTopList, '123123123');
|
|
||||||
this.setData({
|
|
||||||
scrollTop: rects[sideBarIndex].top
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.exec();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
@ -378,10 +324,38 @@ Page({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(e) {
|
async onChange(e) {
|
||||||
this.setData({
|
this.setData({
|
||||||
value: e.detail.value,
|
value: e.detail.value,
|
||||||
});
|
});
|
||||||
|
if (this.data.value == "category") {
|
||||||
|
// 获取店铺商品类目
|
||||||
|
const {
|
||||||
|
shopGuid
|
||||||
|
} = this.data
|
||||||
|
const shopGoodsCategoryResult = await fetchShopGoodsCategory({
|
||||||
|
shopGuid: shopGuid
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
categories: shopGoodsCategoryResult
|
||||||
|
})
|
||||||
|
|
||||||
|
const query2 = wx.createSelectorQuery().in(this);
|
||||||
|
const {
|
||||||
|
sideBarIndex
|
||||||
|
} = this.data;
|
||||||
|
|
||||||
|
query2
|
||||||
|
.selectAll('.title')
|
||||||
|
.boundingClientRect((rects) => {
|
||||||
|
console.log(rects, '123123123');
|
||||||
|
this.offsetTopList = rects.map((item) => item.top);
|
||||||
|
this.setData({
|
||||||
|
scrollTop: rects[sideBarIndex].top
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<view class="shop-detail-page">
|
<view class="shop-detail-page">
|
||||||
|
|
||||||
<!-- 店铺信息 -->
|
<!-- 店铺信息 -->
|
||||||
|
<!-- wx:if="{{ value == 'all' }}" -->
|
||||||
<view style="padding: 10px;" class="shop-big-box" wx:if="{{ value == 'all' }}" bindtap="handlePopup">
|
<view style="padding: 10px;" class="shop-big-box" wx:if="{{ value == 'all' }}" bindtap="handlePopup">
|
||||||
<view style="padding: 10px;" class="shop-left-box">
|
<view style="padding: 10px;" class="shop-left-box">
|
||||||
<view class="shop-left-img-box">
|
<view class="shop-left-img-box">
|
||||||
@ -45,19 +46,19 @@
|
|||||||
|
|
||||||
<view class="side-bar-wrapper">
|
<view class="side-bar-wrapper">
|
||||||
<t-side-bar value="{{sideBarIndex}}" bind:change="onSideBarChange">
|
<t-side-bar value="{{sideBarIndex}}" bind:change="onSideBarChange">
|
||||||
<t-side-bar-item wx:for="{{categories}}" wx:key="index" value="{{item.value || index}}" label="{{item.label}}" icon="{{item.icon}}" badge-props="{{item.badgeProps}}" />
|
<t-side-bar-item wx:for="{{categories}}" wx:key="index" value="{{item.value || index}}" label="{{item.label}}" badge-props="{{item.badgeProps}}" />
|
||||||
</t-side-bar>
|
</t-side-bar>
|
||||||
<scroll-view class="content" scroll-y scroll-with-animation scroll-top="{{scrollTop}}" bind:scroll="onScroll">
|
<scroll-view class="content" scroll-y scroll-with-animation scroll-top="{{scrollTop}}" bind:scroll="onScroll">
|
||||||
<filter wr-class="filter-container" bind:change="handleFilterChange" layout="{{layout}}" priceSorts="{{priceSorts}}" soldSorts="{{soldSorts}}" overall="{{overall}}" bind:showFilterPopup="showFilterPopup">
|
<!-- <filter wr-class="filter-container" bind:change="handleFilterChange" layout="{{layout}}" priceSorts="{{priceSorts}}" soldSorts="{{soldSorts}}" overall="{{overall}}" bind:showFilterPopup="showFilterPopup">
|
||||||
</filter>
|
</filter> -->
|
||||||
<view wx:for="{{categories}}" wx:key="index" class="section">
|
<view wx:for="{{categories}}" wx:key="index" class="section">
|
||||||
<view class="title">{{item.title || item.label}}</view>
|
<view class="title">{{item.label}}</view>
|
||||||
<view class="goods-category-crad">
|
<view class="goods-category-crad">
|
||||||
<view class="empty-wrap" wx:if="{{goodsList.length === 0 && hasLoaded}}">
|
<view class="empty-wrap" wx:if="{{item.items.length === 0 && hasLoaded}}">
|
||||||
<t-empty t-class="empty-tips" size="240rpx" description="暂无相关商品" />
|
<t-empty t-class="empty-tips" size="240rpx" description="暂无相关商品" />
|
||||||
</view>
|
</view>
|
||||||
<view class="category-goods-list" wx:if="{{goodsList.length}}">
|
<view class="category-goods-list" wx:if="{{item.items.length}}">
|
||||||
<goods-list wr-class="wr-goods-list" type="category-card" goodsList="{{goodsList}}" bind:click="gotoGoodsDetail" bind:addcart="handleAddCart" />
|
<goods-list wr-class="wr-goods-list" type="category-card" goodsList="{{item.items}}" bind:click="gotoGoodsDetail" bind:addcart="handleAddCart" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -69,7 +70,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 底部导航栏 -->
|
<!-- 底部导航栏 -->
|
||||||
<t-tab-bar value="{{value}}" bindchange="onChange" theme="tag" split="{{false}}">
|
<t-tab-bar t-class="custom-tab-bar" value="{{value}}" bindchange="onChange" theme="tag" split="{{false}}">
|
||||||
<t-tab-bar-item wx:for="{{list}}" wx:key="index" value="{{item.value}}" icon="{{item.icon}}">
|
<t-tab-bar-item wx:for="{{list}}" wx:key="index" value="{{item.value}}" icon="{{item.icon}}">
|
||||||
{{item.label}}
|
{{item.label}}
|
||||||
</t-tab-bar-item>
|
</t-tab-bar-item>
|
||||||
|
22
services/shop/fetchShopGoodsCategory.js
Normal file
22
services/shop/fetchShopGoodsCategory.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import {
|
||||||
|
request
|
||||||
|
} from '../_utils/request';
|
||||||
|
|
||||||
|
/** 获取店铺详情 */
|
||||||
|
export function fetchShopGoodsCategory(parm) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: `ShopGoodsCategoryApi/getShopGoodsCategoryTreeList`,
|
||||||
|
data: parm,
|
||||||
|
method: 'GET',
|
||||||
|
success: function (res) {
|
||||||
|
let data = res.data;
|
||||||
|
|
||||||
|
resolve(data);
|
||||||
|
},
|
||||||
|
fail: function (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user