You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
225 lines
5.0 KiB
225 lines
5.0 KiB
var api = require("../../utils/activity.js")
|
|
import {
|
|
getTimestamp
|
|
} from "../../utils/common"
|
|
Page({
|
|
data: {
|
|
index: 0,
|
|
zml: false,
|
|
qkdat: false,
|
|
loadMoreVisible: false, //false
|
|
loadMoreType: "none", //loading none
|
|
indexPage: 1,
|
|
indexPage2: 1,
|
|
pageSize: 10,
|
|
tabs: [{
|
|
key: "tab1",
|
|
title: "Tab 1",
|
|
},
|
|
{
|
|
key: "tab2",
|
|
title: "Tab 2",
|
|
},
|
|
{
|
|
key: "tab3",
|
|
title: "Tab 3",
|
|
},
|
|
],
|
|
key: "",
|
|
actId: "",
|
|
banner: [],
|
|
indicatorDots: false, //指示点
|
|
autoplay: false, //true,//自动播放
|
|
circular: false, //衔接滑动
|
|
interval: 2000, //自动播放间隔时长(ms)
|
|
duration: 500, //幻灯片切换时长(ms)
|
|
currentSwiper: 0
|
|
},
|
|
onLoad: function (options) {
|
|
this.getBannerList()
|
|
const temp = Number(options.state) + 1
|
|
this.setData({
|
|
key: "tab" + temp,
|
|
index: 0 //options.state
|
|
})
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: getTimestamp(),
|
|
actType: 0,
|
|
qkdat: true
|
|
}
|
|
this.selectComponent("#state-0").getActivityList(parms)
|
|
},
|
|
onShow () {
|
|
if (this.data.key === "tab3") {
|
|
this.setData({
|
|
key: "tab1",
|
|
zml: false,
|
|
qkdat: true
|
|
})
|
|
let parms = {
|
|
pageIndex: 1,
|
|
pageSize: this.data.pageSize,
|
|
qkdat: this.data.qkdat,
|
|
timestamp: getTimestamp(),
|
|
actType: 0
|
|
}
|
|
this.selectComponent("#state-0").getActivityList(parms)
|
|
}
|
|
if (this.data.actId) {
|
|
this.updateActivityList()
|
|
}
|
|
},
|
|
onPullDownRefresh: function () {
|
|
this.getBannerList()
|
|
},
|
|
getBannerList: function () {
|
|
let that = this
|
|
api.bannerList().then(function (res) {
|
|
that.setData({
|
|
banner: res.data
|
|
})
|
|
wx.stopPullDownRefresh();
|
|
})
|
|
},
|
|
onReachBottom: function () {
|
|
|
|
if (this.data.listLength !== this.data.pageSize) {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "none",
|
|
})
|
|
} else {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "loading",
|
|
})
|
|
}
|
|
if (this.data.key == "tab1") {
|
|
this.setData({
|
|
index: 0
|
|
})
|
|
}
|
|
if (this.data.index == 0) {
|
|
this.setData({
|
|
indexPage: this.data.indexPage + 1
|
|
})
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: getTimestamp(),
|
|
actType: 0
|
|
}
|
|
this.selectComponent("#state-" + this.data.index).getActivityList(parms)
|
|
} else {
|
|
this.setData({
|
|
indexPage2: this.data.indexPage2 + 1
|
|
})
|
|
let parms = {
|
|
pageIndex: this.data.indexPage2,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: getTimestamp(),
|
|
actType: 1
|
|
}
|
|
this.selectComponent("#state-" + this.data.index).getActivityList(parms)
|
|
}
|
|
},
|
|
changeProperty: function (e) {
|
|
var propertyName = e.currentTarget.dataset.propertyName
|
|
var newData = {}
|
|
newData[propertyName] = e.detail.value
|
|
this.setData(newData)
|
|
},
|
|
swiperChange: function (e) {
|
|
this.setData({
|
|
currentSwiper: e.detail.current
|
|
})
|
|
},
|
|
onTabsChange (e) {
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
loadMoreType: "none",
|
|
})
|
|
const {
|
|
key
|
|
} = e.detail
|
|
const index = this.data.tabs.map((n) => n.key).indexOf(key)
|
|
if (index == 0) {
|
|
this.setData({
|
|
zml: false
|
|
})
|
|
} else {
|
|
this.setData({
|
|
zml: true
|
|
})
|
|
}
|
|
this.setData({
|
|
key,
|
|
index,
|
|
indexPage: 1,
|
|
indexPage2: 1
|
|
})
|
|
if (key == "tab3") {
|
|
wx.navigateTo({
|
|
url: "/subpages/heart/pages/signed/signed"
|
|
})
|
|
} else {
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: getTimestamp(),
|
|
actType: this.data.index,
|
|
qkdat: true
|
|
}
|
|
this.selectComponent("#state-" + this.data.index).getActivityList(parms)
|
|
}
|
|
},
|
|
|
|
toActDetail (e) {
|
|
const id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: `/subpages/heart/pages/heartDetail/heartDetail?id=${id}`
|
|
})
|
|
},
|
|
|
|
toActDetailDown (e) {
|
|
if (e.detail.listLength !== this.data.pageSize) {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "none",
|
|
})
|
|
}
|
|
this.setData({
|
|
actId: e.detail.actId,
|
|
listLength: e.detail.listLength
|
|
})
|
|
},
|
|
toLeaderboard () {
|
|
wx.navigateTo({
|
|
url: "/subpages/heart/pages/leaderboard/leaderboard"
|
|
})
|
|
},
|
|
updateActivityList () {
|
|
if ((this.data.key === "tab1")) {
|
|
this.setData({
|
|
index: 0
|
|
})
|
|
} else if (this.data.key === "tab2") {
|
|
this.setData({
|
|
index: 1
|
|
})
|
|
}
|
|
let params = {
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
timestamp: getTimestamp(),
|
|
actType: this.data.index,
|
|
actId: this.data.actId
|
|
}
|
|
this.selectComponent("#state-" + this.data.index).updateActivityList(params)
|
|
this.setData({
|
|
actId: ""
|
|
})
|
|
}
|
|
})
|