|
|
|
// pages/heartNew/heartNew.js
|
|
|
|
const app = getApp()
|
|
|
|
var api = require('../../utils/activity.js')
|
|
|
|
import {
|
|
|
|
getTimestamp
|
|
|
|
} from '../../utils/common'
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
statusHeight: 0, // 自定义头部状态栏高度
|
|
|
|
navigationHeight: 0, // 自定义头部导航栏高度
|
|
|
|
selectedTab: 'tab0',
|
|
|
|
// banner 相关
|
|
|
|
banner: [],
|
|
|
|
indicatorDots: false, //指示点
|
|
|
|
autoplay: true, //true false,//自动播放
|
|
|
|
circular: true, //衔接滑动
|
|
|
|
interval: 4000, //自动播放间隔时长(ms)
|
|
|
|
duration: 500, //幻灯片切换时长(ms)
|
|
|
|
currentSwiper: 0,
|
|
|
|
// banner 相关end
|
|
|
|
// 列表相关
|
|
|
|
loadMoreVisible: false, //false
|
|
|
|
loadMoreType: 'none', //loading none
|
|
|
|
dingdan: false,//判断订单列表隐藏
|
|
|
|
jingcai: true,//判断精彩列表隐藏
|
|
|
|
indexPage: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
qkdat: false,//判断是否清空数据
|
|
|
|
actId: '',//判断返回以后是否需要刷新列表
|
|
|
|
volunteerlist:[],//志愿者列表
|
|
|
|
listLength:0,//数据长度判断是否需要加载
|
|
|
|
getImgUrl:'',
|
|
|
|
ifClickImage:false,//因为志友多多点击图片查看大图,会出现列表刷新的bug,所以加这个字段进行控制
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.bannerListV2()
|
|
|
|
this.getImgUrl()//获取配置图片
|
|
|
|
this.setData({
|
|
|
|
statusHeight: app.globalData.deviceInfo.statusHeight,
|
|
|
|
navigationHeight: app.globalData.deviceInfo.navigationHeight,
|
|
|
|
})
|
|
|
|
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 0,
|
|
|
|
qkdat: true,
|
|
|
|
selectedTab:this.data.selectedTab
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-0").getActivityList(parms)
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
if(this.data.selectedTab == 'tab1'){//刷新志友
|
|
|
|
if(this.data.ifClickImage){//如果为true就不可以刷新,判断完成以后重新置为false
|
|
|
|
this.setData({
|
|
|
|
ifClickImage: false
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: false,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
indexPage: 1,
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
dingdan: true,
|
|
|
|
jingcai: true,
|
|
|
|
volunteerlist:[],//列表置空
|
|
|
|
listLength:0
|
|
|
|
})
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
}
|
|
|
|
this.volunteerlist(parms)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.data.actId) {
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: false,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
indexPage: 1,
|
|
|
|
})
|
|
|
|
this.updateActivityList()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// tab 切换
|
|
|
|
tabBarChange(e) {
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: false,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
indexPage: 1,
|
|
|
|
})
|
|
|
|
if (e.currentTarget.dataset.tab == 'tab0') {
|
|
|
|
this.setData({
|
|
|
|
dingdan: false,
|
|
|
|
jingcai: true,
|
|
|
|
})
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 0,//活动列表类型(0-招募令,1-精彩活动)
|
|
|
|
qkdat: true,
|
|
|
|
selectedTab:e.currentTarget.dataset.tab
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-0").getActivityList(parms)
|
|
|
|
} else if (e.currentTarget.dataset.tab == 'tab1') {
|
|
|
|
this.setData({
|
|
|
|
dingdan: true,
|
|
|
|
jingcai: true,
|
|
|
|
volunteerlist:[],//列表置空
|
|
|
|
listLength:0
|
|
|
|
})
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
}
|
|
|
|
this.volunteerlist(parms)
|
|
|
|
} else if (e.currentTarget.dataset.tab == 'tab2') {
|
|
|
|
this.setData({
|
|
|
|
dingdan: true,
|
|
|
|
jingcai: false,
|
|
|
|
})
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 1,//活动列表类型(0-招募令,1-精彩活动)
|
|
|
|
qkdat: true,
|
|
|
|
selectedTab:e.currentTarget.dataset.tab
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-2").getActivityList(parms)
|
|
|
|
} else if (e.currentTarget.dataset.tab == 'tab3') {
|
|
|
|
this.setData({
|
|
|
|
dingdan: true,
|
|
|
|
jingcai: true,
|
|
|
|
})
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/subpages/heart/pages/leaderboardNew/leaderboardNew`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
selectedTab: e.currentTarget.dataset.tab
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 返回以后刷新列表
|
|
|
|
updateActivityList() {
|
|
|
|
if ((this.data.selectedTab === 'tab0')) {
|
|
|
|
let params = {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 0,
|
|
|
|
actId: this.data.actId,
|
|
|
|
selectedTab:this.data.selectedTab
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-0").updateActivityList(params)
|
|
|
|
} else if (this.data.selectedTab === 'tab2') {
|
|
|
|
let params = {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 1,
|
|
|
|
actId: this.data.actId,
|
|
|
|
selectedTab:this.data.selectedTab
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-2").updateActivityList(params)
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
actId: ''
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 志愿者列表
|
|
|
|
volunteerlist(params){
|
|
|
|
let that = this
|
|
|
|
api.volunteerlist(params).then(function (res) {
|
|
|
|
if (res.data.length !== that.data.pageSize) {
|
|
|
|
that.setData({
|
|
|
|
loadMoreVisible: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
that.setData({
|
|
|
|
listLength:res.data.length,
|
|
|
|
volunteerlist:that.data.volunteerlist.concat(res.data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//返回上一级
|
|
|
|
goback() {
|
|
|
|
wx.navigateBack({
|
|
|
|
delta: 1
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// banner 切换
|
|
|
|
swiperChange: function (e) {
|
|
|
|
this.setData({
|
|
|
|
currentSwiper: e.detail.current
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 通过判断列表的长度断定是否显示加载中
|
|
|
|
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
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
clickImage(e){
|
|
|
|
this.setData({
|
|
|
|
ifClickImage: e.detail,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
this.bannerListV2()
|
|
|
|
},
|
|
|
|
bannerListV2: function () {
|
|
|
|
let that = this
|
|
|
|
let params = {
|
|
|
|
bannerType:"0"
|
|
|
|
}
|
|
|
|
api.bannerList(params).then(function (res) {
|
|
|
|
that.setData({
|
|
|
|
banner: res.data
|
|
|
|
})
|
|
|
|
wx.stopPullDownRefresh();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取配置图片
|
|
|
|
getImgUrl:function(){//0:咨询热线
|
|
|
|
let that = this
|
|
|
|
api.getImgUrl('0').then(function (res) {
|
|
|
|
that.setData({
|
|
|
|
getImgUrl: res.data[0]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
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.selectedTab == 'tab0') {
|
|
|
|
this.setData({
|
|
|
|
indexPage: this.data.indexPage + 1
|
|
|
|
})
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 0,
|
|
|
|
selectedTab:this.data.selectedTab
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-0").getActivityList(parms)
|
|
|
|
}else if(this.data.selectedTab == 'tab1'){
|
|
|
|
this.setData({
|
|
|
|
indexPage: this.data.indexPage + 1
|
|
|
|
})
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
}
|
|
|
|
this.volunteerlist(parms)
|
|
|
|
} else if (this.data.selectedTab == 'tab2') {
|
|
|
|
this.setData({
|
|
|
|
indexPage: this.data.indexPage + 1
|
|
|
|
})
|
|
|
|
let parms = {
|
|
|
|
pageIndex: this.data.indexPage,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 1,
|
|
|
|
selectedTab:this.data.selectedTab
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-2").getActivityList(parms)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
//跳转志愿者认证页面
|
|
|
|
govolunteer() {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/subpages/heart/pages/volunteer/volunteer`
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//拨打电话
|
|
|
|
getPhone(e) {
|
|
|
|
// return false
|
|
|
|
wx.showModal({
|
|
|
|
title: '拨打电话',
|
|
|
|
content: ``,
|
|
|
|
cancelColor: '#29B9A5',
|
|
|
|
confirmColor: '#29B9A5',
|
|
|
|
success: (res) => {
|
|
|
|
if (res.confirm) {
|
|
|
|
console.log('用户点击确定')
|
|
|
|
wx.makePhoneCall({
|
|
|
|
phoneNumber: e.currentTarget.dataset.number
|
|
|
|
})
|
|
|
|
} else if (res.cancel) {
|
|
|
|
console.log('用户点击取消')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|