var t = getApp(); Page({ data: { token: t.globalData.token, newsType: [], curType: "", page: { page: 1, rows: 10, newsTypeId: "" }, newsList: [], serviceUrl: t.baseUrls.serviceUrl, baseImgUrl: t.baseUrls.baseImgUrl }, getNewsType: function () { var a = this; t.restAjax.get(t.restAjax.path(t.apis.getNewsType, [t.baseUrls.requestUrl]), { showArea: "6dcbb862-4b48-4dca-aee1-d78fd76adc05" }, { headers: { token: a.data.token } }, function (t, s) { var n; a.setData({ newsType: s, "page.newsTypeId": s[0].newsTypeId, "curType": s[0].newsTypeId }); a.getNewsList(); }, function (e, t) { console.log(t); }); }, changeType: function (t) { var a, s = t.currentTarget.dataset.id; this.setData({ curType: s, "page.newsTypeId": s, "page.page": 1 }); this.getNewsList(); }, getNewsList: function () { var a = this; t.restAjax.get(t.restAjax.path(t.apis.getNewsList, [t.baseUrls.requestUrl]), a.data.page, { headers: { token: a.data.token } }, function (t, s) { for (var n = 0; n < s.rows.length; n++) s.rows[n].photo && (s.rows[n].photo = s.rows[n].photo.split(",")); if (1 == a.data.page.page) a.setData({ newsList: s.rows }); else if (s.rows.length > 0) { for (var o = a.data.newsList, r = 0; r < s.rows.length; r++) o.push(s.rows[r]); a.setData({ newsList: o }); } else wx.showToast({ title: "暂无更多", icon: "none" }), a.setData(e({}, "page.page", a.data.page.page - 1)); }, function (e, t) { console.log(t); }); }, checkDetail: function (e) { var t = e.currentTarget.dataset.id; wx.navigateTo({ url: "../news/newsDetail?newsId=" + t }); }, onLoad: function (e) { this.setData({ token: t.globalData.token }), this.getNewsType(); }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onReachBottom: function () { this.setData(e({}, "page.page", this.data.page.page + 1)), this.getNewsList(); }, onShareAppMessage: function () { } });