7 changed files with 346 additions and 323 deletions
@ -1,318 +1,337 @@ |
|||||
// subpages/associationNew/pages/eventlist/eventlist.js
|
// subpages/associationNew/pages/eventlist/eventlist.js
|
||||
const app = getApp() |
const app = getApp() |
||||
import { topiclist, commentSubmit, statement } from '../../utils/api' |
import { topiclist, commentSubmit, statement } from '../../utils/api' |
||||
import { |
import { |
||||
getTimestamp |
getTimestamp |
||||
} from '../../../../utils/common' |
} from '../../../../utils/common' |
||||
Page({ |
Page({ |
||||
|
|
||||
/** |
/** |
||||
* 页面的初始数据 |
* 页面的初始数据 |
||||
*/ |
*/ |
||||
data: { |
data: { |
||||
topiclist: [], |
topiclist: [], |
||||
timestamp: '', |
timestamp: '', |
||||
pageIndex: 1, |
pageIndex: 1, |
||||
pageSize: 10, |
pageSize: 10, |
||||
partyGroupId: '',//党群id
|
partyGroupId: '',//党群id
|
||||
topicType: '',//0:事好儿鼓个掌 1:话对捧个场
|
topicType: '',//0:事好儿鼓个掌 1:话对捧个场
|
||||
nodata: false, |
nodata: false, |
||||
loadMoreType: 'none', |
loadMoreType: 'none', |
||||
loadMoreVisible: false, |
loadMoreVisible: false, |
||||
bannedFlag: '',//是否禁言 0:否 1:是
|
bannedFlag: '',//是否禁言 0:否 1:是
|
||||
ifcomment: false,//是否显示评论
|
ifcomment: false,//是否显示评论
|
||||
focus: false, |
focus: false, |
||||
topicId: '',//被评论的话题ID
|
topicId: '',//被评论的话题ID
|
||||
commentContent: '', |
commentContent: '', |
||||
index: 0,//点击的第几条数据,用于评论的局部刷新用
|
index: 0,//点击的第几条数据,用于评论的局部刷新用
|
||||
infoCompleted: 0, |
infoCompleted: 0, |
||||
completeInfoDialogVisible: false, |
completeInfoDialogVisible: false, |
||||
ifpreviewImage:false,//解决图片放大刷新列表的问题
|
ifpreviewImage:false,//解决图片放大刷新列表的问题
|
||||
}, |
}, |
||||
/** |
/** |
||||
* 生命周期函数--监听页面加载 |
* 生命周期函数--监听页面加载 |
||||
*/ |
*/ |
||||
onLoad: function (options) { |
onLoad: function (options) { |
||||
this.setData({ |
this.setData({ |
||||
partyGroupId: options.partyGroupId, |
partyGroupId: options.partyGroupId, |
||||
topicType: options.topicType,//0:事好儿鼓个掌 1:话对捧个场
|
topicType: options.topicType,//0:事好儿鼓个掌 1:话对捧个场
|
||||
infoCompleted: app.globalData.infoCompleted |
infoCompleted: app.globalData.infoCompleted |
||||
}) |
}) |
||||
if (options.topicType == 0) { |
if (options.topicType == 0) { |
||||
wx.setNavigationBarTitle({ |
wx.setNavigationBarTitle({ |
||||
title: '事好鼓个掌' |
title: '事好鼓个掌' |
||||
}) |
}) |
||||
} else { |
} else { |
||||
wx.setNavigationBarTitle({ |
wx.setNavigationBarTitle({ |
||||
title: '话对捧个场' |
title: '话对捧个场' |
||||
}) |
}) |
||||
} |
} |
||||
|
|
||||
|
|
||||
}, |
}, |
||||
// 查列表
|
// 查列表
|
||||
topiclist() { |
topiclist() { |
||||
let that = this; |
let that = this; |
||||
const para = { |
const para = { |
||||
pageIndex: this.data.pageIndex, |
pageIndex: this.data.pageIndex, |
||||
pageSize: this.data.pageSize, |
pageSize: this.data.pageSize, |
||||
timestamp: getTimestamp(), |
timestamp: getTimestamp(), |
||||
topicType: this.data.topicType, |
topicType: this.data.topicType, |
||||
partyGroupId: this.data.partyGroupId, //党群id
|
partyGroupId: this.data.partyGroupId, //党群id
|
||||
partyTopicId:'' |
partyTopicId:'' |
||||
} |
} |
||||
topiclist(para).then(res => { |
topiclist(para).then(res => { |
||||
wx.stopPullDownRefresh(); |
wx.stopPullDownRefresh(); |
||||
that.setData({ |
that.setData({ |
||||
bannedFlag: res.data.bannedFlag, |
bannedFlag: res.data.bannedFlag, |
||||
nodata: false, |
nodata: false, |
||||
topiclist: that.data.topiclist.concat(res.data.topicList), |
topiclist: that.data.topiclist.concat(res.data.topicList), |
||||
loadMoreType: res.data.topicList.length === that.data.pageSize ? 'loading' : 'none', |
loadMoreType: res.data.topicList.length === that.data.pageSize ? 'loading' : 'none', |
||||
loadMoreVisible: res.data.topicList.length === that.data.pageSize ? false : true |
loadMoreVisible: res.data.topicList.length === that.data.pageSize ? false : true |
||||
}) |
}) |
||||
if (that.data.topiclist.length == 0) {//没有值
|
if (that.data.topiclist.length == 0) {//没有值
|
||||
that.setData({ |
that.setData({ |
||||
nodata: true, |
nodata: true, |
||||
loadMoreType: 'none', |
loadMoreType: 'none', |
||||
loadMoreVisible: false, |
loadMoreVisible: false, |
||||
}) |
}) |
||||
} |
} |
||||
}).catch(err => { |
}).catch(err => { |
||||
wx.stopPullDownRefresh(); |
wx.stopPullDownRefresh(); |
||||
that.setData({ |
that.setData({ |
||||
topiclist: [], |
topiclist: [], |
||||
nodata: true, |
nodata: true, |
||||
loadMoreType: 'none', |
loadMoreType: 'none', |
||||
loadMoreVisible: false, |
loadMoreVisible: false, |
||||
}) |
}) |
||||
console.log(err) |
console.log(err) |
||||
}) |
}) |
||||
}, |
}, |
||||
// 跳转 发布话题
|
// 跳转 发布话题
|
||||
navigateToAddTopic() { |
navigateToAddTopic() { |
||||
if (this.verifyCompleteInfo()) { |
if (this.verifyCompleteInfo()) { |
||||
return false |
return false |
||||
} |
} |
||||
wx.navigateTo({ |
wx.navigateTo({ |
||||
url: `/subpages/associationNew/pages/addTopic/addTopic?partyGroupId=${this.data.partyGroupId}&topicType=${this.data.topicType}` |
url: `/subpages/associationNew/pages/addTopic/addTopic?partyGroupId=${this.data.partyGroupId}&topicType=${this.data.topicType}` |
||||
}) |
}) |
||||
}, |
}, |
||||
/** |
/** |
||||
* 生命周期函数--监听页面初次渲染完成 |
* 生命周期函数--监听页面初次渲染完成 |
||||
*/ |
*/ |
||||
onReady: function () { |
onReady: function () { |
||||
|
|
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 生命周期函数--监听页面显示 |
* 生命周期函数--监听页面显示 |
||||
*/ |
*/ |
||||
onShow: function () { |
onShow: function () { |
||||
if(this.data.ifpreviewImage){ |
if(this.data.ifpreviewImage){ |
||||
this.setData({ |
this.setData({ |
||||
ifpreviewImage:false |
ifpreviewImage:false |
||||
}) |
}) |
||||
} else { |
} else { |
||||
this.setData({ |
this.setData({ |
||||
pageIndex: 1, |
pageIndex: 1, |
||||
pageSize: 10, |
pageSize: 10, |
||||
nodata: false, |
nodata: false, |
||||
loadMoreType: 'none', |
loadMoreType: 'none', |
||||
loadMoreVisible: false, |
loadMoreVisible: false, |
||||
topiclist: [], |
topiclist: [], |
||||
}) |
}) |
||||
this.topiclist() |
this.topiclist() |
||||
} |
} |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 生命周期函数--监听页面隐藏 |
* 生命周期函数--监听页面隐藏 |
||||
*/ |
*/ |
||||
onHide: function () { |
onHide: function () { |
||||
|
|
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 生命周期函数--监听页面卸载 |
* 生命周期函数--监听页面卸载 |
||||
*/ |
*/ |
||||
onUnload: function () { |
onUnload: function () { |
||||
|
|
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 页面相关事件处理函数--监听用户下拉动作 |
* 页面相关事件处理函数--监听用户下拉动作 |
||||
*/ |
*/ |
||||
onPullDownRefresh: function () { |
onPullDownRefresh: function () { |
||||
this.setData({ |
this.setData({ |
||||
pageIndex: 1, |
pageIndex: 1, |
||||
pageSize: 10, |
pageSize: 10, |
||||
nodata: false, |
nodata: false, |
||||
loadMoreType: 'none', |
loadMoreType: 'none', |
||||
loadMoreVisible: false, |
loadMoreVisible: false, |
||||
topiclist: [], |
topiclist: [], |
||||
}) |
}) |
||||
this.topiclist() |
this.topiclist() |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 页面上拉触底事件的处理函数 |
* 页面上拉触底事件的处理函数 |
||||
*/ |
*/ |
||||
onReachBottom: function () { |
onReachBottom: function () { |
||||
this.setData({ |
this.setData({ |
||||
loadMoreVisible: true |
loadMoreVisible: true |
||||
}) |
}) |
||||
if (this.data.loadMoreType === 'loading') { |
if (this.data.loadMoreType === 'loading') { |
||||
this.setData({ |
this.setData({ |
||||
pageIndex: this.data.pageIndex + 1, |
pageIndex: this.data.pageIndex + 1, |
||||
pageSize: this.data.pageSize, |
pageSize: this.data.pageSize, |
||||
}) |
}) |
||||
this.topiclist() |
this.topiclist() |
||||
} |
} |
||||
}, |
}, |
||||
|
|
||||
//点赞
|
//点赞
|
||||
clicklike(e) { |
clicklike(e) { |
||||
if (this.verifyCompleteInfo()) { |
if (this.verifyCompleteInfo()) { |
||||
return false |
return false |
||||
} |
} |
||||
let index = e.currentTarget.dataset.index |
this.setData({ |
||||
// <!-- 用户是否已点赞 0否;1是 -->
|
index: e.currentTarget.dataset.index |
||||
if (this.data.bannedFlag == '1') {//被禁言
|
}) |
||||
wx.showToast({ |
// <!-- 用户是否已点赞 0否;1是 -->
|
||||
title: '您已经被禁言', |
if (this.data.bannedFlag == '1') {//被禁言
|
||||
icon: 'none', |
wx.showToast({ |
||||
duration: 2000 |
title: '您已经被禁言', |
||||
}) |
icon: 'none', |
||||
return false |
duration: 2000 |
||||
} |
}) |
||||
let attitude = "" |
return false |
||||
if (e.currentTarget.dataset.likeflag == '0') {//点赞
|
} |
||||
attitude = 0 |
let attitude = "" |
||||
} else { |
if (e.currentTarget.dataset.likeflag == '0') {//点赞
|
||||
attitude = 2 |
attitude = 0 |
||||
} |
} else { |
||||
let that = this; |
attitude = 2 |
||||
const para = { |
} |
||||
topicId: e.currentTarget.dataset.id,//被评论的话题ID
|
let that = this; |
||||
attitude: attitude,//表态 0赞;1踩;2取消赞;3取消踩
|
const para = { |
||||
} |
topicId: e.currentTarget.dataset.id,//被评论的话题ID
|
||||
statement(para).then(res => { |
attitude: attitude,//表态 0赞;1踩;2取消赞;3取消踩
|
||||
// 点赞成功以后实现局部刷新功能
|
} |
||||
var obj = that.data.topiclist[index] |
statement(para).then(res => { |
||||
// <!-- 用户是否已点赞 0否;1是 -->
|
// 点赞成功以后实现局部刷新功能
|
||||
obj.likeFlag = obj.likeFlag == '0' ? '1' : '0' |
that.nowLikesList(e.currentTarget.dataset.id); |
||||
obj.supportNum = obj.likeFlag == '1' ? obj.supportNum + 1 : obj.supportNum - 1 |
}).catch(err => { |
||||
that.setData({ |
console.log(err) |
||||
["topiclist[" + index + "]"]: obj |
}) |
||||
}) |
}, |
||||
}).catch(err => { |
// Textarea获取焦点
|
||||
console.log(err) |
clickTextarea(e) { |
||||
}) |
if (this.verifyCompleteInfo()) { |
||||
}, |
return false |
||||
// Textarea获取焦点
|
} |
||||
clickTextarea(e) { |
let index = e.currentTarget.dataset.index |
||||
if (this.verifyCompleteInfo()) { |
if (this.data.bannedFlag == '1') {//被禁言
|
||||
return false |
wx.showToast({ |
||||
} |
title: '您已经被禁言', |
||||
let index = e.currentTarget.dataset.index |
icon: 'none', |
||||
if (this.data.bannedFlag == '1') {//被禁言
|
duration: 2000 |
||||
wx.showToast({ |
}) |
||||
title: '您已经被禁言', |
return false |
||||
icon: 'none', |
} |
||||
duration: 2000 |
this.setData({ |
||||
}) |
ifcomment: true, |
||||
return false |
focus: true, |
||||
} |
topicId: e.currentTarget.dataset.id, |
||||
this.setData({ |
index: index |
||||
ifcomment: true, |
}) |
||||
focus: true, |
}, |
||||
topicId: e.currentTarget.dataset.id, |
|
||||
index: index |
// 失去焦点
|
||||
}) |
bindAddressInput(e) { |
||||
}, |
this.setData({ //失去焦点以后view隐藏
|
||||
|
ifcomment: false, |
||||
// 失去焦点
|
commentContent: '' |
||||
bindAddressInput(e) { |
}) |
||||
this.setData({ //失去焦点以后view隐藏
|
}, |
||||
ifcomment: false, |
// 双向绑定
|
||||
commentContent: '' |
bindIdentity(e) { |
||||
}) |
this.setData({ |
||||
}, |
commentContent: e.detail.value |
||||
// 双向绑定
|
}) |
||||
bindIdentity(e) { |
}, |
||||
this.setData({ |
// 评论按钮点击事件
|
||||
commentContent: e.detail.value |
commentSubmit() { |
||||
}) |
let that = this; |
||||
}, |
const para = { |
||||
// 评论按钮点击事件
|
topicId: that.data.topicId,//被评论的话题ID
|
||||
commentSubmit() { |
faCommentId: '',//父评论(被评论)ID
|
||||
let that = this; |
content: that.data.commentContent,//评论内容
|
||||
const para = { |
} |
||||
topicId: that.data.topicId,//被评论的话题ID
|
commentSubmit(para).then(res => { |
||||
faCommentId: '',//父评论(被评论)ID
|
// 评论成功以后,调用接口比对出当前评论列表的数据,对已有列表数据进行替换
|
||||
content: that.data.commentContent,//评论内容
|
that.NowTopiclist() |
||||
} |
}).catch(err => { |
||||
commentSubmit(para).then(res => { |
console.log(err) |
||||
// 评论成功以后,调用接口比对出当前评论列表的数据,对已有列表数据进行替换
|
}) |
||||
that.NowTopiclist() |
}, |
||||
}).catch(err => { |
|
||||
console.log(err) |
// 列表内当前操作的数据
|
||||
}) |
NowTopiclist() { |
||||
}, |
let that = this; |
||||
|
const para = { |
||||
// 列表内当前操作的数据
|
pageIndex: 1, |
||||
NowTopiclist() { |
pageSize: 1, |
||||
let that = this; |
timestamp: getTimestamp(), |
||||
const para = { |
topicType: that.data.topicType, |
||||
pageIndex: 1, |
partyGroupId: that.data.partyGroupId, //党群id
|
||||
pageSize: 1, |
partyTopicId: that.data.topicId |
||||
timestamp: getTimestamp(), |
} |
||||
topicType: that.data.topicType, |
topiclist(para).then(res => { |
||||
partyGroupId: that.data.partyGroupId, //党群id
|
console.log(JSON.stringify(res)) |
||||
partyTopicId: that.data.topicId |
// 评论成功以后实现局部刷新功能
|
||||
} |
var obj = that.data.topiclist[that.data.index] |
||||
topiclist(para).then(res => { |
// 评论成功以后评论数量加1
|
||||
console.log(JSON.stringify(res)) |
// obj.commentNum = obj.commentNum + 1
|
||||
// 评论成功以后实现局部刷新功能
|
// obj.comments.splice(0, 0, {username:obj.nickname,content:para.content});
|
||||
var obj = that.data.topiclist[that.data.index] |
obj = res.data.topicList[0] |
||||
// 评论成功以后评论数量加1
|
that.setData({ |
||||
// obj.commentNum = obj.commentNum + 1
|
["topiclist[" + that.data.index + "]"]: obj |
||||
// obj.comments.splice(0, 0, {username:obj.nickname,content:para.content});
|
}) |
||||
obj = res.data.topicList[0] |
}).catch(err => { |
||||
that.setData({ |
console.log(err) |
||||
["topiclist[" + that.data.index + "]"]: obj |
}) |
||||
}) |
}, |
||||
}).catch(err => { |
//列表照片的放大查看
|
||||
console.log(err) |
previewImage(e) { |
||||
}) |
this.setData({ |
||||
}, |
ifpreviewImage:true |
||||
//列表照片的放大查看
|
}) |
||||
previewImage(e) { |
app.globalData.previewImage = true |
||||
this.setData({ |
wx.previewImage({ |
||||
ifpreviewImage:true |
urls: e.currentTarget.dataset.imgarry, |
||||
}) |
current: e.currentTarget.dataset.src |
||||
app.globalData.previewImage = true |
}) |
||||
wx.previewImage({ |
}, |
||||
urls: e.currentTarget.dataset.imgarry, |
// 检查 是否完善信息
|
||||
current: e.currentTarget.dataset.src |
verifyCompleteInfo() { |
||||
}) |
if (this.data.infoCompleted == 0) { |
||||
}, |
this.setData({ |
||||
// 检查 是否完善信息
|
completeInfoDialogVisible: !this.data.completeInfoDialogVisible |
||||
verifyCompleteInfo() { |
}) |
||||
if (this.data.infoCompleted == 0) { |
return true |
||||
this.setData({ |
} else { |
||||
completeInfoDialogVisible: !this.data.completeInfoDialogVisible |
return false |
||||
}) |
} |
||||
return true |
}, |
||||
} else { |
|
||||
return false |
/** |
||||
} |
* 用户点击右上角分享 |
||||
}, |
*/ |
||||
|
onShareAppMessage: function () { |
||||
/** |
|
||||
* 用户点击右上角分享 |
}, |
||||
*/ |
nowLikesList (topicId) { |
||||
onShareAppMessage: function () { |
let that = this; |
||||
|
const para = { |
||||
} |
pageIndex: 1, |
||||
|
pageSize: 10, |
||||
|
timestamp: getTimestamp(), |
||||
|
topicType: this.data.topicType, |
||||
|
partyGroupId: this.data.partyGroupId, //党群id
|
||||
|
partyTopicId: topicId |
||||
|
} |
||||
|
topiclist(para).then(res => { |
||||
|
var obj = that.data.topiclist[that.data.index] |
||||
|
obj = res.data.topicList[0] |
||||
|
// <!-- 用户是否已点赞 0否;1是 -->
|
||||
|
// obj.likeFlag = obj.likeFlag == '0' ? '1' : '0'
|
||||
|
// obj.supportNum = obj.likeFlag == '1' ? obj.supportNum + 1 : obj.supportNum - 1
|
||||
|
that.setData({ |
||||
|
["topiclist[" + that.data.index + "]"]: obj |
||||
|
}) |
||||
|
}).catch(err => { |
||||
|
console.log(err) |
||||
|
}) |
||||
|
} |
||||
}) |
}) |
Loading…
Reference in new issue