index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {
  2. getActivityList
  3. } from '~/api/activity'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. banner: '',
  10. cardActivityList: [],
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad(options) {
  16. this.getActivityList()
  17. },
  18. async getActivityList() {
  19. let {
  20. banner,
  21. cardActivityList
  22. } = await getActivityList()
  23. cardActivityList.forEach(item => {
  24. item.currentIndex = 0
  25. })
  26. console.log(cardActivityList);
  27. this.setData({
  28. cardActivityList,
  29. banner
  30. })
  31. },
  32. // 换一换
  33. changeTemplate({
  34. currentTarget
  35. }) {
  36. let index = currentTarget.dataset.index
  37. let item = currentTarget.dataset.item
  38. let nextIndex = item.currentIndex
  39. if (item.currentIndex < item.templateList.length - 1) {
  40. nextIndex = ++item.currentIndex
  41. } else {
  42. nextIndex = 0
  43. }
  44. this.setData({
  45. [`cardActivityList[${index}].currentIndex`]: nextIndex
  46. })
  47. },
  48. toRecording({
  49. currentTarget
  50. }) {
  51. let index = currentTarget.dataset.index
  52. let target = this.data.cardActivityList[index]
  53. let id = target.templateList[target.currentIndex].id
  54. wx.navigateTo({
  55. url: `/pages/activityDet/index?id=${id}`,
  56. })
  57. },
  58. jumpMyGreeing() {
  59. wx.navigateTo({
  60. url: '/pages/greeting/index',
  61. })
  62. },
  63. onShareAppMessage() {
  64. return {
  65. title: '拜年还能这么玩?语音贺卡超有趣,点我开玩!',
  66. path: `/pages/activityList/index?uid=${wx.getStorageSync('uid')}`,
  67. imageUrl: 'http://reader-wx.ai160.com/images/reader/card/share-new-activity.png'
  68. }
  69. },
  70. onShareTimeline() {
  71. return {
  72. title: '拜年还能这么玩?语音贺卡超有趣,点我开玩!',
  73. query: `uid=${wx.getStorageSync('uid')}`,
  74. imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/xkx_logo.jpg'
  75. }
  76. },
  77. })