Browse Source

优化

master
zhaoyongnian 5 years ago
parent
commit
f023125ab1
  1. 67
      subpages/associationNew/pages/eventlist/eventlist.js
  2. 3
      subpages/associationNew/pages/eventlist/eventlist.json
  3. 16
      subpages/associationNew/pages/eventlist/eventlist.wxml
  4. 3
      subpages/associationNew/utils/api.js

67
subpages/associationNew/pages/eventlist/eventlist.js

@ -24,7 +24,9 @@ Page({
focus: false, focus: false,
topicId: '',//被评论的话题ID topicId: '',//被评论的话题ID
commentContent: '', commentContent: '',
index:0,//点击的第几条数据,用于评论的局部刷新用 index: 0,//点击的第几条数据,用于评论的局部刷新用
infoCompleted: 0,
completeInfoDialogVisible: false,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
@ -33,6 +35,7 @@ Page({
this.setData({ this.setData({
partyGroupId: options.partyGroupId, partyGroupId: options.partyGroupId,
topicType: options.topicType,//0:事好儿鼓个掌 1:话对捧个场 topicType: options.topicType,//0:事好儿鼓个掌 1:话对捧个场
infoCompleted: app.globalData.infoCompleted
}) })
if (options.topicType == 0) { if (options.topicType == 0) {
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
@ -85,14 +88,9 @@ Page({
}, },
// 跳转 发布话题 // 跳转 发布话题
navigateToAddTopic() { navigateToAddTopic() {
// if (this.data.groupState === '15') { if (this.verifyCompleteInfo()) {
// wx.showToast({ return false
// title: '该群已禁言,暂不可发布话题', }
// icon: 'none',
// duration: 2000
// })
// 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}`
}) })
@ -189,12 +187,12 @@ Page({
} }
statement(para).then(res => { statement(para).then(res => {
// 点赞成功以后实现局部刷新功能 // 点赞成功以后实现局部刷新功能
var obj= that.data.topiclist[index] var obj = that.data.topiclist[index]
// <!-- 用户是否已点赞 0否;1是 --> // <!-- 用户是否已点赞 0否;1是 -->
obj.likeFlag = obj.likeFlag == '0' ? '1' : '0' obj.likeFlag = obj.likeFlag == '0' ? '1' : '0'
obj.supportNum = obj.likeFlag == '1' ? obj.supportNum+1 : obj.supportNum-1 obj.supportNum = obj.likeFlag == '1' ? obj.supportNum + 1 : obj.supportNum - 1
that.setData({ that.setData({
["topiclist["+index+"]"]:obj ["topiclist[" + index + "]"]: obj
}) })
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
@ -215,7 +213,7 @@ Page({
ifcomment: true, ifcomment: true,
focus: true, focus: true,
topicId: e.currentTarget.dataset.id, topicId: e.currentTarget.dataset.id,
index:index index: index
}) })
}, },
@ -223,7 +221,7 @@ Page({
bindAddressInput(e) { bindAddressInput(e) {
this.setData({ //失去焦点以后view隐藏 this.setData({ //失去焦点以后view隐藏
ifcomment: false, ifcomment: false,
commentContent:'' commentContent: ''
}) })
}, },
// 双向绑定 // 双向绑定
@ -234,7 +232,6 @@ Page({
}, },
// 评论按钮点击事件 // 评论按钮点击事件
commentSubmit() { commentSubmit() {
let that = this; let that = this;
const para = { const para = {
topicId: that.data.topicId,//被评论的话题ID topicId: that.data.topicId,//被评论的话题ID
@ -242,13 +239,34 @@ Page({
content: that.data.commentContent,//评论内容 content: that.data.commentContent,//评论内容
} }
commentSubmit(para).then(res => { commentSubmit(para).then(res => {
// 评论成功以后,调用接口比对出当前评论列表的数据,对已有列表数据进行替换
that.NowTopiclist()
}).catch(err => {
console.log(err)
})
},
// 列表内当前操作的数据
NowTopiclist() {
let that = this;
const para = {
pageIndex: 1,
pageSize: 1,
timestamp: getTimestamp(),
topicType: that.data.topicType,
partyGroupId: that.data.partyGroupId, //党群id
partyTopicId: that.data.topicId
}
topiclist(para).then(res => {
console.log(JSON.stringify(res))
// 评论成功以后实现局部刷新功能 // 评论成功以后实现局部刷新功能
var obj= that.data.topiclist[that.data.index] var obj = that.data.topiclist[that.data.index]
// 评论成功以后评论数量加1 // 评论成功以后评论数量加1
obj.commentNum = obj.commentNum + 1 // obj.commentNum = obj.commentNum + 1
obj.comments.splice(0, 0, {username:obj.nickname,content:para.content}); // obj.comments.splice(0, 0, {username:obj.nickname,content:para.content});
obj = res.data.topicList[0]
that.setData({ that.setData({
["topiclist["+that.data.index+"]"]:obj ["topiclist[" + that.data.index + "]"]: obj
}) })
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
@ -262,6 +280,17 @@ Page({
current: e.currentTarget.dataset.src current: e.currentTarget.dataset.src
}) })
}, },
// 检查 是否完善信息
verifyCompleteInfo() {
if (this.data.infoCompleted == 0) {
this.setData({
completeInfoDialogVisible: !this.data.completeInfoDialogVisible
})
return true
} else {
return false
}
},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享

3
subpages/associationNew/pages/eventlist/eventlist.json

@ -1,7 +1,8 @@
{ {
"usingComponents": { "usingComponents": {
"load-more": "../../../../components/loadMore/loadMore", "load-more": "../../../../components/loadMore/loadMore",
"no-data":"../../../../components/nodata/nodata" "no-data":"../../../../components/nodata/nodata",
"completeInfo-dialog": "../../../../components/completeInfoDialog/completeInfoDialog"
}, },
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": true, "enablePullDownRefresh": true,

16
subpages/associationNew/pages/eventlist/eventlist.wxml

@ -10,11 +10,13 @@
<view wx:if="{{item.images.length > 0 && topicType == '0'}}" class="image-list" <view wx:if="{{item.images.length > 0 && topicType == '0'}}" class="image-list"
style="height: {{item.images.length === 3 ? '160rpx' : item.images.length === 2 ? '205rpx' : item.images.length === 1 ? '350rpx' : '' }}"> style="height: {{item.images.length === 3 ? '160rpx' : item.images.length === 2 ? '205rpx' : item.images.length === 1 ? '350rpx' : '' }}">
<image mode="aspectFill" catchtap="previewImage" data-src="{{_item}}" data-imgArry="{{item.images}}" class="image-item" <image mode="aspectFill" catchtap="previewImage" data-src="{{_item}}" data-imgArry="{{item.images}}"
wx:for="{{item.images}}" wx:key="{{index}}" wx:for-index="index" wx:for-item="_item" src="{{_item}}" /> class="image-item" wx:for="{{item.images}}" wx:key="{{index}}" wx:for-index="index" wx:for-item="_item"
src="{{_item}}" />
</view> </view>
<view class="attitude"> <view class="attitude">
<view class="all" data-id="{{item.id}}" bindtap="clicklike" data-likeFlag="{{item.likeFlag}}" data-index="{{index}}"> <view class="all" data-id="{{item.id}}" bindtap="clicklike" data-likeFlag="{{item.likeFlag}}"
data-index="{{index}}">
<!-- 用户是否已点赞 0否;1是 --> <!-- 用户是否已点赞 0否;1是 -->
<!-- --> <!-- -->
<image src="{{item.likeFlag == '0' ? '../../images/give.png' : '../../images/give_2.png'}}"></image> <image src="{{item.likeFlag == '0' ? '../../images/give.png' : '../../images/give_2.png'}}"></image>
@ -38,7 +40,8 @@
<view class="release" wx:if="{{ifcomment}}"> <view class="release" wx:if="{{ifcomment}}">
<view class="replyinfo2"> <view class="replyinfo2">
<textarea placeholder-class="input_null" fixed="true" maxlength="-1" show-confirm-bar="false" <textarea placeholder-class="input_null" fixed="true" maxlength="-1" show-confirm-bar="false"
cursor-spacing="15" auto-height="true" placeholder="请输入回复" value="{{commentContent}}" focus='{{focus}}' bindblur="bindAddressInput" bindinput="bindIdentity"></textarea> cursor-spacing="15" auto-height="true" placeholder="请输入回复" value="{{commentContent}}" focus='{{focus}}'
bindblur="bindAddressInput" bindinput="bindIdentity"></textarea>
<button bindtap="commentSubmit" form-type="submit" class="submit">发送</button> <button bindtap="commentSubmit" form-type="submit" class="submit">发送</button>
</view> </view>
</view> </view>
@ -49,4 +52,7 @@
<view wx:if="{{bannedFlag == '0'}}" class="addIssue" bindtap="navigateToAddTopic"> <view wx:if="{{bannedFlag == '0'}}" class="addIssue" bindtap="navigateToAddTopic">
<image wx:if="{{topicType == '0'}}" src="../../images/story.png" /> <image wx:if="{{topicType == '0'}}" src="../../images/story.png" />
<image wx:else src="../../images/speack.png" /> <image wx:else src="../../images/speack.png" />
</view> </view>
<completeInfo-dialog completeInfoDialogVisible="{{completeInfoDialogVisible}}">
</completeInfo-dialog>

3
subpages/associationNew/utils/api.js

@ -67,13 +67,14 @@ export function postUserBanned({groupUserId, bannedFlag}) {
/** /**
* 话题列表 * 话题列表
*/ */
export function topiclist({pageIndex,pageSize,timestamp,topicType,partyGroupId}) { export function topiclist({pageIndex,pageSize,timestamp,topicType,partyGroupId,partyTopicId}) {
return request.get('partyGroup/topic/list',{ return request.get('partyGroup/topic/list',{
pageIndex, pageIndex,
pageSize, pageSize,
timestamp, timestamp,
topicType, topicType,
partyGroupId, partyGroupId,
partyTopicId
}) })
} }

Loading…
Cancel
Save