//index.js import fetch from '../../../utils/http' //获取应用实例 const app = getApp() const $api = require('../../../config/api.js').$api Component({ behaviors: [], properties: {}, data: { UserInfo: app.globalData.UserInfo, NavList: [{ value: '楼盘资讯', id: '' }, { value: '精彩活动', id: '' }], NavActiveIndex: 0, ListA: [], ListB: [], PostDataA: { PageNum: 1, PageSize: 10000 }, PostDataB: { PageNum: 1, PageSize: 10000 } }, lifetimes: {}, ready: function() { this.GetProjectList() this.GetActivityList() let _self = this wx.getSystemInfo({ success(res) { _self.setData({ WindowHeight: res.windowHeight }) } }) }, pageLifetimes: { show: function() {}, }, methods: { GetActivityList() { // 获取活动列表 fetch({ url: $api.activity.list.url + '?pageNum=' + this.data.PostDataB.PageNum + '&pageSize=' + this.data.PostDataB.PageSize, method: $api.activity.list.method }).then((res) => { if (res.code === 200) { let arr = res.data.records || [] let pArr = this.data.ListB arr.map((item) => { pArr.push({ Title: item.title, CreateDate: item.publicDate, Org: item.buildingName, Img: item.imgUrl, Id: item.activityId }) }) this.setData({ ListB: pArr, PostDataB: { PageNum: res.data.total === this.data.ListB.length ? this.data.PostDataB.PageNum : this.data.PostDataB.PageNum + 1, PageSize: this.data.PostDataB.PageSize } }) } }) }, GetProjectList() { // 获取项目动态列表 fetch({ url: $api.dynamic.list.url + '?pageNum=' + this.data.PostDataA.PageNum + '&pageSize=' + this.data.PostDataA.PageSize, method: $api.dynamic.list.method }).then((res) => { if (res.code === 200) { let arr = res.data.records || [] let pArr = this.data.ListA arr.map((item) => { pArr.push({ Title: item.title, CreateDate: item.createDate, Org: item.buildingName, Img: item.imgUrl, Id: item.dynamicId }) }) this.setData({ ListA: pArr, PostDataA: { PageNum: res.data.total === this.data.ListA.length ? this.data.PostDataA.PageNum : this.data.PostDataA.PageNum + 1, PageSize: this.data.PostDataA.PageSize } }) } }) }, CutNav(e) { // 切换nav if (e.target.dataset.index !== undefined && e.target.dataset.index !== this.data.NavActiveIndex) { this.setData({ NavActiveIndex: e.target.dataset.index }) this.triggerEvent('tabChange', e.target.dataset.index) } }, ItemTap(e) { wx.navigateTo({ url: '/pages/ActivityDetail/index?type=' + e.target.dataset.type + '&id=' + e.target.dataset.id }) } } })