// pages/near/index.js import request from '../../utils/request' Page({ /** * 页面的初始数据 */ data: { list:[], categoryId:0, keyword:'', pageNum:1, pageSize:10, longitude:0, latitude:0 }, listTap(e){ let id = e.currentTarget.dataset.id wx.navigateTo({ url: '/pages/shopList/businessDetail?id='+id, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, release(e){ wx.navigateTo({ url: '/pages/article/publish2' }) }, getData(){ let data ={ longitude:this.data.longitude, latitude:this.data.latitude, keyword:this.data.keyword, orderBy:1, pageNum:this.data.pageNum, pageSize:this.data.pageSize } request._post('/firefly/store/search/list',data, res=>{ if(res.retCode == 0){ if(res.body.length>0){ var listdata = this.data.list listdata.push.apply(listdata, res.body) this.setData({ list:listdata, pageNum:++res.pageInfo.pageNum }) }else{ if(this.data.pageNum != 1){ setTimeout(() => { wx.showToast({ title: '没有更多数据', icon: 'none', duration: 2000 }) }, 200); } } } } ) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { var _this = this _this.getData() // wx.getLocation({ // type: 'wgs84', // success(res) { // _this.setData({ // latitude:res.latitude, // longitude:res.longitude // }) // _this.setData({ // list:[], // pageNum:1 // }) // _this.getData() // } // }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })