import { getActivityList } from '~/api/activity' Page({ /** * 页面的初始数据 */ data: { banner: '', cardActivityList: [], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.getActivityList() }, async getActivityList() { let { banner, cardActivityList } = await getActivityList() cardActivityList.forEach(item => { item.currentIndex = 0 }) console.log(cardActivityList); this.setData({ cardActivityList, banner }) }, // 换一换 changeTemplate({ currentTarget }) { let index = currentTarget.dataset.index let item = currentTarget.dataset.item let nextIndex = item.currentIndex if (item.currentIndex < item.templateTypeList.length - 1) { nextIndex = ++item.currentIndex } else { nextIndex = 0 } this.setData({ [`cardActivityList[${index}].currentIndex`]: nextIndex }) }, toRecording({ currentTarget }) { let index = currentTarget.dataset.index let target = this.data.cardActivityList[index] let id = target.templateTypeList[target.currentIndex].id wx.navigateTo({ url: `/pages/activityDet/index?id=${id}`, }) }, jumpMyGreeing() { wx.navigateTo({ url: '/pages/greeting/index', }) }, })