// packageC/Myshaky/searchResult/searchResult.js var app = getApp(); import util from '../../../utils/util.js'; Page({ /** * 页面的初始数据 */ data: { city: '', page:1, keywords:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options); this.setData({ city_name: options.city_name, city: options.city_name, keywords: options.keywords }); this.infrom(); }, goDw(e) { wx.navigateTo({ url: '/packageC/o2o/o2oLocation/o2oLocation?tag=activitySearch', }); }, inpText(e) { this.setData({ inpText: e.detail.value }); }, goSearch(e) { this.setData({ page:1 }); if(!this.data.inpText){ this.setData({ inpText:'' }); } this.infrom(); }, goxq(e){ let activity_id = e.currentTarget.id; if (e.currentTarget.id) { wx.navigateTo({ url: '/packageC/Myshaky/enrollEnter/enrollEnter?id=' + activity_id, }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.current_page < this.data.last_page) { this.setData({ page: this.data.page + 1 }); wx.showLoading({ title: '加载中', mask: true, }); this.nextinfrom(); }else{ wx.showToast({ title: '没有更多', icon: 'none' }); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, nextinfrom(){ let urlStr = app.getNetAddresss("plugin.activity-apply.api.index.getSearch"); let that = this; app._getNetWork({ url: urlStr, data: { city_name: that.data.city_name, keywords: that.data.keywords, page:that.data.page }, success: function (resdata) { var res = resdata.data; if (res.result == 1) { console.log(res); if (res.data.data.length == 0) { that.setData({ kong: true }); } else { that.setData({ kong: false }); } // var timestamp = Date.parse(new Date()); // var timestamps = timestamp / 1000; for (let i = 0; i < res.data.data.length; i++) { res.data.data[i].start_time = util.formatTimeTwo(res.data.data[i].start_time, 'Y/M/D h:m:s'); } if(res.data.current_page >= res.data.last_page){ wx.hideToast(); wx.showToast({ title: '没有更多', icon: 'none' }); that.setData({ current_page: res.data.current_page, last_page: res.data.last_page }); return; }else{ wx.hideToast(); that.setData({ listData:that.data.listData.concat(res.data.data), current_page: res.data.current_page, last_page: res.data.last_page, }); } } }, fail: function (res) { console.log(res); } }); }, infrom() { let urlStr = app.getNetAddresss("plugin.activity-apply.api.index.getSearch"); let that = this; app._getNetWork({ url: urlStr, data: { city_name: that.data.city_name, keywords: that.data.keywords, page:that.data.page }, success: function (resdata) { var res = resdata.data; if (res.result == 1) { console.log(res); if (res.data.data.length == 0) { that.setData({ kong: true }); } else { that.setData({ kong: false }); } var timestamp = Date.parse(new Date()); var timestamps = timestamp / 1000; for (let i = 0; i < res.data.data.length; i++) { res.data.data[i].start_time = util.formatTimeTwo(res.data.data[i].start_time, 'Y/M/D h:m:s'); } that.setData({ listData: res.data.data, nowTime: timestamps, current_page: res.data.current_page, last_page: res.data.last_page }); } }, fail: function (res) { console.log(res); } }); }, });