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, evaluationState:'', issueToProjectId: "", // 项目当中,之前的议题id evaluationScore: "", evaluationContent: "", voice: "", duration: "", solutionInfo:"", }, 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", // 是否显示 议题/项目分类列表 pageName: "", // 从诉求里面过来的 ispeople: ''// 从源项目列表 - 诉求里面过来的 }, onLoad(options) { console.log('::::::::::::::', 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") { if (options.pageName == "appeal" || options.ispeople == '1') { wx.setNavigationBarTitle({ title: "诉求详情", }) }else { wx.setNavigationBarTitle({ title: "项目详情", }) } this.setData({ detailType: "project", projectId: options.detailId, detailId: options.detailId, pageName: options.pageName ? options.pageName : "", ispeople: options.ispeople ? options.ispeople : "", peopleFlag: options.peopleFlag ? options.peopleFlag : "", // 诉求分类:0民生 1发展 }) if (this.data.pageName == "appeal" || this.data.ispeople == '1') { 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 projectList = [] const newProjectList = [] res[0].forEach((item, index) => { // 民生、发展流程只展示 state: 60 结案 11 结案申请 12 || 1001 响应拟办 14 驳回 0吹哨(社区 网格) 1011 1012 1013 满意度评价 // 11 14 隐藏掉 if((item.state == 0 && item.itemDeptDTOS && item.itemDeptDTOS.length > 0) || item.state == 1 || item.state == 15 || item.state == 1011 || item.state == 1012 || item.state == 1013 || item.state == 12 || item.state == 60 || item.state == 1001) { console.log('item', JSON.stringify(item)) newProjectList.push(item) } }) newProjectList.forEach((element, index) => { if (index === newProjectList.length - 1) { element.type = "project" element.isFirst = true projectList.push(element) } else { element.type = "project" element.isFirst = false projectList.push(element) } }); this.setData({ handleProgressList: [...projectList], }) console.log( "11", this.data.handleProgressList, projectList ) }) .catch((err) => { console.log(err) }) }) } else { 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], }) console.log( "11", this.data.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], }, loadMoreVisible: true, loadMoreType: res.data.commentsList.length === 10 ? "loading" : "none", }) if (res.data.commentsList.length == 0) { this.setData({ loadMoreVisible: true, }) } }) .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: this.data.pageName == "appeal" || this.data.ispeople == '1' ? ["诉求未处理完毕,不能进行评价!"] : ["项目未处理完毕或已关闭", "不能进行评价!"], // dialogTitle: "满意度评价", // // dialogVisible: !this.data.dialogVisible, // }) // return false // } wx.navigateTo({ url: `/subpages/discussion/pages/publishEvaluation/publishEvaluation?itemId=${this.data.projectId}&evaluationScore=${this.data.detailObj.evaluationScore}&evaluationContent=${this.data.detailObj.evaluationContent}&pageName=${this.data.pageName == "appeal" || this.data.ispeople == '1' ? 'appeal' : ''}&solutionInfo=${this.data.detailObj.solutionInfo}`, }) }, // 检查 议题/项目的状态 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 } }, //2020.11.2 议题项目转发 onShareAppMessage(res) { console.log( "shareType=discussionDetail" + "&detailId=" + this.data.detailId + "&showClassify=" + this.data.showClassify + "&detailType=" + this.data.detailType + "&nowGridId=" + wx.getStorageSync("gridId") ) return { title: this.data.detailType == "issue" ? "党群议事-议题详情" : "党群议事-项目详情", path: `/pages/index/index?shareType=discussionDetail&detailId=${ this.data.detailId }&showClassify=${this.data.showClassify}&detailType=${ this.data.detailType }&nowGridId=${wx.getStorageSync("gridId")}`, } }, })