123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- page: 1,
- no_more: false,
- keyword: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (options.keyword) {
- this.setData({keyword:options.keyword});
- }
- this.getList();
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.setData({list:[],page:1,no_more:false,keyword:''});
- this.getList();
- wx.stopPullDownRefresh();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.getList();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- return {
- title: "晋爱人才",
- path: "/pages/home/home/home",
- };
- },
- //列表
- getList() {
- var self = this;
- if (self.data.no_more) {
- return false;
- }
- app.post('portal/articles/index',{
- page:self.data.page,
- keyword:self.data.keyword,
- },function(res){
- if (res.length < 10) {
- self.setData({no_more:true});
- }
- let list = self.data.list;
- list = list.concat(res);
- let page = self.data.page;
- page++;
- self.setData({list:list,page:page});
- });
- },
- //搜索
- bindSearch() {
- this.setData({list:[],page:1,no_more:false});
- this.getList();
- }
- })
|