index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. },
  11. // 轮播
  12. handleChange: function (e) {
  13. this.setData({
  14. currentIndex: e.detail.current
  15. })
  16. },
  17. // 跳转活动详情页面
  18. goActive(e) {
  19. console.log(e)
  20. let id = e.currentTarget.dataset.id
  21. let openId = e.currentTarget.dataset.openid
  22. wx.navigateTo({
  23. url: '/pages/activeDetail/activeDetail?id=' + id + '&openId=' + openId,
  24. })
  25. },
  26. // 获取活动列表
  27. getActivies() {
  28. wx.request({
  29. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  30. method: "get",
  31. data: {
  32. activeStatus: 0
  33. },
  34. success: (res) => {
  35. console.log(res)
  36. if (res.data.code == 0) {
  37. this.setData({
  38. arr: res.data.actives
  39. })
  40. }
  41. },
  42. complete(){
  43. wx.hideLoading();
  44. }
  45. })
  46. wx.request({
  47. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  48. method: "get",
  49. data: {
  50. activeStatus: 1
  51. },
  52. success: (res) => {
  53. if (res.data.code == 0) {
  54. this.setData({
  55. arr1: res.data.actives
  56. })
  57. }
  58. },
  59. complete(){
  60. wx.hideLoading();
  61. }
  62. })
  63. },
  64. goMy() {
  65. wx.redirectTo({
  66. url: '/pages/personal/personal',
  67. })
  68. },
  69. getIntroduce() {
  70. wx.request({
  71. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/introduce',
  72. method: "get",
  73. data: {
  74. introduce: this.data.introduceId
  75. },
  76. success: (res) => {
  77. console.log(res, '获取推荐人')
  78. }
  79. })
  80. },
  81. onLoad(options) {
  82. wx.showLoading();
  83. tool.openidStatus().then(result => {
  84. this.setData({
  85. openid: result[0],
  86. sessionkey: result[1],
  87. })
  88. this.getActivies();
  89. if (options.id) {
  90. this.setData({
  91. introduceId: options.id
  92. })
  93. this.getIntroduce();
  94. }
  95. })
  96. },
  97. onShow(){
  98. this.getActivies();
  99. }
  100. })