|
@@ -8,9 +8,7 @@ Page({
|
|
|
classifyNavList:[],
|
|
|
classifyNavActiveId: 2981,
|
|
|
goodsList:[],
|
|
|
- commodity_levelTwo:null,
|
|
|
requestState:true, //默认为true,表示还有数据
|
|
|
- page:0,
|
|
|
filterArray: [
|
|
|
{ name: '1', value: '0~499元' },
|
|
|
{ name: '2', value: '500~999元'},
|
|
@@ -18,12 +16,17 @@ Page({
|
|
|
{ name: '4', value: '2000元以上' },
|
|
|
],
|
|
|
filterStatic:false,
|
|
|
- isNew:true,
|
|
|
- isMin:true,
|
|
|
+ page: 1, //默认第一页
|
|
|
+ channelId:null, //渠道id,登录后给,默认为null
|
|
|
+ maxPrice:null, //最大价格
|
|
|
+ minPrice:null, //最低价格
|
|
|
+ limit:10, //分页大小
|
|
|
+ priceSort: null, //价格排序 desc asc
|
|
|
+ timeSort: null, //时间排序 desc asc
|
|
|
+
|
|
|
},
|
|
|
onLoad(){
|
|
|
this.getNavList(this);
|
|
|
- this.getGoodsListAllfor(this)
|
|
|
},
|
|
|
onShow(){
|
|
|
|
|
@@ -39,13 +42,18 @@ Page({
|
|
|
},
|
|
|
getNavList(that){
|
|
|
wx.request({
|
|
|
- url: host + '/classifyapi/findAllforhome',
|
|
|
+ url: host + '/classifyapi/classifyTwoAll',
|
|
|
method:'get',
|
|
|
+ data:{
|
|
|
+ classifyHigher:'3053',
|
|
|
+ },
|
|
|
success(res){
|
|
|
console.log(res,"成功后的")
|
|
|
that.setData({
|
|
|
- classifyNavList:[...res.data.rows]
|
|
|
+ classifyNavList:res.data.rows,
|
|
|
+ classifyNavActiveId: res.data.rows[0].id
|
|
|
})
|
|
|
+ that.getGoodsList(that)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -55,44 +63,46 @@ Page({
|
|
|
that.setData({
|
|
|
classifyNavActiveId:item.id,
|
|
|
requestState: true, //数据初始化
|
|
|
- page: 0,//数据初始化
|
|
|
+ page: 1,//数据初始化
|
|
|
goodsList: []//数据初始化
|
|
|
})
|
|
|
- that.getGoodsListAllfor(that)
|
|
|
+ that.getGoodsList(that)
|
|
|
|
|
|
},
|
|
|
- getGoodsListAllfor(that){
|
|
|
- wx.request({
|
|
|
- url: host +'/classifyapi/findAllforviewSce',
|
|
|
- method:'get',
|
|
|
- data:{
|
|
|
- id:that.data.classifyNavActiveId
|
|
|
- },
|
|
|
- success(res){
|
|
|
- that.setData({
|
|
|
- commodity_levelTwo:res.data.rows[0].id,
|
|
|
- })
|
|
|
- that.getGoodsList(that)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
getGoodsList(that){
|
|
|
- let goodsList = that.data.goodsList, requestState = true
|
|
|
+ let data = {
|
|
|
+ classId: that.data.classifyNavActiveId,
|
|
|
+ limit: that.data.limit,
|
|
|
+ offset:that.data.page,
|
|
|
+ }
|
|
|
+ if(that.data.channelId){
|
|
|
+ data.channelId = that.data.channelId
|
|
|
+ }
|
|
|
+ if (that.data.maxPrice) {
|
|
|
+ data.maxPrice = that.data.maxPrice
|
|
|
+ }
|
|
|
+ if (that.data.minPrice) {
|
|
|
+ data.minPrice = that.data.minPrice
|
|
|
+ }
|
|
|
+ if (that.data.priceSort) {
|
|
|
+ data.priceSort = that.data.priceSort
|
|
|
+ }
|
|
|
+ if (that.data.timeSort) {
|
|
|
+ data.timeSort = that.data.timeSort
|
|
|
+ }
|
|
|
wx.request({
|
|
|
- url: host + '/commodityapi/commoditviewfoeeverybody?commodity_levelTwo=2983&offset=0&limit=10',
|
|
|
+ url: host +'/commodityapi/queryCommodityByClass',
|
|
|
method:'get',
|
|
|
- data:{
|
|
|
- commodity_levelTwo: that.data.commodity_levelTwo,
|
|
|
- offset:that.data.page,
|
|
|
- limit:10,
|
|
|
- },
|
|
|
+ data:data,
|
|
|
success(res){
|
|
|
- console.log(res)
|
|
|
- res.data.rows.length < 10 ? requestState = false : requestState = true
|
|
|
- goodsList.push(...res.data.rows)
|
|
|
+ let dataArray = that.data.goodsList;
|
|
|
+ res.data.rows.forEach(el => {
|
|
|
+ el.logo = el.commodity_logo.split(",")
|
|
|
+ })
|
|
|
+ dataArray.push(...res.data.rows)
|
|
|
that.setData({
|
|
|
- goodsList: goodsList,
|
|
|
- requestState: requestState
|
|
|
+ goodsList: dataArray,
|
|
|
+ requestState: res.data.rows.length > that.data.limit
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -100,23 +110,61 @@ Page({
|
|
|
filterTap(){
|
|
|
let that = this;
|
|
|
that.setData({
|
|
|
- filterStatic: !that.data.filterStatic
|
|
|
+ filterStatic: !that.data.filterStatic,
|
|
|
+ page:1,
|
|
|
+ goodsList:[],
|
|
|
})
|
|
|
+ that.getGoodsList(that)
|
|
|
},
|
|
|
- newTap(){
|
|
|
- this.setData({
|
|
|
- isNew:!this.data.isNew
|
|
|
+ timeSortTap(){
|
|
|
+ let that = this;
|
|
|
+ that.setData({
|
|
|
+ timeSort: that.data.timeSort === null ? 'asc' : that.data.timeSort === 'asc' ? 'desc' : 'asc',
|
|
|
+ page:1,
|
|
|
+ goodsList: [],
|
|
|
})
|
|
|
+ that.getGoodsList(that)
|
|
|
},
|
|
|
- priceTap() {
|
|
|
- this.setData({
|
|
|
- isMin: !this.data.isMin
|
|
|
+ priceSortTap() {
|
|
|
+ let that = this;
|
|
|
+ that.setData({
|
|
|
+ priceSort: that.data.priceSort === null ? 'asc' : that.data.priceSort === 'asc' ? 'desc' : 'asc',
|
|
|
})
|
|
|
},
|
|
|
+ blurPriceMin(e) {
|
|
|
+ // event.detail = {value: value}
|
|
|
+ let that = this;
|
|
|
+ that.setData({
|
|
|
+ minPrice: e.detail.value,
|
|
|
+ page: 1,
|
|
|
+ goodsList: [],
|
|
|
+ })
|
|
|
+ that.getGoodsList(that)
|
|
|
+ },
|
|
|
+ blurPriceMax(e) {
|
|
|
+ let that = this;
|
|
|
+ that.setData({
|
|
|
+ maxPrice: e.detail.value,
|
|
|
+ page: 1,
|
|
|
+ goodsList: [],
|
|
|
+ })
|
|
|
+ that.getGoodsList(that)
|
|
|
+ },
|
|
|
close(){
|
|
|
this.setData({
|
|
|
filterStatic:false
|
|
|
})
|
|
|
+ },
|
|
|
+ toGoodsDetail(e) { // 进入商品详情页
|
|
|
+ let that = this, id = e.currentTarget.dataset.id;
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/buy/buy?com_id=' + id,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ search(){
|
|
|
+ wx.redirectTo({
|
|
|
+ url: "/pages/search/search",
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
})
|