12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- var app = getApp();
- const util = require('../../utils/utils.js');
- Page({
- data: {
- notice:[],
- links:null,
- page:1,
- img:app.globalData.imgUrl
- },
- onLoad: function (options) {
- this.notice()
- },
- notice: function () {
- var that = this;
- var area_id = ''
- if (wx.getStorageSync('home').id != undefined) {
- area_id = wx.getStorageSync('home').id
- }
- var data = {
- 'area_id': area_id
- }
- app.request("/ans", data, "GET").then(res => {
- console.log(res)
- that.setData({ notice: res.data.data,links:res.data.meta.pagination.links})
- }).catch(err => {
- console.log(err)
- })
- },
- detail: util.throttle(function (e) {
- console.log(e)
- var id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '../public_details/public_details?id=' + id,
- })
- }, 1000),
- onReady: function () {
- },
- onShow: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- wx.showNavigationBarLoading();
- var that = this;
- var area_id = ''
- if (wx.getStorageSync('home').id != undefined) {
- area_id = wx.getStorageSync('home').id
- }
- var data = {
- 'area_id': area_id
- }
- app.request("/ans", data, "GET").then(res => {
- console.log(res)
- that.setData({ notice: res.data.data, links: res.data.meta.pagination.links })
- wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
- })
- },
- onReachBottom: function () {
- var that = this;
- if (this.data.links == null) {
- wx.showToast({
- title: '没有更多了',
- icon: 'none'
- })
- } else {
- var area_id = '';
- var page = that.data.page + 1;
- if (wx.getStorageSync('home').id != undefined) {
- area_id = wx.getStorageSync('home').id
- }
- var data = {
- 'area_id': area_id
- }
- app.request("/ans?page=" + page, data, "GET").then(res => {
- console.log(res)
- that.setData({ notice: that.data.notice.concat(res.data.data), links: res.data.meta.pagination.links, page })
- }).catch(err => {
- console.log(err)
- })
- }
- },
- onShareAppMessage: function () {
- }
- })
|