123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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',
- })
- },
- })
|