Commit d6a3421a by 赵雅纹

商品排序

parent 7130727c
...@@ -15,11 +15,27 @@ wxService.page({ ...@@ -15,11 +15,27 @@ wxService.page({
pageSize: 10, pageSize: 10,
totalPages: '', totalPages: '',
form: { form: {
queryDto: { mallCategoryId: '',
mallCategoryId: '' sortType:'',
} order:''
}, },
proStyle:false navTab:[
{
name: '推荐',
type: 'recommend'
},
{
name: '最新',
type: 'new'
},
{
name: '价格',
type: 'price'
},
],
priceSort:false,
currentTab:'recommend',
proStyle:false,
}, },
/** /**
...@@ -29,11 +45,7 @@ wxService.page({ ...@@ -29,11 +45,7 @@ wxService.page({
console.log(options) console.log(options)
if (options && options.id) { if (options && options.id) {
this.setData({ this.setData({
form: { 'form.mallCategoryId': options.id
queryDto: {
mallCategoryId: options.id
}
}
}) })
} }
}, },
...@@ -42,6 +54,32 @@ wxService.page({ ...@@ -42,6 +54,32 @@ wxService.page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.setData({
'form.sortType': this.data.currentTab
})
this.getProList();
},
// 切换tab
switchTab(e){
console.log(e)
this.setData({
currentTab: e.currentTarget.dataset.type,
'form.sortType': e.currentTarget.dataset.type
})
if (this.data.currentTab == 'price'){
if (!this.data.priceSort){
this.setData({
'form.order': 'desc',
priceSort: true
})
}else{
this.setData({
'form.order': 'asc',
priceSort: false
})
}
}
this.getProList(); this.getProList();
}, },
...@@ -50,7 +88,7 @@ wxService.page({ ...@@ -50,7 +88,7 @@ wxService.page({
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
wxService.post(`/sale/product/buyer/listPageByCategoryId?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`, this.data.form.queryDto).then(res => { wxService.post(`/sale/product/buyer/listPageByCategoryId?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`, this.data.form).then(res => {
const { result, data } = res.data const { result, data } = res.data
if (result == 0 && data.content) { if (result == 0 && data.content) {
wx.hideLoading() wx.hideLoading()
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
<view class="page-category-pro"> <view class="page-category-pro">
<view class="pro-nav-wrap"> <view class="pro-nav-wrap">
<view class="nav-list"> <view class="nav-list">
<view class="nav-item nav-active">推荐</view> <block wx:for="{{navTab}}" wx:key="{{index}}">
<view class="nav-item">最新</view> <view class="nav-item {{currentTab == item.type ? 'nav-active' : ''}}" bindtap="switchTab" data-type="{{item.type}}">{{item.name}}</view>
<view class="nav-item">最热</view> </block>
<view class="nav-item">价格</view>
</view> </view>
<view class="pro-style" bindtap="switchProStyle"> <view class="pro-style" bindtap="switchProStyle">
<image mode="widthFix" src="{{!proStyle ? '/assets/imgs/7_1_0/category-style-01.png' : '/assets/imgs/7_1_0/category-style-02.png'}}" /> <image mode="widthFix" src="{{!proStyle ? '/assets/imgs/7_1_0/category-style-01.png' : '/assets/imgs/7_1_0/category-style-02.png'}}" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment