锦水居民端小程序
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.

633 lines
17 KiB

// pages/heartNew/heartNew.js
const app = getApp()
var api = require("../../utils/activity.js")
var heartBehavior = require("../../utils/heartBehavior")
5 years ago
import {
getTimestamp
} from "../../utils/common"
Page({
behaviors: [heartBehavior],
/**
* 页面的初始数据
*/
data: {
statusHeight: 0, // 自定义头部状态栏高度
navigationHeight: 0, // 自定义头部导航栏高度
selectedTab: "tab0",
5 years ago
// banner 相关
5 years ago
banner: [],
indicatorDots: false, // 指示点
autoplay: true, // true false,//自动播放
circular: true, // 衔接滑动
interval: 4000, // 自动播放间隔时长(ms)
duration: 500, // 幻灯片切换时长(ms)
5 years ago
currentSwiper: 0,
5 years ago
// banner 相关end
5 years ago
// 列表相关
loadMoreVisible: false, // false
loadMoreType: "none", // loading none
dingdan: false, // 判断订单列表隐藏
jingcai: true, // 判断精彩列表隐藏
5 years ago
indexPage: 1,
pageSize: 10,
qkdat: false, // 判断是否清空数据
actId: "", // 判断返回以后是否需要刷新列表
volunteerlist:[],// 志愿者列表
volunteerCount: 0, // 志愿者注册数
listLength:0, // 数据长度判断是否需要加载
getImgUrl:"", // 顶部咨询电话图片
5 years ago
ifClickImage:false,//因为志友多多点击图片查看大图,会出现列表刷新的bug,所以加这个字段进行控制
tabFixed: false,
searchName: '',
infoCompleted: 0, //是否完善了用户信息
completeInfoDialogVisible: false,
volunteerTagId: '',//志愿者标签id
tagList: [
{
tagName: '全部',
id: ''
}
],
isLoading: false, //防止标签切换加载数据时点击切换标签
btnTop: 0,
btnLeft: 0,
shouye: {},
scanBtn: {}, // 扫码签到改为可配置
applyBtn: {}, // 申请发单按钮改为可配置,
searchActive: '', //
searchJingcai: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function () {
this.loadBehavior()
5 years ago
this.bannerListV2()
this.getVolunteerTags()
this.setData({
statusHeight: app.globalData.deviceInfo.statusHeight,
navigationHeight: app.globalData.deviceInfo.navigationHeight,
infoCompleted: app.globalData.infoCompleted
})
5 years ago
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
timestamp: getTimestamp(),
actType: 0,
5 years ago
qkdat: true,
sponsor: this.data.searchActive,
5 years ago
selectedTab:this.data.selectedTab
5 years ago
}
this.selectComponent("#state-0").getActivityList(parms)
this.setData({
btnTop: app.globalData.screen.height * 2 * 0.75,
btnLeft: (app.globalData.screen.width * 2 - 200) * 0.5
})
5 years ago
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
4 years ago
if (app.globalData.volunteerChange) {
app.globalData.volunteerChange = false
this.getUserState()
return
}
if(this.data.selectedTab == "tab1"){//刷新志友
5 years ago
if(this.data.ifClickImage){//如果为true就不可以刷新,判断完成以后重新置为false
this.setData({
ifClickImage: false
})
}else{
5 years ago
this.setData({
loadMoreVisible: false,
loadMoreType: "none",
5 years ago
indexPage: 1,
})
5 years ago
this.setData({
dingdan: true,
jingcai: true,
volunteerlist:[],//列表置空
listLength:0
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
nickname: this.data.searchName,
volunteerTagId: this.data.volunteerTagId
5 years ago
}
this.volunteerlist(parms)
5 years ago
}
} else if (this.data.selectedTab == "tab3") {
this.setData({
dingdan: false,
jingcai: true,
selectedTab: 'tab0'
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
timestamp: getTimestamp(),
actType: 0,//活动列表类型(0-招募令,1-精彩活动)
qkdat: true,
sponsor: this.data.searchActive,
selectedTab:this.data.selectedTab
}
this.selectComponent("#state-0").getActivityList(parms)
5 years ago
}
5 years ago
if (this.data.actId) {
5 years ago
this.setData({
loadMoreVisible: false,
loadMoreType: "none",
5 years ago
indexPage: 1,
})
5 years ago
this.updateActivityList()
}
},
5 years ago
// tab 切换
tabBarChange (e) {
5 years ago
this.setData({
loadMoreVisible: false,
loadMoreType: "none",
5 years ago
indexPage: 1,
searchActive: '',
searchJingcai: ''
5 years ago
})
if (e.currentTarget.dataset.tab == "tab0") {
5 years ago
this.setData({
dingdan: false,
jingcai: true,
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
timestamp: getTimestamp(),
actType: 0,//活动列表类型(0-招募令,1-精彩活动)
5 years ago
qkdat: true,
sponsor: this.data.searchActive,
5 years ago
selectedTab:e.currentTarget.dataset.tab
5 years ago
}
this.selectComponent("#state-0").getActivityList(parms)
} else if (e.currentTarget.dataset.tab == "tab1") {
5 years ago
this.setData({
dingdan: true,
jingcai: true,
volunteerlist:[],//列表置空
listLength:0,
searchName: ''
5 years ago
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
nickname: this.data.searchName,
volunteerTagId: this.data.volunteerTagId
5 years ago
}
this.volunteerlist(parms)
} else if (e.currentTarget.dataset.tab == "tab2") {
5 years ago
this.setData({
dingdan: true,
jingcai: false,
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
timestamp: getTimestamp(),
actType: 1,//活动列表类型(0-招募令,1-精彩活动)
5 years ago
qkdat: true,
sponsor: this.data.searchJingcai,
5 years ago
selectedTab:e.currentTarget.dataset.tab
5 years ago
}
this.selectComponent("#state-2").getActivityList(parms)
} else if (e.currentTarget.dataset.tab == "tab3") {
5 years ago
this.setData({
dingdan: true,
jingcai: true,
})
5 years ago
wx.navigateTo({
url: "/subpages/heart/pages/leaderboardNew/leaderboardNew"
5 years ago
})
}
5 years ago
this.setData({
selectedTab: e.currentTarget.dataset.tab
})
},
5 years ago
// 返回以后刷新列表
updateActivityList () {
if ((this.data.selectedTab === "tab0")) {
5 years ago
let params = {
pageIndex: 1,
pageSize: 10,
timestamp: getTimestamp(),
actType: 0,
5 years ago
actId: this.data.actId,
sponsor: this.data.searchActive,
5 years ago
selectedTab:this.data.selectedTab
5 years ago
}
this.selectComponent("#state-0").updateActivityList(params)
} else if (this.data.selectedTab === "tab2") {
5 years ago
let params = {
pageIndex: 1,
pageSize: 10,
timestamp: getTimestamp(),
actType: 1,
5 years ago
actId: this.data.actId,
sponsor: this.data.searchJingcai,
5 years ago
selectedTab:this.data.selectedTab
5 years ago
}
this.selectComponent("#state-2").updateActivityList(params)
}
this.setData({
actId: ""
5 years ago
})
},
// 志愿者列表
volunteerlist (params){
5 years ago
let that = this
api.volunteerV2list(params).then(function (res) {
if (res.data.volunteerList.length !== that.data.pageSize) {
5 years ago
that.setData({
loadMoreVisible: true,
loadMoreType: "none",
5 years ago
})
}
5 years ago
that.setData({
listLength:res.data.volunteerList.length,
volunteerlist:that.data.volunteerlist.concat(res.data.volunteerList),
volunteerCount: res.data.volunteerCount,
isLoading: false
5 years ago
})
})
},
5 years ago
//返回上一级
goback () {
5 years ago
wx.navigateBack({
delta: 1
})
},
// banner 切换
5 years ago
swiperChange: function (e) {
5 years ago
this.setData({
currentSwiper: e.detail.current
})
},
5 years ago
// 通过判断列表的长度断定是否显示加载中
toActDetailDown (e) {
5 years ago
if (e.detail.listLength !== this.data.pageSize) {
this.setData({
loadMoreVisible: true,
loadMoreType: "none",
5 years ago
})
}
this.setData({
actId: e.detail.actId,
listLength: e.detail.listLength
})
},
clickImage (e){
5 years ago
this.setData({
ifClickImage: e.detail,
})
},
bindInputValue (e) {
this.setData({
4 years ago
searchName: e.detail.value.trim('')
})
},
searchName () {
console.log(this.data.searchName)
if(!this.data.searchName) {
wx.showToast({
title: '请输入搜索的昵称',
icon: 'none',
duration: 2000
})
return;
}
this.setData({
volunteerlist: [],
indexPage: 1
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
nickname: this.data.searchName,
volunteerTagId: this.data.volunteerTagId
}
this.volunteerlist(parms)
},
bindInputValueActive (e) {
if ((this.data.selectedTab === "tab0")) {
this.setData({
searchActive: e.detail.value.trim('')
})
} else if (this.data.selectedTab === "tab2") {
this.setData({
searchJingcai: e.detail.value.trim('')
})
}
},
searchActive () {
if ((this.data.selectedTab === "tab0")) {
let params = {
pageIndex: 1,
pageSize: 10,
timestamp: getTimestamp(),
actType: 0,
qkdat: true,
sponsor: this.data.searchActive,
selectedTab:this.data.selectedTab
}
this.selectComponent("#state-0").getActivityList(params)
} else if (this.data.selectedTab === "tab2") {
let params = {
pageIndex: 1,
pageSize: 10,
timestamp: getTimestamp(),
actType: 1,
qkdat: true,
sponsor: this.data.searchJingcai,
selectedTab:this.data.selectedTab
}
this.selectComponent("#state-2").getActivityList(params)
}
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
5 years ago
this.bannerListV2()
},
bannerListV2: function () {
let that = this
5 years ago
let params = {
bannerType:"0"
}
api.bannerList(params).then(function (res) {
5 years ago
that.setData({
banner: res.data
})
wx.stopPullDownRefresh();
})
},
// 获取志愿者标签列表
getVolunteerTags () {
api.getVolunteerTags().then(res => {
if (res.code == 0 && res.msg == 'success') {
const tagList = this.data.tagList.concat(res.data)
console.log('志愿者标签列表: ', tagList)
this.setData({
tagList
})
}
}).catch(err => {
console.log(err)
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
5 years ago
if (this.data.listLength !== this.data.pageSize) {
this.setData({
loadMoreVisible: true,
loadMoreType: "none",
5 years ago
})
} else {
this.setData({
loadMoreVisible: true,
loadMoreType: "loading",
5 years ago
})
}
if (this.data.selectedTab == "tab0") {
5 years ago
this.setData({
indexPage: this.data.indexPage + 1
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
timestamp: getTimestamp(),
5 years ago
actType: 0,
sponsor: this.data.searchActive,
5 years ago
selectedTab:this.data.selectedTab
5 years ago
}
this.selectComponent("#state-0").getActivityList(parms)
}else if(this.data.selectedTab == "tab1"){
5 years ago
this.setData({
indexPage: this.data.indexPage + 1
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
nickname: this.data.searchName,
volunteerTagId: this.data.volunteerTagId
5 years ago
}
this.volunteerlist(parms)
} else if (this.data.selectedTab == "tab2") {
5 years ago
this.setData({
indexPage: this.data.indexPage + 1
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
timestamp: getTimestamp(),
5 years ago
actType: 1,
sponsor: this.data.searchJingcai,
5 years ago
selectedTab:this.data.selectedTab
5 years ago
}
this.selectComponent("#state-2").getActivityList(parms)
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
5 years ago
},
//跳转志愿者认证页面
govolunteer () {
5 years ago
wx.navigateTo({
url: "/subpages/heart/pages/volunteer/volunteer"
5 years ago
})
},
5 years ago
//拨打电话
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("用户点击取消")
}
}
})
},
onPageScroll: function (ev) {
var _this = this;
if (ev.scrollTop <= 0) {
ev.scrollTop = 0;
} else if (ev.scrollTop > wx.getSystemInfoSync().windowHeight) {
ev.scrollTop = wx.getSystemInfoSync().windowHeight;
}
if (ev.scrollTop > 210 || ev.scrollTop == wx.getSystemInfoSync().windowHeight) {
//向下滚动
this.setData({
tabFixed: true
})
} else {
//向上滚动
this.setData({
tabFixed: false
})
}
},
//跳转到我要提交页面
myApply () {
if (this.data.infoCompleted == 0) {
this.setData({
completeInfoDialogVisible: !this.data.completeInfoDialogVisible
})
return false
}
wx.navigateTo({
url: "/subpages/heart/pages/myApply/myApply"
})
},
//banner跳转到详情
toBannerDetail (e) {
wx.navigateTo({
url: `/subpages/heart/pages/bannerDetail/bannerDetail?id=${e.currentTarget.dataset.id}`
})
},
// 跳转 拼团购顺道捎 入口
toJumpPage (e) {
if (e.currentTarget.dataset.code == 'ptg') {
wx.navigateTo({
url: `/subpages/heart/pages/groupBuyList/groupBuyList?title=${e.currentTarget.dataset.title}`
})
} else if (e.currentTarget.dataset.code == 'sds') {
wx.navigateTo({
url: `/subpages/heart/pages/dropByList/dropByList?title=${e.currentTarget.dataset.title}`
})
} else if (e.currentTarget.dataset.code == 'volunteer_sqfd') {
this.myApply()
} else if (e.currentTarget.dataset.code == 'shouye') {
this.toShouye()
}
},
//选择志愿者标签筛选
changeTag (e) {
if (this.data.isLoading) {
wx.showToast({
title: '正在加载...',
icon: 'loading',
})
return
}
const id = e.currentTarget.dataset.id
this.setData({
volunteerTagId: id,
volunteerlist: [],
indexPage: 1,
isLoading: true
})
let parms = {
pageIndex: this.data.indexPage,
pageSize: this.data.pageSize,
nickname: this.data.searchName,
volunteerTagId: this.data.volunteerTagId
}
this.volunteerlist(parms)
},
//扫描签到码
scanCode () {
wx.scanCode({
onlyFromCamera: false,
scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
success: res => {
if (res.errMsg == 'scanCode:ok') {
wx.navigateTo({
url: `/subpages/heart/pages/scanCodeSignin/scanCodeSignin?id=${res.result}`
})
}
},
fail: res => {
// 接口调用失败
// wx.showToast({
// icon: 'none',
// title: '接口调用失败!'
// })
},
complete: res => {
// 接口调用结束
console.log(res)
}
});
},
4 years ago
// 志愿者信息变更,更新用户当前状态
getUserState: function () {
let that = this
wx.login({
success (res) {
if (res.code) {
api.getToken(res.code).then((res) => {
let state = res.data.userState
app.globalData.infoCompleted = state
wx.removeStorageSync("topGridName")
wx.setStorageSync("topGridName", res.data.grid)
wx.removeStorageSync("token")
wx.setStorageSync("token", res.data.token)
that.setData({
infoCompleted: app.globalData.infoCompleted
})
})
} else {
console.log("登录失败" + res.errMsg)
}
}
})
},
//跳转到 页面
toShouye () {
//如果是 详情样式,直接跳转详情页面
if (this.data.shouye.moduleStyle == '4') {
wx.navigateTo({
url: `/subpages/oneKeyService/pages/noticeDetail/noticeDetail?pid=${this.data.shouye.pid}&bannerflag=${this.data.shouye.bannerFlag}&categorycode=${this.data.shouye.categoryCode}&modulestyle=${this.data.shouye.moduleStyle}&categoryname=${this.data.shouye.categoryName}&detailstyle=${this.data.shouye.detailStyle}`
})
} else {
wx.navigateTo({
url: `/subpages/oneKeyService/pages/moduleList/moduleList?pid=${this.data.shouye.id}&bannerflag=${this.data.shouye.bannerFlag}&categorycode=${this.data.shouye.categoryCode}&modulestyle=${this.data.shouye.moduleStyle}&categoryname=${this.data.shouye.categoryName}&detailstyle=${this.data.shouye.detailStyle}`
})
}
},
})