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.
388 lines
9.3 KiB
388 lines
9.3 KiB
import { getTimestamp } from "../../../../utils/common"
|
|
const api = require("../../../../utils/api")
|
|
var api_banner = require("../../../../utils/activity.js")
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
selectTab: "tab1",
|
|
selectedTab_B: "tab0",
|
|
typeList: [{ //排名方式:0-周,1-月
|
|
type: "tab0",
|
|
name: "审核中",
|
|
select: true
|
|
},
|
|
{
|
|
type: "tab1",
|
|
name: "已通过",
|
|
select: false
|
|
},
|
|
{
|
|
type: "tab4",
|
|
name: "未通过",
|
|
select: false
|
|
}, {
|
|
type: "tab5",
|
|
name: "已结束",
|
|
select: false
|
|
}
|
|
],
|
|
// 积分排行榜相关
|
|
datalenght: null,
|
|
loveRankingList: [],
|
|
preloadVisible: true,
|
|
// 列表相关
|
|
loadMoreVisible: false,
|
|
loadMoreType: "none",
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
signedList: [],
|
|
timer: "",
|
|
timestamp: getTimestamp(),
|
|
jilu: true,
|
|
banner:[],
|
|
rankId: '0',
|
|
rankTabList: [
|
|
{
|
|
id: '0',
|
|
label: '公益排名'
|
|
},
|
|
// {
|
|
// id: '1',
|
|
// label: '参与次数'
|
|
// },
|
|
// {
|
|
// id: '2',
|
|
// label: '公益积分'
|
|
// },
|
|
{
|
|
id: '3',
|
|
label: '公益积分'
|
|
}
|
|
],
|
|
pioneerList: []
|
|
},
|
|
// tab 切换
|
|
onTabChange (e) {
|
|
this.setData({
|
|
selectTab: e.currentTarget.dataset.tab,
|
|
pageNo: 1
|
|
})
|
|
|
|
if (e.currentTarget.dataset.tab == "tab3") {
|
|
this.setData({
|
|
jilu: false,
|
|
signedList: []
|
|
})
|
|
this.getSignedList()
|
|
} else if (e.currentTarget.dataset.tab == 'tab2') {
|
|
this.setData({
|
|
jilu: true,
|
|
pioneerList: []
|
|
})
|
|
this.getVolunteerPioneerList()
|
|
} else {
|
|
this.setData({
|
|
jilu: true,
|
|
loveRankingList: [],
|
|
})
|
|
this.loadLoveRanking()
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function () {
|
|
this.loadLoveRanking()
|
|
this.bannerListV2()
|
|
this.setData({
|
|
timestamp: getTimestamp(),
|
|
})
|
|
},
|
|
bannerListV2: function () {
|
|
let that = this
|
|
let params = {
|
|
bannerType:"2"
|
|
}
|
|
api_banner.bannerList(params).then(function (res) {
|
|
that.setData({
|
|
banner: res.data
|
|
})
|
|
})
|
|
},
|
|
preViewImage (e) {
|
|
let list = [];
|
|
list.push(this.data.banner[e.currentTarget.dataset.listIndex].bannerImg)
|
|
console.log(list)
|
|
if (e.currentTarget.dataset.listIndex+1 < this.data.banner.length) {
|
|
list.push(this.data.banner[e.currentTarget.dataset.listIndex+1].bannerImg)
|
|
}
|
|
wx.previewImage({
|
|
urls: list,
|
|
current: e.currentTarget.dataset.src
|
|
})
|
|
},
|
|
// 加载 爱心互助排行榜
|
|
loadLoveRanking () {
|
|
if (this.data.rankId == '3') {
|
|
this.getCharityPoints()
|
|
return
|
|
}
|
|
this.setData({
|
|
// loveRankingList: [],
|
|
preloadVisible: true
|
|
})
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
type: this.data.rankId
|
|
}
|
|
api.leaderboard(para).then(res => {
|
|
this.setData({
|
|
datalenght: res.data.length
|
|
})
|
|
// res.data.forEach((item) => {
|
|
// this.data.loveRankingList.push(item)
|
|
// })
|
|
this.setData({
|
|
loveRankingList: [ ...this.data.loveRankingList, ...res.data ],
|
|
loadMoreType: res.data.length === 10 ? "loading" : "none",
|
|
preloadVisible: false
|
|
})
|
|
}).catch(() => {
|
|
this.setData({
|
|
datalenght:0,
|
|
loveRankingList: [],
|
|
loadMoreType: "none",
|
|
preloadVisible: false
|
|
})
|
|
})
|
|
},
|
|
|
|
// 获取志愿先锋 列表
|
|
getVolunteerPioneerList() {
|
|
let params = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize
|
|
}
|
|
api.getVolunteerPioneerList(params).then(res => {
|
|
this.setData({
|
|
pioneerList: [ ...this.data.pioneerList, ...res.data ],
|
|
loadMoreType: res.data.length === 10 ? "loading" : "none",
|
|
preloadVisible: false
|
|
})
|
|
}).catch(() => {
|
|
this.setData({
|
|
pioneerList: [],
|
|
loadMoreType: "none",
|
|
preloadVisible: false
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
if(this.data.selectTab == "tab3"){
|
|
this.pulldownRefresh()
|
|
}
|
|
if (!app.globalData.previewImage) {
|
|
console.log("过滤previewImage引起的onShow")
|
|
}
|
|
app.globalData.previewImage = false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
// 参与记录切换
|
|
onButtonChange: function (e) {
|
|
const list = this.data.typeList
|
|
let that = this;
|
|
list.forEach(item => {
|
|
if (item.type === e.currentTarget.dataset.type) {
|
|
item.select = true
|
|
} else {
|
|
item.select = false
|
|
}
|
|
})
|
|
that.setData({
|
|
typeList: list,
|
|
selectedTab_B: e.currentTarget.dataset.type
|
|
})
|
|
|
|
this.pulldownRefresh()
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
this.pullDownRefresh = this.selectComponent("#pulldown-refresh")
|
|
},
|
|
onPageScroll (e) {
|
|
this.pullDownRefresh.onPageScroll(e)
|
|
},
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.setData({
|
|
loadMoreVisible: true
|
|
})
|
|
if (this.data.loadMoreType === "loading") {
|
|
this.setData({
|
|
pageNo: this.data.pageNo + 1
|
|
})
|
|
if(this.data.selectTab == "tab3") {
|
|
this.getSignedList()
|
|
} else if(this.data.selectTab == 'tab1') {
|
|
this.loadLoveRanking()
|
|
} else if(this.data.selectTab == 'tab2') {
|
|
this.getVolunteerPioneerList()
|
|
}
|
|
}
|
|
},
|
|
// 列表 下拉刷新, 初始化加载
|
|
pulldownRefresh () {
|
|
this.setData({
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
loadMoreVisible: false,
|
|
loadMoreType: "none",
|
|
preloadVisible: true,
|
|
signedList: [],
|
|
timestamp: getTimestamp()
|
|
})
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: this.data.timestamp,
|
|
actType: this.data.selectedTab_B.substr(3, 1)
|
|
}
|
|
api.getSignedList(para).then(res => {
|
|
this.pullDownRefresh.stopRefresh()
|
|
// console.log('已报名活动', res)
|
|
this.setData({
|
|
signedList: [...res.data],
|
|
loadMoreType: res.data.length === 10 ? "loading" : "none",
|
|
preloadVisible: false
|
|
})
|
|
}).catch(err => {
|
|
this.pullDownRefresh.stopRefresh()
|
|
this.setData({
|
|
signedList: [],
|
|
loadMoreType: "none",
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 列表 上拉加载
|
|
getSignedList () {
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: this.data.timestamp,
|
|
actType: this.data.selectedTab_B.substr(3, 1)
|
|
}
|
|
api.getSignedList(para).then(res => {
|
|
// console.log('已报名活动', res.data.length)
|
|
this.setData({
|
|
signedList: [...this.data.signedList, ...res.data],
|
|
loadMoreType: res.data.length === 10 ? "loading" : "none",
|
|
preloadVisible: false
|
|
})
|
|
}).catch(err => {
|
|
this.setData({
|
|
signedList: [],
|
|
loadMoreType: "none",
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
}).finally(() => {
|
|
this.pullDownRefresh.stopRefresh()
|
|
})
|
|
},
|
|
|
|
// 查看详情
|
|
toDetail (e) {
|
|
if (this.data.selectedTab === "tab4") {
|
|
wx.navigateTo({
|
|
url: `/subpages/heart/pages/refusedOrEndedDetail/refusedOrEndedDetail?id=${e.detail.detailId}`
|
|
})
|
|
} else if (e.detail.actCurrentState == 5) {
|
|
wx.navigateTo({
|
|
url: `/subpages/heart/pages/cancelDetail/cancelDetail?id=${e.detail.detailId}`
|
|
})
|
|
} else {
|
|
wx.navigateTo({
|
|
url: `/subpages/heart/pages/heartDetail/heartDetail?id=${e.detail.detailId}`
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
|
|
//选择排序列
|
|
changeTag (e) {
|
|
const id = e.currentTarget.dataset.id
|
|
this.setData({
|
|
rankId: id,
|
|
loveRankingList: [],
|
|
pageNo: 1
|
|
})
|
|
this.loadLoveRanking()
|
|
},
|
|
// 加载 公益积分记录
|
|
getCharityPoints () {
|
|
this.setData({
|
|
// loveRankingList: [],
|
|
preloadVisible: true
|
|
})
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize
|
|
}
|
|
api.getCharityPoints(para).then(res => {
|
|
this.setData({
|
|
datalenght: res.data.length
|
|
})
|
|
// res.data.forEach((item) => {
|
|
// this.data.loveRankingList.push(item)
|
|
// })
|
|
this.setData({
|
|
loveRankingList: [ ...this.data.loveRankingList, ...res.data ],
|
|
loadMoreType: res.data.length === 10 ? "loading" : "none",
|
|
preloadVisible: false
|
|
})
|
|
}).catch(() => {
|
|
this.setData({
|
|
datalenght:0,
|
|
loveRankingList: [],
|
|
loadMoreType: "none",
|
|
preloadVisible: false
|
|
})
|
|
})
|
|
},
|
|
})
|