index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. })
  43. wx.request({
  44. url: app.globalData.publicUrl + '/wx/member/' + this.data.openid + '/actives',
  45. method: "get",
  46. data: {
  47. activeStatus: 1
  48. },
  49. success: (res) => {
  50. if (res.data.code == 0) {
  51. this.setData({
  52. arr1: res.data.actives
  53. })
  54. wx.hideLoading();
  55. }
  56. }
  57. })
  58. },
  59. async onShow() {
  60. wx.showLoading({
  61. title: '加载中',
  62. })
  63. tool.openidStatus().then(result => {
  64. this.setData({
  65. openid: result[0],
  66. sessionkey: result[1]
  67. })
  68. this.getActivies();
  69. })
  70. }
  71. })