// pages/activity/springten/index.js import commonApi from "../../../utils/https/common" import util from "../../../utils/util" let app = getApp() Page({ /** * 页面的初始数据 */ data: { types:['必赏','必吃','必游','必玩','必购','必住','赏夜戏','品夜饮','尝夜宴','逛夜市'], type:0, list:[], total:1, areas:[], areaIndex:-1 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // 获取当前定位 commonApi._post("act/get_suzhou_areas").then(res=>{ res.data.unshift({ area_id:"", area_title:"苏州" }) this.setData({ areas:res.data, areaIndex:0 }) }) this.getList() }, changeArea:function(e){ this.setData({ areaIndex:e.detail.value, list:[], total:1 }) this.getList(); }, changeType:function(e){ this.setData({ type:e.currentTarget.dataset.type, list:[], total:1 }) this.getList(); }, getList:function(){ if(this.data.total<=this.data.list.length) return; commonApi._post("scene/get_scene_by_tag",{ offset:this.data.list.length, limit:30, tag_id:this.data.type!=0?17+Number(this.data.type):27, area_id:this.data.areaIndex>-1?this.data.areas[this.data.areaIndex].area_id:null }).then(res=>{ res.data.list.map(item=>{ if(item.type && item.type.indexOf('tenscenic')!=-1){ item.isYunHe = true; } else { item.isYunHe = false; } item.brief_intro = item.brief_intro?item.brief_intro.replace(/<\/?.+?>/g,""):""; item.display_tags = item.display_tags?item.display_tags.split(","):[]; item.display_tags = item.display_tags.splice(0,2); }) this.setData({ list:this.data.list.concat(res.data.list), total:res.data.count }) }) }, gotoWeb:function(e){ let item = e.currentTarget.dataset.item; app.globalData.weburl = item.ext_link; wx.navigateTo({ url: '/pages/pbService/web/index', }) }, gotoDetail:function(e){ let item = e.currentTarget.dataset.item; util.gotoDetail(item) }, gotoLocation:function(e){ let item = e.currentTarget.dataset.item; wx.openLocation({ latitude: item.lat, longitude: item.lon, name:item.title, address:item.address }) }, gotoFoodInfo:function(e){ let item = e.currentTarget.dataset.item; wx.navigateTo({ url: '/pages/info/foodInfo/index?id='+item.id, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { // this.getList() }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })