|
|
|
const api = require('../../utils/api')
|
|
|
|
import { getTimestamp } from "../../../../utils/common"
|
|
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
statusHeight: 0, // 自定义头部状态栏高度
|
|
|
|
navigationHeight: 0, // 自定义头部导航栏高度
|
|
|
|
selectTab: "tab1",
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
loadMoreVisible: false,
|
|
|
|
loadMoreType: "none",
|
|
|
|
list: [], // 团队成员列表
|
|
|
|
teamDetail: {},
|
|
|
|
teamId: '',
|
|
|
|
dialogVisible: false,
|
|
|
|
dialogTitle: "",
|
|
|
|
dialogContent: "",
|
|
|
|
dialogConfirmText: "",
|
|
|
|
dialogCancelText: "",
|
|
|
|
content: '',
|
|
|
|
shortContent: '',
|
|
|
|
isShowAll: true, // 是否显示全部内容
|
|
|
|
isShowButton: false, // 是否显示 展开-收起 按钮
|
|
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.setData({
|
|
|
|
statusHeight: app.globalData.deviceInfo.statusHeight,
|
|
|
|
navigationHeight: app.globalData.deviceInfo.navigationHeight
|
|
|
|
})
|
|
|
|
if (options.id) {
|
|
|
|
this.setData({
|
|
|
|
teamId: options.id
|
|
|
|
})
|
|
|
|
this.getAppTeamDetail()
|
|
|
|
}
|
|
|
|
if (this.data.selectTab == 'tab1') {
|
|
|
|
this.setData({
|
|
|
|
list: [],
|
|
|
|
})
|
|
|
|
this.getTeamVolunteerList()
|
|
|
|
} else {
|
|
|
|
let params = {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 0,
|
|
|
|
qkdat: true,
|
|
|
|
selectedTab: 'tab0',
|
|
|
|
teamId: this.data.teamId
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-0").getActivityList(params)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
onUnload: function () {
|
|
|
|
this.setData({
|
|
|
|
isShowAll: false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onReachBottom: function () {
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: true
|
|
|
|
})
|
|
|
|
if (this.data.loadMoreType === "loading") {
|
|
|
|
this.setData({
|
|
|
|
pageIndex: this.data.pageIndex + 1
|
|
|
|
})
|
|
|
|
this.getTeamVolunteerList()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 返回上一级
|
|
|
|
goback () {
|
|
|
|
wx.navigateBack({
|
|
|
|
delta: 1
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 志愿者认证
|
|
|
|
confirmDialog () {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: "/subpages/heart/pages/volunteer/volunteer"
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 加入团队
|
|
|
|
joinTeam () {
|
|
|
|
let that = this
|
|
|
|
api.getVolunteerVerify().then(res => {
|
|
|
|
if (res.code == 0) {
|
|
|
|
if (res.data && res.data.id) {
|
|
|
|
let param = {
|
|
|
|
volunteerId: this.data.teamDetail.volunteerId,
|
|
|
|
teamId: this.data.teamId
|
|
|
|
}
|
|
|
|
wx.showModal({
|
|
|
|
content: '请确认加入团队',
|
|
|
|
confirmColor: '#04BCA0',
|
|
|
|
success (res) {
|
|
|
|
if (res.confirm) {
|
|
|
|
console.log('用户点击确定')
|
|
|
|
api.joinTeam(param).then(res => {
|
|
|
|
if (res.code == 0 && res.msg == 'success') {
|
|
|
|
wx.showToast({
|
|
|
|
title: '加入成功',
|
|
|
|
icon: 'none',
|
|
|
|
durantion: 2000
|
|
|
|
})
|
|
|
|
that.getAppTeamDetail()
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: res.msg,
|
|
|
|
icon: 'none',
|
|
|
|
durantion: 2000
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else if (res.cancel) {
|
|
|
|
console.log('用户点击取消')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
dialogVisible: !this.data.dialogVisible,
|
|
|
|
dialogTitle: "志愿者认证",
|
|
|
|
dialogContent: ["是否前往认证志愿者"],
|
|
|
|
dialogConfirmText: "是",
|
|
|
|
dialogCancelText: "否"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// tab 切换
|
|
|
|
onTabChange (e) {
|
|
|
|
this.setData({
|
|
|
|
selectTab: e.currentTarget.dataset.tab,
|
|
|
|
pageIndex: 1
|
|
|
|
})
|
|
|
|
|
|
|
|
if (e.currentTarget.dataset.tab == "tab2") {
|
|
|
|
this.setData({
|
|
|
|
list: [],
|
|
|
|
nodata: false
|
|
|
|
})
|
|
|
|
let params = {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
actType: 0,
|
|
|
|
qkdat: true,
|
|
|
|
sponsor: '',
|
|
|
|
selectedTab: 'tab0',
|
|
|
|
teamId: this.data.teamId
|
|
|
|
}
|
|
|
|
this.selectComponent("#state-0").getActivityList(params)
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
list: [],
|
|
|
|
})
|
|
|
|
this.getTeamVolunteerList()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 通过判断列表的长度断定是否显示加载中
|
|
|
|
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
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 团队详情
|
|
|
|
getAppTeamDetail () {
|
|
|
|
api.getAppTeamDetail({ id: this.data.teamId }).then(res => {
|
|
|
|
let html = res.data.content.replace(/<\/?.+?>/g, '').replace(/[ ]/g, '')
|
|
|
|
this.setData({
|
|
|
|
teamDetail: res.data,
|
|
|
|
content: html
|
|
|
|
}, () => {
|
|
|
|
let query = wx.createSelectorQuery().in(this)
|
|
|
|
query.select('.top-text-desc').boundingClientRect()
|
|
|
|
query.exec(res => {
|
|
|
|
// console.log(res[0].height)
|
|
|
|
this.setData({
|
|
|
|
isShowButton: res[0].height > 70,
|
|
|
|
shortContent: res[0].height > 70 ? this.data.content.substring(0, 62) : this.data.content,
|
|
|
|
isShowAll: !this.data.isShowAll
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
showAll () {
|
|
|
|
this.setData({
|
|
|
|
isShowAll: !this.data.isShowAll
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 团队成员列表
|
|
|
|
|
|
|
|
// 获取团队列表
|
|
|
|
getTeamVolunteerList () {
|
|
|
|
const para = {
|
|
|
|
pageIndex: this.data.pageIndex,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
id: this.data.teamId
|
|
|
|
}
|
|
|
|
api.getTeamVolunteerList(para).then(res => {
|
|
|
|
this.setData({
|
|
|
|
list: [...this.data.list,...res.data],
|
|
|
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
|
|
|
|
loadMoreVisible: res.data.length === this.data.pageSize ? false : true,
|
|
|
|
nodata: false,
|
|
|
|
})
|
|
|
|
if (this.data.list.length == 0) {
|
|
|
|
this.setData({
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
this.setData({
|
|
|
|
list: [],
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|