|
|
|
// subpages/associationNew/pages/eventlist/eventlist.js
|
|
|
|
const app = getApp()
|
|
|
|
import { topiclist, commentSubmit, statement } from '../../utils/api'
|
|
|
|
import {
|
|
|
|
getTimestamp
|
|
|
|
} from '../../../../utils/common'
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
topiclist: [],
|
|
|
|
timestamp: '',
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
partyGroupId: '',//党群id
|
|
|
|
topicType: '',//0:事好儿鼓个掌 1:话对捧个场
|
|
|
|
nodata: false,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
bannedFlag: '',//是否禁言 0:否 1:是
|
|
|
|
ifcomment: false,//是否显示评论
|
|
|
|
focus: false,
|
|
|
|
topicId: '',//被评论的话题ID
|
|
|
|
commentContent: '',
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.setData({
|
|
|
|
partyGroupId: options.partyGroupId,
|
|
|
|
topicType: options.topicType,//0:事好儿鼓个掌 1:话对捧个场
|
|
|
|
})
|
|
|
|
if (options.topicType == 0) {
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: '事好儿鼓个掌'
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: '话对捧个场'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
// 查列表
|
|
|
|
topiclist() {
|
|
|
|
let that = this;
|
|
|
|
const para = {
|
|
|
|
pageIndex: this.data.pageIndex,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
timestamp: getTimestamp(),
|
|
|
|
topicType: this.data.topicType,
|
|
|
|
partyGroupId: this.data.partyGroupId, //党群id
|
|
|
|
}
|
|
|
|
topiclist(para).then(res => {
|
|
|
|
that.setData({
|
|
|
|
bannedFlag: res.data.bannedFlag,
|
|
|
|
nodata: false,
|
|
|
|
topiclist: that.data.topiclist.concat(res.data.topicList),
|
|
|
|
loadMoreType: res.data.topicList.length === that.data.pageSize ? 'loading' : 'none',
|
|
|
|
loadMoreVisible: res.data.topicList.length === that.data.pageSize ? false : true
|
|
|
|
})
|
|
|
|
if (that.data.topiclist.length == 0) {//没有值
|
|
|
|
that.setData({
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
that.setData({
|
|
|
|
topiclist: [],
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 跳转 发布话题
|
|
|
|
navigateToAddTopic() {
|
|
|
|
// if (this.data.groupState === '15') {
|
|
|
|
// wx.showToast({
|
|
|
|
// title: '该群已禁言,暂不可发布话题',
|
|
|
|
// icon: 'none',
|
|
|
|
// duration: 2000
|
|
|
|
// })
|
|
|
|
// return false
|
|
|
|
// }
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/subpages/associationNew/pages/addTopic/addTopic?partyGroupId=${this.data.partyGroupId}&topicType=${this.data.topicType}`
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.setData({
|
|
|
|
topiclist: [],
|
|
|
|
})
|
|
|
|
this.topiclist()
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: true
|
|
|
|
})
|
|
|
|
if (this.data.loadMoreType === 'loading') {
|
|
|
|
this.setData({
|
|
|
|
pageIndex: this.data.pageIndex + 1,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
})
|
|
|
|
this.topiclist()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
//点赞
|
|
|
|
clicklike(e) {
|
|
|
|
// <!-- 用户是否已点赞 0否;1是 -->
|
|
|
|
if (this.data.bannedFlag == '1') {//被禁言
|
|
|
|
wx.showToast({
|
|
|
|
title: '您已经被禁言',
|
|
|
|
icon: 'none',
|
|
|
|
duration: 2000
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let attitude = ""
|
|
|
|
if (e.currentTarget.dataset.likeflag == '0') {//点赞
|
|
|
|
attitude = 0
|
|
|
|
} else {
|
|
|
|
attitude = 2
|
|
|
|
}
|
|
|
|
let that = this;
|
|
|
|
const para = {
|
|
|
|
topicId: e.currentTarget.dataset.id,//被评论的话题ID
|
|
|
|
attitude: attitude,//表态 0赞;1踩;2取消赞;3取消踩
|
|
|
|
}
|
|
|
|
statement(para).then(res => {
|
|
|
|
that.setData({
|
|
|
|
topiclist: [],
|
|
|
|
})
|
|
|
|
this.topiclist()
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// Textarea获取焦点
|
|
|
|
clickTextarea(e) {
|
|
|
|
if (this.data.bannedFlag == '1') {//被禁言
|
|
|
|
wx.showToast({
|
|
|
|
title: '您已经被禁言',
|
|
|
|
icon: 'none',
|
|
|
|
duration: 2000
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
ifcomment: true,
|
|
|
|
focus: true,
|
|
|
|
topicId: e.currentTarget.dataset.id
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 失去焦点
|
|
|
|
bindAddressInput(e) {
|
|
|
|
this.setData({ //失去焦点以后view隐藏
|
|
|
|
ifcomment: false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 双向绑定
|
|
|
|
bindIdentity(e) {
|
|
|
|
this.setData({
|
|
|
|
commentContent: e.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 评论按钮点击事件
|
|
|
|
commentSubmit() {
|
|
|
|
|
|
|
|
let that = this;
|
|
|
|
const para = {
|
|
|
|
topicId: this.data.topicId,//被评论的话题ID
|
|
|
|
faCommentId: '',//父评论(被评论)ID
|
|
|
|
content: this.data.commentContent,//评论内容
|
|
|
|
}
|
|
|
|
commentSubmit(para).then(res => {
|
|
|
|
that.setData({
|
|
|
|
topiclist: [],
|
|
|
|
})
|
|
|
|
this.topiclist()
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
previewImage(e) {
|
|
|
|
app.globalData.previewImage = true
|
|
|
|
wx.previewImage({
|
|
|
|
urls: e.currentTarget.dataset.imgarry,
|
|
|
|
current: e.currentTarget.dataset.src
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|