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.
142 lines
4.3 KiB
142 lines
4.3 KiB
4 years ago
|
const api = require('../../utils/api')
|
||
|
const typePageSize = 99
|
||
|
const typePageIndex = 1
|
||
|
Page({
|
||
|
data: {
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
nodata: false,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
selectBarLeft: 0,
|
||
|
teamCategoryList: [],
|
||
|
volunteerTeamList: [],
|
||
|
typeCode: '', // 当前类别code
|
||
|
},
|
||
|
onLoad: function (options) {
|
||
|
|
||
|
},
|
||
|
onShow: function () {
|
||
|
this.setData({
|
||
|
pageIndex: 1,
|
||
|
volunteerTeamList: []
|
||
|
})
|
||
|
const _this = this
|
||
|
const query = wx.createSelectorQuery().in(this)
|
||
|
this.getTeamTypeList().then(getType => {
|
||
|
if (getType) {
|
||
|
query.select('#item1').boundingClientRect()
|
||
|
query.exec(function(res){
|
||
|
_this.setData({
|
||
|
selectBarLeft: res[0].width/2
|
||
|
})
|
||
|
console.log(_this.data.selectBarLeft)
|
||
|
})
|
||
|
this.getAppTeamListByType()
|
||
|
} else {
|
||
|
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
onReachBottom: function () {
|
||
|
this.setData({
|
||
|
loadMoreVisible: true
|
||
|
})
|
||
|
if (this.data.loadMoreType === "loading") {
|
||
|
this.setData({
|
||
|
pageIndex: this.data.pageIndex + 1
|
||
|
})
|
||
|
this.getAppTeamListByType()
|
||
|
}
|
||
|
},
|
||
|
// 前往团队介绍
|
||
|
toTeamDetail (e) {
|
||
|
let id = e.currentTarget.dataset.id
|
||
|
wx.navigateTo({
|
||
|
url: `../teamIntroduction/teamIntroduction?id=${id}`
|
||
|
})
|
||
|
},
|
||
|
// 分类导航切换
|
||
|
onChangeClassifyTab (e) {
|
||
|
let code = e.currentTarget.dataset.code
|
||
|
this.data.teamCategoryList.forEach((item, index) => {
|
||
|
if (index === e.currentTarget.dataset.tab) {
|
||
|
item.select = true
|
||
|
const _this = this
|
||
|
const query = wx.createSelectorQuery().in(this)
|
||
|
query.select(`#item${index + 1}`).boundingClientRect()
|
||
|
query.exec(function(res){
|
||
|
_this.setData({
|
||
|
selectBarLeft: res[0].width/2
|
||
|
})
|
||
|
console.log(_this.data.selectBarLeft)
|
||
|
})
|
||
|
} else {
|
||
|
item.select = false
|
||
|
}
|
||
|
})
|
||
|
this.setData({
|
||
|
teamCategoryList: this.data.teamCategoryList,
|
||
|
typeCode: code,
|
||
|
pageIndex: 1,
|
||
|
volunteerTeamList: []
|
||
|
}, () => {
|
||
|
this.getAppTeamListByType()
|
||
|
})
|
||
|
},
|
||
|
// 获取团队类别列表
|
||
|
getTeamTypeList () {
|
||
|
let param = {
|
||
|
pageSize : typePageSize,
|
||
|
pageIndex : typePageIndex,
|
||
|
teamId: ''
|
||
|
}
|
||
|
return new Promise ((resolve, reject) => {
|
||
|
api.getTeamTypeList(param).then(res => {
|
||
|
if (res.code == 0 && res.msg == 'success') {
|
||
|
res.data[0].select = true
|
||
|
this.setData({
|
||
|
teamCategoryList: res.data,
|
||
|
typeCode: res.data[0].typeCode
|
||
|
})
|
||
|
resolve(true)
|
||
|
}
|
||
|
reject(false)
|
||
|
}).catch(err => {
|
||
|
reject(false)
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
// 获取团队列表
|
||
|
getAppTeamListByType () {
|
||
|
const para = {
|
||
|
pageIndex: this.data.pageIndex,
|
||
|
pageSize: this.data.pageSize,
|
||
|
typeCode: this.data.typeCode
|
||
|
}
|
||
|
api.getAppTeamListByType(para).then(res => {
|
||
|
console.log(res)
|
||
|
this.setData({
|
||
|
volunteerTeamList: [...this.data.volunteerTeamList,...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.volunteerTeamList.length == 0) {
|
||
|
this.setData({
|
||
|
nodata: true,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
})
|
||
|
}
|
||
|
}).catch(err => {
|
||
|
this.setData({
|
||
|
volunteerTeamList: [],
|
||
|
nodata: true,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
})
|
||
|
console.log(err)
|
||
|
})
|
||
|
}
|
||
|
})
|