12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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.templateList.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.templateList[target.currentIndex].id
- wx.navigateTo({
- url: `/pages/activityDet/index?id=${id}`,
- })
- },
- jumpMyGreeing() {
- wx.navigateTo({
- url: '/pages/greeting/index',
- })
- },
- })
|