var app = getApp(); var host = app.globalData.servsers; Page({ data: { contentList: [], forid:null, page:0, // 表示从第一页开始 limit:10, // 每页10条数据 requestState:true, // 表示可以请求 loginStatic: false //登陆状态,默认为false }, onLoad: function (options) { var that = this; // var classify_name = options.classify_name; // var flag = options.flag; // var shareFlag = options.shareFlag; // if (shareFlag != '' && shareFlag != null && shareFlag != undefined){ // that.setData({ // shareFlag: shareFlag // }) // } console.log("id:" + options.id); console.log("classify_name:" + options.classify_name); console.log("shareFlag:" + options.shareFlag); console.log("classify_des: "+options.classify_des); if (options.id){ that.getId(that, options.id) } else { that.getGoodsList(that) } if(options.id == '2298' || options.id == '3000'){//内部员工和VIP禁止分享 //禁止分享 wx.hideShareMenu(); } // that.setData({ // id: options.id // }) // wx.request({ // url: host+"classifyapi/findAllforviewSce", // data: { // id: options.id // }, // method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT // header: { // 'Accept': 'application/json' // }, // success: function (res) { // that.setData({ // contentList: res.data.rows // }); // console.log(res.data.rows); // if (res.data.rows != ''){ // var forid = res.data.rows[0].id; // var forname = res.data.rows[0].classify_name; // var classifydes = res.data.rows[0].classify_des; // } // if (res == null || res.data == null) { // console.error('网络请求失败'); // return; // } // } // }); // wx.setNavigationBarTitle({ // title: options.classify_name // }) // this.setData({ // classify_name: options.classify_name, // classify_des: options.classify_des, // flag: flag // }) }, onShow(){ let that = this; if (wx.getStorageSync('channelIdObj').channelId) { that.setData({ loginStatic: true, }) } }, //滚动到底部触发事件 /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { let that = this; if (that.data.requestState) { that.setData({ page: that.data.page + 1 }) that.getGoodsList(that) } }, getId(that,id){ wx.request({ url: host + "classifyapi/findAllforviewSce", method:'get', data:{ id:id }, success(res){ if(res.data.rows.length > 0){ that.setData({ forid: res.data.rows[0].id }) } that.getGoodsList(that) } }) }, getGoodsList(that){ let data = { offset: that.data.page, limit: that.data.limit, channelId: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : "" } if (that.data.forid) { data.commodity_levelTwo = that.data.forid } // if (that.data.channelIdObj.channelAccountId) { // data.commodity_levelTwo = that.data.forid // } wx.request({ url: host + "commodityapi/commoditviewfoeeverybody", data: data, method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT header: { 'Accept': 'application/json' }, success: function (res) { let contentList = that.data.contentList; contentList.push(...res.data.rows) that.setData({ contentList: contentList, requestState: res.data.rows.length ==that.data.limit }); if (res == null || res.data == null) { console.error('网络请求失败'); return; } } }); }, toGoodsDetail(e) { // 进入商品详情页 let that = this, id = e.currentTarget.dataset.id; wx.navigateTo({ url: '/pages/buy/buy?com_id=' + id, }) }, })