// pages/Mall/sortCommodity/sortCommodity.js // 获取应用实例 const {API} = require('../../../service/api.js'); Page({ /** * 页面的初始数据 */ data: { ipInfoList:[ {ipName:'全部',ipId:''} ], filterIndex1:-1, filterIndex2:-1, filterObj:{} //筛选条件 }, // 监听筛选 selectFilter(e){ let {index,index2,item} = e.currentTarget.dataset; let filterObj = this.data.filterObj; if(index === 0) filterObj.ipId = item.ipId; if(index === 1) filterObj.prodClassId = item.prodClassId; this.setData({ [index === 0?'filterIndex1':'filterIndex2']:index2, filterObj }) }, // 获取IP分类 getIpList(){ API.getIpInfos().then(res=>{ if(res){ res.ipInfoList.push({ipName:"全部",ipId:''}) this.setData({ ipInfoList:res.ipInfoList }) }; }) }, // 获取商品分类 getProdClasses(){ API.getProdClasses().then(res=>{ if(res){ res.prodClassList.push({className:"全部",prodClassId:''}) this.setData({ prodClassList:res.prodClassList }) }; }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getProdClasses(); this.getIpList(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })