index.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //index.js
  2. import fetch from '../../../utils/http'
  3. //获取应用实例
  4. const app = getApp()
  5. const $api = require('../../../config/api.js').$api
  6. Component({
  7. behaviors: [],
  8. properties: {},
  9. data: {
  10. UserInfo: app.globalData.UserInfo,
  11. NavList: [{
  12. value: '楼盘资讯',
  13. id: ''
  14. }, {
  15. value: '精彩活动',
  16. id: ''
  17. }],
  18. NavActiveIndex: 0,
  19. ListA: [],
  20. ListB: [],
  21. PostDataA: {
  22. PageNum: 1,
  23. PageSize: 10000
  24. },
  25. PostDataB: {
  26. PageNum: 1,
  27. PageSize: 10000
  28. }
  29. },
  30. lifetimes: {},
  31. ready: function() {
  32. this.GetProjectList()
  33. this.GetActivityList()
  34. let _self = this
  35. wx.getSystemInfo({
  36. success(res) {
  37. _self.setData({
  38. WindowHeight: res.windowHeight
  39. })
  40. }
  41. })
  42. },
  43. pageLifetimes: {
  44. show: function() {},
  45. },
  46. methods: {
  47. GetActivityList() { // 获取活动列表
  48. fetch({
  49. url: $api.activity.list.url + '?pageNum=' + this.data.PostDataB.PageNum + '&pageSize=' + this.data.PostDataB.PageSize,
  50. method: $api.activity.list.method
  51. }).then((res) => {
  52. if (res.code === 200) {
  53. let arr = res.data.records || []
  54. let pArr = this.data.ListB
  55. arr.map((item) => {
  56. pArr.push({
  57. Title: item.title,
  58. CreateDate: item.publicDate,
  59. Org: item.buildingName,
  60. Img: item.imgUrl,
  61. Id: item.activityId
  62. })
  63. })
  64. this.setData({
  65. ListB: pArr,
  66. PostDataB: {
  67. PageNum: res.data.total === this.data.ListB.length ? this.data.PostDataB.PageNum : this.data.PostDataB.PageNum + 1,
  68. PageSize: this.data.PostDataB.PageSize
  69. }
  70. })
  71. }
  72. })
  73. },
  74. GetProjectList() { // 获取项目动态列表
  75. fetch({
  76. url: $api.dynamic.list.url + '?pageNum=' + this.data.PostDataA.PageNum + '&pageSize=' + this.data.PostDataA.PageSize,
  77. method: $api.dynamic.list.method
  78. }).then((res) => {
  79. if (res.code === 200) {
  80. let arr = res.data.records || []
  81. let pArr = this.data.ListA
  82. arr.map((item) => {
  83. pArr.push({
  84. Title: item.title,
  85. CreateDate: item.createDate,
  86. Org: item.buildingName,
  87. Img: item.imgUrl,
  88. Id: item.dynamicId
  89. })
  90. })
  91. this.setData({
  92. ListA: pArr,
  93. PostDataA: {
  94. PageNum: res.data.total === this.data.ListA.length ? this.data.PostDataA.PageNum : this.data.PostDataA.PageNum + 1,
  95. PageSize: this.data.PostDataA.PageSize
  96. }
  97. })
  98. }
  99. })
  100. },
  101. CutNav(e) { // 切换nav
  102. if (e.target.dataset.index !== undefined && e.target.dataset.index !== this.data.NavActiveIndex) {
  103. this.setData({
  104. NavActiveIndex: e.target.dataset.index
  105. })
  106. this.triggerEvent('tabChange', e.target.dataset.index)
  107. }
  108. },
  109. ItemTap(e) {
  110. wx.navigateTo({
  111. url: '/pages/ActivityDetail/index?type=' + e.target.dataset.type + '&id=' + e.target.dataset.id
  112. })
  113. }
  114. }
  115. })