index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. const app = require('../../utils/util.js');
  2. const tool = require('../../utils/tool.js');
  3. Page({
  4. data: {
  5. currentIndex: 0,
  6. arr: [],
  7. arr1: [],
  8. isInfo: false,
  9. isTargetInfo: false,
  10. letterStatus: true,
  11. lbArr: [{
  12. src: '../../images/lb2.png'
  13. },
  14. // {src:'../../images/lb2.png'},
  15. // {src:'../../images/lb2.png'}
  16. ]
  17. },
  18. // 轮播
  19. handleChange: function (e) {
  20. this.setData({
  21. currentIndex: e.detail.current
  22. })
  23. },
  24. // 关闭信件
  25. closeLetter() {
  26. console.log('1')
  27. this.setData({
  28. letterStatus: true
  29. })
  30. wx.setStorageSync('letterStatus', true)
  31. },
  32. goShare() {
  33. wx.redirectTo({
  34. url: '/pages/share/share',
  35. })
  36. },
  37. // 跳转活动详情页面
  38. goActive(e) {
  39. console.log(e)
  40. let id = e.currentTarget.dataset.id
  41. let openId = e.currentTarget.dataset.openid
  42. wx.navigateTo({
  43. url: '/pages/activeDetail/activeDetail?id=' + id + '&openId=' + openId,
  44. })
  45. },
  46. goActiveDefault() {
  47. wx.redirectTo({
  48. url: '/pages/activeDefaultDetails/activeDefaultDetails',
  49. })
  50. },
  51. // 获取活动列表
  52. getActivies() {
  53. wx.request({
  54. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  55. method: "get",
  56. data: {
  57. activeStatus: 0
  58. },
  59. success: (res) => {
  60. console.log(res)
  61. if (res.data.code == 0) {
  62. this.setData({
  63. arr: res.data.actives
  64. })
  65. }
  66. },
  67. complete() {
  68. wx.hideLoading();
  69. }
  70. })
  71. wx.request({
  72. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  73. method: "get",
  74. data: {
  75. activeStatus: 1
  76. },
  77. success: (res) => {
  78. if (res.data.code == 0) {
  79. this.setData({
  80. arr1: res.data.actives
  81. })
  82. }
  83. },
  84. complete() {
  85. wx.hideLoading();
  86. }
  87. })
  88. },
  89. goMy() {
  90. wx.redirectTo({
  91. url: '/pages/personal/personal',
  92. })
  93. },
  94. getIntroduce(id) {
  95. wx.request({
  96. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/introduce',
  97. method: "get",
  98. data: {
  99. introduce: id
  100. },
  101. success: (res) => {
  102. console.log(res, '获取推荐人')
  103. }
  104. })
  105. },
  106. getletterStauts() {
  107. console.log(wx.getStorageSync('letterStatus'))
  108. if (wx.getStorageSync('letterStatus')==true) {
  109. console.log('我缓存里有值是1')
  110. this.setData({
  111. letterStatus: true
  112. })
  113. // this.closeLetter();
  114. }else{
  115. console.log('我没有缓存、')
  116. this.setData({
  117. letterStatus: false
  118. })
  119. }
  120. console.log(this.data.letterStatus)
  121. },
  122. onLoad(options) {
  123. this.getletterStauts();
  124. wx.showLoading();
  125. tool.openidStatus().then(result => {
  126. this.setData({
  127. openid: result[0],
  128. sessionkey: result[1],
  129. })
  130. this.getActivies();
  131. if (options.id) {
  132. this.getIntroduce(options.id);
  133. }
  134. })
  135. },
  136. onShow() {
  137. this.getActivies();
  138. this.getletterStauts();
  139. }
  140. })