// pages/activity/tenscenic/index.js import commonApi from "../../../utils/https/common" import util from "../../../utils/util" Page({ /** * 页面的初始数据 */ data: { areas:[], tag1:0, tag2:0, areaIndex:0, list:[], total:1, playFlag:false, scrollTop:0, realScrollTop:0, navList: [ {name: '全部', tag_id: [81,89,97,105,113,121,129,137,145,153]}, {name: '必吃', tag_id: [82,90,98,106,114,122,130,138,146,154]}, {name: '必住', tag_id: [83,91,99,107,115,123,131,139,147,155]}, {name: '必游', tag_id: [84,92,100,108,116,124,132,140,148,156]}, {name: '必购', tag_id: [85,93,101,109,117,125,133,141,149,157]}, {name: '必娱', tag_id: [86,94,102,110,118,126,134,142,150,158]}, {name: '必行', tag_id: [87,95,103,111,119,127,135,143,151,159]}, {name: '必玩', tag_id: [88,96,104,112,120,128,136,144,152,160]}, ] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { commonApi._post("act/get_suzhou_areas",{}).then(res=>{ res.data.unshift({ area_title:"全部", area_id:"" }) this.setData({ areas:res.data }) this.getList() }) }, changeArea:function(e){ this.setData({ areaIndex:e.detail.value, list:[], total:1 }) this.getList() }, changeTag2:function(e){ let tag = e.currentTarget.dataset.tag; this.setData({ tag2:tag, list:[], total:1, realScrollTop:this.data.scrollTop }) this.getList(1) }, changeTag:function(e){ let tag = e.currentTarget.dataset.tag; this.setData({ tag1:tag, list:[], total:1, realScrollTop:this.data.scrollTop }) this.getList(1) }, getList:function(type){ if(this.data.list.length>=this.data.total) return; commonApi._post("scene/get_scene_by_tag",{ area_id:this.data.areas[this.data.areaIndex].area_id, tag_id:this.data.navList[this.data.tag2].tag_id[this.data.tag1], offset:this.data.list.length, limit:10, del_html:true }).then(res=>{ this.setData({ total:res.data.count, list:this.data.list.concat(res.data.list) }) if(type==1){ wx.pageScrollTo({ duration: 0, scrollTop:this.data.realScrollTop }) } }) }, goTop:function(){ wx.pageScrollTo({ duration: 200, scrollTop:0 }) }, play:function(){ this.setData({ playFlag:true }) }, playEnd:function(){ this.setData({ playFlag:false }) }, gotoDetail:function(e){ let item = e.currentTarget.dataset.item util.gotoDetail(item) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, onPageScroll:function(e){ console.log() this.setData({ scrollTop:e.scrollTop }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.getList() }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })