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.
317 lines
7.8 KiB
317 lines
7.8 KiB
const api = require('../../utils/api')
|
|
import {
|
|
getTimestamp
|
|
} from '../../utils/common'
|
|
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
selectedTabBar: 'issue',
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
timestamp: '',
|
|
issueList: [],
|
|
projectList: [],
|
|
topicList: [],
|
|
nomoreVisible: false,
|
|
nomoreStatus: 'loading',
|
|
preloadVisible: true,
|
|
userInfo: {
|
|
faceImg: '',
|
|
nickname: '',
|
|
partyFlag: '',
|
|
points:0,
|
|
grade:0
|
|
},
|
|
completeInfoDialogVisible: false,
|
|
infoCompleted: 0
|
|
},
|
|
onLoad() {
|
|
this.getUserInfo()
|
|
this.setData({
|
|
infoCompleted: app.globalData.infoCompleted
|
|
})
|
|
},
|
|
onShow() {
|
|
if (!app.globalData.previewImage) {
|
|
this.data.pageNo = 1
|
|
this.data.pageSize = 10
|
|
this.setData({
|
|
nomoreVisible: false,
|
|
nomoreStatus: 'loading',
|
|
preloadVisible: true
|
|
})
|
|
if (this.data.selectedTabBar === 'issue') {
|
|
this.getIssueList()
|
|
} else if (this.data.selectedTabBar === 'project') {
|
|
this.getProjectList()
|
|
} else if (this.data.selectedTabBar === 'topic') {
|
|
this.getTopicList()
|
|
}
|
|
}
|
|
app.globalData.previewImage = false
|
|
},
|
|
|
|
// 触底 上拉加载
|
|
onReachBottom() {
|
|
this.setData({
|
|
nomoreVisible: true
|
|
})
|
|
if (this.data.selectedTabBar === 'topic') {
|
|
if (this.data.nomoreStatus === 'loading') {
|
|
this.data.pageNo = this.data.pageNo + 1
|
|
this.loadMoreTopicList()
|
|
} else {
|
|
this.setData({
|
|
nomoreVisible: true
|
|
})
|
|
}
|
|
} else if (this.data.selectedTabBar === 'project') {
|
|
if (this.data.nomoreStatus === 'loading') {
|
|
this.data.pageNo = this.data.pageNo + 1
|
|
this.loadMoreProjectList()
|
|
} else {
|
|
this.setData({
|
|
nomoreVisible: true
|
|
})
|
|
}
|
|
}
|
|
},
|
|
// tab 切换
|
|
chooseTabBar(e) {
|
|
this.setData({
|
|
nomoreVisible: false,
|
|
nomoreStatus: 'loading',
|
|
preloadVisible: true
|
|
})
|
|
this.data.pageNo = 1
|
|
this.data.pageSize = 10
|
|
if (e.currentTarget.dataset.type === 'issue') {
|
|
this.getIssueList()
|
|
} else if (e.currentTarget.dataset.type === 'project') {
|
|
this.data.pageNo = 1
|
|
this.data.pageSize = 10
|
|
this.getProjectList()
|
|
} else if (e.currentTarget.dataset.type === 'topic') {
|
|
this.getTopicList()
|
|
}
|
|
this.setData({
|
|
selectedTabBar: e.currentTarget.dataset.type
|
|
})
|
|
},
|
|
// 获取 我的话题列表
|
|
getTopicList() {
|
|
this.setData({
|
|
topicList: []
|
|
})
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize
|
|
}
|
|
api.getMyTopicList(para).then(res => {
|
|
console.log('我的话题列表', res)
|
|
this.setData({
|
|
topicList: [...res.data],
|
|
nomoreStatus: res.data.length === 10 ? 'loading' : 'none',
|
|
preloadVisible: false
|
|
})
|
|
}).catch(err => {
|
|
this.setData({
|
|
topicList: [],
|
|
nomoreStatus: 'none',
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取 我的话题列表 上拉加载
|
|
loadMoreTopicList() {
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize
|
|
}
|
|
api.getMyTopicList(para).then(res => {
|
|
console.log('我的话题列表', res)
|
|
const topicList = [...this.data.topicList, ...res.data]
|
|
this.setData({
|
|
nomoreStatus: res.data.length === 10 ? 'loading' : 'none',
|
|
preloadVisible: false,
|
|
topicList,
|
|
})
|
|
}).catch(err => {
|
|
this.setData({
|
|
topicList: [],
|
|
nomoreStatus: 'none',
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取 我的议题列表
|
|
getIssueList() {
|
|
this.setData({
|
|
issueList: []
|
|
})
|
|
api.getMyIssueList().then(res => {
|
|
console.log('我的议题列表', res)
|
|
this.setData({
|
|
issueList: [...res.data],
|
|
nomoreStatus: 'none',
|
|
preloadVisible: false
|
|
})
|
|
}).catch(err => {
|
|
this.setData({
|
|
issueList: [],
|
|
nomoreStatus: 'none',
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取 我的项目列表
|
|
getProjectList() {
|
|
this.setData({
|
|
projectList: []
|
|
})
|
|
this.data.timestamp = getTimestamp()
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: this.data.timestamp
|
|
}
|
|
api.getMyProjectList(para).then(res => {
|
|
console.log('我的项目列表', res)
|
|
this.setData({
|
|
projectList: [...res.data],
|
|
nomoreStatus: res.data.length === 10 ? 'loading' : 'none',
|
|
preloadVisible: false
|
|
})
|
|
}).catch(err => {
|
|
this.setData({
|
|
projectList: [],
|
|
nomoreStatus: 'none',
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取 我的项目列表 上拉加载
|
|
loadMoreProjectList() {
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: this.data.timestamp
|
|
}
|
|
api.getMyProjectList(para).then(res => {
|
|
console.log('我的项目列表', res)
|
|
const projectList = [...this.data.projectList, ...res.data]
|
|
this.setData({
|
|
nomoreStatus: res.data.length === 10 ? 'loading' : 'none',
|
|
preloadVisible: false,
|
|
projectList,
|
|
})
|
|
}).catch(err => {
|
|
this.setData({
|
|
projectList: [],
|
|
nomoreStatus: 'none',
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取用户信息
|
|
getUserInfo() {
|
|
api.getUserInfo().then(res => {
|
|
console.log('用户信息', res)
|
|
const userInfo = {}
|
|
for (const key in this.data.userInfo) {
|
|
userInfo[key] = res.data[key]
|
|
}
|
|
this.setData({
|
|
userInfo
|
|
})
|
|
}).catch(err => {
|
|
this.setData({
|
|
userInfo: {
|
|
faceImg: '',
|
|
nickname: '',
|
|
partyFlag: '0',
|
|
points:0,
|
|
grade:0
|
|
}
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 完善信息
|
|
navigateToComplete() {
|
|
wx.navigateTo({
|
|
url: '/pages/complete/complete'
|
|
})
|
|
},
|
|
// 议题列表 跳转详情
|
|
toIssueDetail(e) {
|
|
const {
|
|
issueId,
|
|
state
|
|
} = e.detail
|
|
if (state !== '待审核' && state !== '未通过') {
|
|
wx.navigateTo({
|
|
url: `/subpages/discussion/pages/discussionDetail/discussionDetail?type=issue&detailId=${issueId}`
|
|
})
|
|
} else if (state === '待审核' || state === '未通过') {
|
|
wx.navigateTo({
|
|
url: `/subpages/mine/pages/eventDetail/eventDetail?eventId=${issueId}&eventType=${state}`
|
|
})
|
|
}
|
|
},
|
|
// 项目列表 跳转详情
|
|
toProjectDetail(e) {
|
|
const {
|
|
itemId
|
|
} = e.detail
|
|
wx.navigateTo({
|
|
url: `/subpages/discussion/pages/discussionDetail/discussionDetail?type=project&detailId=${itemId}`
|
|
})
|
|
},
|
|
// 话题列表 跳转详情
|
|
toTopicDetail(e) {
|
|
const {
|
|
topicId
|
|
} = e.detail
|
|
wx.navigateTo({
|
|
url: `/subpages/association/pages/topicDetail/topicDetail?detailId=${topicId}`
|
|
})
|
|
},
|
|
// 我有事说
|
|
addIssue() {
|
|
if (this.data.infoCompleted == 0) {
|
|
this.setData({
|
|
completeInfoDialogVisible: !this.data.completeInfoDialogVisible
|
|
})
|
|
return false
|
|
}
|
|
wx.navigateTo({
|
|
url: '/subpages/discussion/pages/addIssue/addIssue'
|
|
})
|
|
},
|
|
// 跳转到 邀请记录
|
|
navigateToInviteRecord() {
|
|
wx.navigateTo({
|
|
url: '/subpages/mine/pages/inviteRecord/inviteRecord'
|
|
})
|
|
},
|
|
// 跳转到 网格管理
|
|
navigateToGridManage() {
|
|
wx.navigateTo({
|
|
url: '/subpages/mine/pages/gridManage/gridManage'
|
|
})
|
|
},
|
|
//跳转到积分中心
|
|
navigateToIntegralCentre(e) {
|
|
console.log(':::::'+e.currentTarget.dataset.points)
|
|
wx.navigateTo({
|
|
url: `/subpages/integralCentre/pages/index/index?points=` + e.currentTarget.dataset.points
|
|
})
|
|
}
|
|
})
|