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.
573 lines
18 KiB
573 lines
18 KiB
import {
|
|
getIssueDetail,
|
|
getIssueTypeStatistics,
|
|
getRemarkList,
|
|
showRemarkStatement,
|
|
showIssueStatement,
|
|
getProjectDetail,
|
|
getProjectTypeStatistics,
|
|
getIssueHandleProgressV2,
|
|
getProjectHandleProgressV2
|
|
} from '../../utils/api'
|
|
import { formatTimestamp } from '../../utils/common'
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
loadMoreVisible: false, // loadMoreVisible 和 loadMoreType 控制 超出一屏时的 加载和没有更多的显示与隐藏
|
|
loadMoreType: 'none',
|
|
issueId: '', // 议题id
|
|
projectId: '', // 项目id
|
|
detailId: '', // 页面获得项目或议题id
|
|
detailType: 'issue', // 议题详情 还是 项目详情
|
|
detailObj: { // 详情内容对象
|
|
id: '',
|
|
content: '',
|
|
distributeTime: '',
|
|
partyFlag: '',
|
|
nickname: '',
|
|
avatar: '',
|
|
browseNum: '',
|
|
approveNum: 0,
|
|
opposeNum: '',
|
|
images: '',
|
|
userLike: '',
|
|
categoryCode: '',
|
|
firstCategoryCode: '', // 一级分类code
|
|
userDislike: '',
|
|
isOperational: '',
|
|
address: '',
|
|
operational: true, // 议题是否可操作
|
|
itemState: '', // 项目状态 0-处理中 5-已关闭 10-已结案
|
|
showSatisfactionEvaluation: false,
|
|
issueToProjectId: '', // 项目当中,之前的议题id
|
|
},
|
|
typeStatisticsObj: { // 列表统计对象
|
|
attitudeNum: '',
|
|
categoryCode: '',
|
|
categoryName: '',
|
|
issueNum: '',
|
|
itemNum: ''
|
|
},
|
|
handleProgressList: [], // 处理进展列表
|
|
timeStamp: '', // 加载评论列表 需要的时间戳
|
|
remarkType: 'new', // 评论 最新最热类型
|
|
pageNo: 1, // 页码
|
|
pageSize: 10, // 页长
|
|
remarkObj: { // 评论列表
|
|
statementNum: 0,
|
|
commentsList: []
|
|
},
|
|
supportTimer: '', // 点赞 支持的计时器
|
|
dispportTimer: '', // 点踩 反对的计时器
|
|
dialogVisible: false, // 提示信息探矿所需入参
|
|
dialogTitle: '',
|
|
dialogContent: '',
|
|
dialogConformText: '',
|
|
dialogCancelText: '',
|
|
completeInfoDialogVisible: false, // 完善信息弹窗
|
|
infoCompleted: 0, // 当前用户是否完善信息
|
|
showClassify: 'hide' // 是否显示 议题/项目分类列表
|
|
},
|
|
onLoad (options) {
|
|
if (options.showClassify === 'show') {
|
|
this.setData({
|
|
showClassify: 'show'
|
|
})
|
|
}
|
|
if (options.type === 'issue') {
|
|
this.setData({
|
|
detailType: 'issue',
|
|
detailId: options.detailId,
|
|
issueId: options.detailId
|
|
})
|
|
this.getIssueDetail().then(() => {
|
|
this.getIssueTypeStatistics(this.data.detailObj.firstCategoryCode)
|
|
})
|
|
this.getIssueHandleProgressV2(this.data.issueId).then(res => {
|
|
const handleProgressList = []
|
|
res.forEach((item,index) => {
|
|
if (index === res.length - 1) {
|
|
item.type = 'point'
|
|
item.isFirst = true
|
|
handleProgressList.push(item)
|
|
} else {
|
|
item.type = 'issue'
|
|
item.isFirst = false
|
|
handleProgressList.push(item)
|
|
}
|
|
})
|
|
this.setData({
|
|
handleProgressList
|
|
})
|
|
})
|
|
this.getRemarkList()
|
|
wx.setNavigationBarTitle({
|
|
title: '议题详情'
|
|
})
|
|
} else if (options.type === 'project') {
|
|
wx.setNavigationBarTitle({
|
|
title: '项目详情'
|
|
})
|
|
this.setData({
|
|
detailType: 'project',
|
|
projectId: options.detailId,
|
|
detailId: options.detailId
|
|
})
|
|
this.getProjectDetail().then(() => {
|
|
this.getProjectTypeStatistics(this.data.detailObj.firstCategoryCode)
|
|
Promise.all([this.getIssueHandleProgressV2(this.data.detailObj.issueToProjectId), this.getProjectHandleProgressV2()]).then(res => {
|
|
console.log('项目和议题处理进展', res)
|
|
const issueList = []
|
|
const projectList = []
|
|
res[0].forEach((item,index) => {
|
|
if (index === res[0].length - 1) {
|
|
item.type = 'point'
|
|
item.isFirst = true
|
|
issueList.push(item)
|
|
} else {
|
|
item.type = 'issue'
|
|
item.isFirst = false
|
|
issueList.push(item)
|
|
}
|
|
})
|
|
res[1].forEach((item, index) => {
|
|
if (index === res[1].length - 1) {
|
|
item.type = 'issueToProject'
|
|
item.isFirst = false
|
|
projectList.push(item)
|
|
} else {
|
|
item.type = 'project'
|
|
item.isFirst = false
|
|
projectList.push(item)
|
|
}
|
|
})
|
|
this.setData({
|
|
handleProgressList: [...projectList, ...issueList]
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
})
|
|
this.getRemarkList()
|
|
|
|
}
|
|
this.setData({
|
|
infoCompleted: app.globalData.infoCompleted
|
|
})
|
|
},
|
|
onReachBottom () {
|
|
this.setData({
|
|
loadMoreVisible: true
|
|
})
|
|
if (this.data.loadMoreType === 'loading') {
|
|
this.setData({
|
|
pageNo: this.data.pageNo + 1
|
|
})
|
|
this.loadMoreGetRemarkList()
|
|
}
|
|
},
|
|
// 获取议题详情
|
|
getIssueDetail () {
|
|
return new Promise((resolve, reject) => {
|
|
getIssueDetail(this.data.issueId).then(res => {
|
|
console.log('议题详情', res)
|
|
const detailObj = {}
|
|
for (const key in this.data.detailObj) {
|
|
detailObj[key] = res.data[key]
|
|
}
|
|
this.setData({
|
|
detailObj
|
|
})
|
|
resolve(true)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
reject(false)
|
|
})
|
|
})
|
|
},
|
|
// 获取项目详情
|
|
getProjectDetail () {
|
|
return new Promise((resolve, reject) => {
|
|
getProjectDetail(this.data.projectId).then(res => {
|
|
console.log('项目详情', res)
|
|
const detailObj = {}
|
|
for (const key in this.data.detailObj) {
|
|
detailObj[key] = res.data[key]
|
|
}
|
|
detailObj.issueToProjectId = res.data.issueId
|
|
this.setData({
|
|
detailObj
|
|
})
|
|
resolve(true)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
reject(false)
|
|
})
|
|
})
|
|
},
|
|
// 议题类别统计
|
|
getIssueTypeStatistics (categoryCode) {
|
|
getIssueTypeStatistics(categoryCode).then(res => {
|
|
console.log('议题类别统计', res)
|
|
const typeStatisticsObj = {}
|
|
for (const key in this.data.typeStatisticsObj) {
|
|
typeStatisticsObj[key] = res.data[key] || ''
|
|
}
|
|
this.setData({
|
|
typeStatisticsObj
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 项目类别统计
|
|
getProjectTypeStatistics (categoryCode) {
|
|
getProjectTypeStatistics(categoryCode).then(res => {
|
|
console.log('项目类别统计', res)
|
|
const typeStatisticsObj = {}
|
|
for (const key in this.data.typeStatisticsObj) {
|
|
typeStatisticsObj[key] = res.data[key] || ''
|
|
}
|
|
this.setData({
|
|
typeStatisticsObj
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 议题处理进展 v2
|
|
getIssueHandleProgressV2 (issueId) {
|
|
return new Promise((resolve, reject) => {
|
|
getIssueHandleProgressV2(issueId).then(res => {
|
|
console.log('议题处理进度v2',res)
|
|
resolve(res.data)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
reject(err)
|
|
})
|
|
})
|
|
},
|
|
// 项目处理进展 v2
|
|
getProjectHandleProgressV2 () {
|
|
return new Promise((resolve, reject) => {
|
|
getProjectHandleProgressV2(this.data.projectId).then(res => {
|
|
console.log('项目处理进展', res)
|
|
resolve(res.data)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
reject(err)
|
|
})
|
|
})
|
|
},
|
|
// 最新最热 评论列表切换
|
|
changeRemarkType (e) {
|
|
this.setData({
|
|
remarkType: e.detail.type,
|
|
loadMoreVisible: false
|
|
})
|
|
this.getRemarkList()
|
|
},
|
|
// 获取评论列表 下拉刷新
|
|
getRemarkList () {
|
|
this.setData({
|
|
timeStamp: formatTimestamp(),
|
|
pageNo: 1,
|
|
pageSize: 10
|
|
})
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: this.data.timestamp,
|
|
orderType: this.data.remarkType === 'new' ? 0 : 1,
|
|
issueId: this.data.detailType === 'issue' ? this.data.issueId : '',
|
|
itemId: this.data.detailType === 'project' ? this.data.projectId : ''
|
|
}
|
|
getRemarkList(para).then(res => {
|
|
console.log('评论列表', res)
|
|
this.setData({
|
|
remarkObj: {
|
|
statementNum: res.data.statementNum,
|
|
commentsList: [...res.data.commentsList]
|
|
},
|
|
loadMoreType: res.data.commentsList.length === 10 ? 'loading' : 'none'
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取评论列表 上拉加载
|
|
loadMoreGetRemarkList () {
|
|
const para = {
|
|
pageIndex: this.data.pageNo,
|
|
pageSize: this.data.pageSize,
|
|
timestamp: this.data.timestamp,
|
|
orderType: this.data.remarkType === 'new' ? 0 : 1,
|
|
issueId: this.data.detailType === 'issue' ? this.data.issueId : '',
|
|
itemId: this.data.detailType === 'project' ? this.data.projectId : ''
|
|
}
|
|
getRemarkList(para).then(res => {
|
|
console.log('评论列表', res)
|
|
this.setData({
|
|
remarkObj: {
|
|
statementNum: res.data.statementNum,
|
|
commentsList: [...this.data.remarkObj.commentsList,...res.data.commentsList]
|
|
},
|
|
loadMoreType: res.data.commentsList.length === 10 ? 'loading' : 'none'
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
debounceSupportRemark (e) {
|
|
clearTimeout(this.data.supportTimer)
|
|
this.data.supportTimer = setTimeout(() => {
|
|
this.supportRemark(e)
|
|
}, 300)
|
|
},
|
|
// 评论 支持 点赞
|
|
supportRemark (e) {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
if(this.verifyState()) {
|
|
return false
|
|
}
|
|
const hasAttitude = this.data.remarkObj.commentsList.some(item => item.commentId === e.detail.commentId && (item.userLike || item.userDislike))
|
|
if (hasAttitude) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['已表达过态度,不可以更改哦!'],
|
|
dialogTitle: '已表态',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return false
|
|
}
|
|
const index = this.data.remarkObj.commentsList.findIndex(item => item.commentId === e.detail.commentId)
|
|
this.setData({
|
|
[`remarkObj.commentsList[${index}].userLike`]: true,
|
|
[`remarkObj.commentsList[${index}].approveNum`]: parseInt(this.data.remarkObj.commentsList[index].approveNum) + 1,
|
|
['remarkObj.statementNum']: parseInt(this.data.remarkObj.statementNum) + 1
|
|
})
|
|
const para = {
|
|
attitude: '0',
|
|
commentId: e.detail.commentId,
|
|
issueId: this.data.detailType === 'issue' ? this.data.issueId : '',
|
|
itemId: this.data.detailType === 'project' ? this.data.projectId : ''
|
|
}
|
|
showRemarkStatement(para).then(res => {
|
|
console.log('评论支持', res)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
debounceDispportRemark (e) {
|
|
clearTimeout(this.data.dispportTimer)
|
|
this.data.dispportTimer = setTimeout(() => {
|
|
this.dispportRemark(e)
|
|
}, 300)
|
|
},
|
|
// 评论 不支持 点踩
|
|
dispportRemark (e) {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
if(this.verifyState()) {
|
|
return false
|
|
}
|
|
const hasAttitude = this.data.remarkObj.commentsList.some(item => item.commentId === e.detail.commentId && (item.userLike || item.userDislike))
|
|
if (hasAttitude) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['已表达过态度,不可以更改哦!'],
|
|
dialogTitle: '已表态',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return false
|
|
return false
|
|
}
|
|
const index = this.data.remarkObj.commentsList.findIndex(item => item.commentId === e.detail.commentId)
|
|
this.setData({
|
|
[`remarkObj.commentsList[${index}].userDislike`]: true,
|
|
[`remarkObj.commentsList[${index}].opposeNum`]: parseInt(this.data.remarkObj.commentsList[index].opposeNum) + 1,
|
|
['remarkObj.statementNum']: parseInt(this.data.remarkObj.statementNum) + 1
|
|
})
|
|
const para = {
|
|
attitude: '1',
|
|
commentId: e.detail.commentId,
|
|
issueId: this.data.detailType === 'issue' ? this.data.issueId : '',
|
|
itemId: this.data.detailType === 'project' ? this.data.projectId : ''
|
|
}
|
|
showRemarkStatement(para).then(res => {
|
|
console.log('评论不支持', res)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 对 议题/项目 进行评论
|
|
navigateToReply () {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
if(this.verifyState()) {
|
|
return false
|
|
}
|
|
wx.navigateTo({
|
|
url: `/subpages/discussion/pages/remarkOrReply/remarkOrReply?detailId=${this.data.detailId}&faCommentId=&detailType=${this.data.detailType}`
|
|
})
|
|
},
|
|
// 评论 回复 回调
|
|
replyRemark (e) {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
if(this.verifyState()) {
|
|
return false
|
|
}
|
|
wx.navigateTo({
|
|
url: `/subpages/discussion/pages/remarkOrReply/remarkOrReply?detailId=${this.data.detailId}&faCommentId=${e.detail.commentId}&detailType=${this.data.detailType}`
|
|
})
|
|
},
|
|
debounceSupportIssueOrProject () {
|
|
clearTimeout(this.data.supportTimer)
|
|
this.data.supportTimer = setTimeout(() => {
|
|
this.supportIssueOrProject()
|
|
}, 300)
|
|
},
|
|
// 点赞 议题或评论
|
|
supportIssueOrProject () {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
if(this.verifyState()) {
|
|
return false
|
|
}
|
|
if (this.data.detailObj.userDislike || this.data.detailObj.userLike) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['已表达过态度,不可以更改哦!'],
|
|
dialogTitle: '已表态',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return false
|
|
}
|
|
this.setData({
|
|
['detailObj.userLike']: true,
|
|
['detailObj.approveNum']: parseInt(this.data.detailObj.approveNum) + 1
|
|
})
|
|
const para = {
|
|
attitude: '0',
|
|
issueId: this.data.detailType === 'issue' ? this.data.issueId : '',
|
|
itemId: this.data.detailType === 'project' ? this.data.projectId : ''
|
|
}
|
|
showIssueStatement(para).then(res => {
|
|
console.log('点赞议题或项目', res)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
debounceDispportIssueOrProject () {
|
|
clearTimeout(this.data.dispportTimer)
|
|
this.data.dispportTimer = setTimeout(() => {
|
|
this.dispportIssueOrProject()
|
|
}, 300)
|
|
},
|
|
// 点踩 议题活评论
|
|
dispportIssueOrProject () {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
if(this.verifyState()) {
|
|
return false
|
|
}
|
|
if (this.data.detailObj.userDislike || this.data.detailObj.userLike) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['已表达过态度,不可以更改哦!'],
|
|
dialogTitle: '已表态',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return false
|
|
}
|
|
this.setData({
|
|
['detailObj.userDislike']: true,
|
|
['detailObj.opposeNum']: parseInt(this.data.detailObj.opposeNum) + 1
|
|
})
|
|
const para = {
|
|
attitude: '1',
|
|
issueId: this.data.detailType === 'issue' ? this.data.issueId : '',
|
|
itemId: this.data.detailType === 'project' ? this.data.projectId : ''
|
|
}
|
|
showIssueStatement(para).then(res => {
|
|
console.log('点踩议题或项目', res)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 跳转到 分类列表
|
|
navigateToCategoryList () {
|
|
if (this.data.showClassify === 'show') {
|
|
wx.navigateTo({
|
|
url: `/subpages/discussion/pages/categoryList/categoryList?type=${this.data.detailType}&categoryCode=${this.data.detailObj.firstCategoryCode}`
|
|
})
|
|
}
|
|
},
|
|
// 满意度评价
|
|
publishEvaluation () {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
if (this.data.detailObj.itemState !== 10) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['项目未处理完毕或已关闭','不能进行评价!'],
|
|
dialogTitle: '满意度评价',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return false
|
|
}
|
|
wx.navigateTo({
|
|
url: `/subpages/discussion/pages/publishEvaluation/publishEvaluation?itemId=${this.data.projectId}`
|
|
})
|
|
},
|
|
// 检查 议题/项目的状态
|
|
verifyState () {
|
|
if (this.data.detailType === 'issue' && !this.data.detailObj.operational) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['议题已关闭,不可再进行','评论/回复/支持/不支持等表达态度'],
|
|
dialogTitle: '已关闭',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return true
|
|
} else if (this.data.detailType === 'project') {
|
|
if (this.data.detailObj.itemState === 5) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['项目已关闭,不可再进行','评论/回复/支持/不支持等表达态度'],
|
|
dialogTitle: '已关闭',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return true
|
|
} else if (this.data.detailObj.itemState === 10) {
|
|
this.setData({
|
|
dialogConformText: '知道了',
|
|
dialogContent: ['项目已结案,不可再进行','评论/回复/支持/不支持等表达态度'],
|
|
dialogTitle: '已结案',
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
return true
|
|
}
|
|
}
|
|
},
|
|
// 检查 是否完善信息
|
|
verifyCompleteInfo () {
|
|
if (this.data.infoCompleted == 0) {
|
|
this.setData({
|
|
completeInfoDialogVisible: !this.data.completeInfoDialogVisible
|
|
})
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
})
|