var _request = require('../../../../../utils/request.js') Page({ data: { page: 1, per_page: 10, year: 0, month: 0, nextid: 0, nextmlist: [], mlistitem: {}, btnshow: false, nextshow: true, prevshow: true, upmonth: 0, downmonth: 0, time: Date.parse(new Date()) / 1000, newy: 0, newm: 0 }, onLoad: function (options) { var date = new Date(this.data.time * 1000) var ny = date.getFullYear() var nm = date.getMonth() + 1 this.setData({ nextid: parseInt(options.id), year: parseInt(options.year), month: parseInt(options.month), upmonth: parseInt(options.month) - 1, downmonth: parseInt(options.month) + 1, newy: ny, newm: nm }) this.getmonthlist() }, getmonthlist () { var that = this var url = 'v1/invite/' + that.data.nextid + '/monthly/slist' var params = { page: that.data.page, per_page: that.data.per_page, cache: false, y: that.data.year, m: that.data.month, } var success = function (res) { var result = that.data.nextmlist.concat(res.data.list || []) if (that.data.year == that.data.newy && that.data.month == that.data.newm) { that.setData({ nextshow: false }) } if (res.data.list_count > 10) { that.setData({ btnshow: true }) } if (res.data.list.length) { var result = res.data.list that.setData({ nextmlist: result, page: that.data.page + 1, per_page: that.data.per_page }) } else { that.setData({ btnshow: false }) } that.setData({ mlistitem : res.data, }) } _request.$get(url, params, success) }, getmonthlist1 () { var that = this var url = 'v1/invite/' + that.data.nextid + '/monthly/slist' var params = { page: that.data.page, per_page: that.data.per_page, cache: false, y: that.data.year, m: that.data.month, } var success = function (res) { // var result = that.data.nextmlist.concat(res.data.list || []) if (res.data.list_count > 10) { that.setData({ btnshow: true }) } if (res.data.list.length) { var result = that.data.nextmlist.concat(res.data.list || []) that.setData({ nextmlist: result, page: that.data.page + 1, per_page: that.data.per_page }) } else { that.setData({ btnshow: false }) } that.setData({ mlistitem : res.data, }) } _request.$get(url, params, success) }, prevmonth () { wx.showLoading({ title: '加载中', duration: 1000 }) var that = this var m = that.data.month var y = that.data.year var ny = that.data.newy var nm = that.data.newm m = m - 1 if (m < 1) { m = 12 y = y - 1 } that.setData({ month: m, year: y, upmonth: m - 1, downmonth: m + 1, page: 1, // mlist: [] }) if (y === ny && m < nm) { that.setData({ nextshow: true }) } if (y < ny) { that.setData({ nextshow: true }) } if (y === 2018 && m === 7) { that.setData({ prevshow: false }) } that.getmonthlist() }, nextmonth () { wx.showLoading({ title: '加载中', duration: 1000 }) var that = this var m = that.data.month var y = that.data.year var ny = that.data.newy var nm = that.data.newm m = m + 1 if (m > 12) { m = 1 y = y + 1 } that.setData({ prevshow: true, month: m, year: y, upmonth: m - 1, downmonth: m + 1, page: 1, // mlist: [] }) if (y === ny && m >= nm) { that.setData({ nextshow: false }) } if (y < ny) { that.setData({ nextshow: true }) } that.getmonthlist() }, })