|
|
|
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: "",
|
|
|
|
isSignUp: 0,
|
|
|
|
points: 0,
|
|
|
|
grade: 0
|
|
|
|
},
|
|
|
|
completeInfoDialogVisible: false,
|
|
|
|
infoCompleted: 0,
|
|
|
|
changeName:false,
|
|
|
|
visible: false,
|
|
|
|
signMsg: '',
|
|
|
|
signCode: 0
|
|
|
|
},
|
|
|
|
onLoad () {
|
|
|
|
if(app.globalData.infoCompleted == 0 || app.globalData.infoCompleted == 4){//当状态为0 或者 4 的时候 显示完善个人信息其余状态为更改个人信息
|
|
|
|
this.setData({
|
|
|
|
changeName: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
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,
|
|
|
|
timestamp: getTimestamp()
|
|
|
|
}
|
|
|
|
api.getMyTopicListV2(para).then(res => {
|
|
|
|
console.log("我的话题列表", res)
|
|
|
|
this.setData({
|
|
|
|
topicList: [...res.data.topicList],
|
|
|
|
nomoreStatus: res.data.topicList.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,
|
|
|
|
timestamp: getTimestamp()
|
|
|
|
}
|
|
|
|
api.getMyTopicListV2(para).then(res => {
|
|
|
|
console.log("我的话题列表", res)
|
|
|
|
const topicList = [...this.data.topicList, ...res.data.topicList]
|
|
|
|
this.setData({
|
|
|
|
nomoreStatus: res.data.topicList.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",
|
|
|
|
isSignUp: 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 () {
|
|
|
|
this.getUserInfo();//防止积分变化
|
|
|
|
wx.navigateTo({
|
|
|
|
url: "/subpages/integralCentre/pages/index/index?points=" + this.data.userInfo.points
|
|
|
|
})
|
|
|
|
},
|
|
|
|
jqqd () {
|
|
|
|
wx.showToast({
|
|
|
|
title: "敬请期待~",
|
|
|
|
icon: "none",
|
|
|
|
duration: 1000
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 签到 2020.07.24
|
|
|
|
// toSignUp () {
|
|
|
|
// if (this.data.userInfo.isSignUp == 1) {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
// api.userInfoSignUp().then(res => {
|
|
|
|
// console.log(res.data)
|
|
|
|
// if (res.code === 0) {
|
|
|
|
// // 显示提醒
|
|
|
|
// this.setData({
|
|
|
|
// signCode: res.code,
|
|
|
|
// signMsg: res.data,
|
|
|
|
// visible: true
|
|
|
|
// });
|
|
|
|
// } else {
|
|
|
|
// this.setData({
|
|
|
|
// signCode: res.code,
|
|
|
|
// signMsg: res.msg,
|
|
|
|
// visible: true
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
// // 关闭签到提醒
|
|
|
|
// onClose() {
|
|
|
|
// this.getUserInfo()
|
|
|
|
// this.setData({
|
|
|
|
// visible: false
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
})
|