Browse Source

update 所有删除功能

master
fanp 6 years ago
parent
commit
ba77e4e8f7
  1. 2
      config.js
  2. 16
      models/topic.js
  3. 54
      pages/topics/goodIdea/cell/index.js
  4. 65
      pages/topics/goodIdea/cell/index.wxml
  5. 46
      pages/topics/goodIdea/cell/index.wxss
  6. 3
      pages/topics/goodIdea/index.js
  7. 3
      pages/topics/goodIdea/index.wxml
  8. 25
      pages/topics/index.js
  9. 2
      pages/topics/index.wxml
  10. 2
      pages/topics/interactive/cell/index.wxss
  11. 16
      pages/topics/interactive/submitTopic/index.wxml
  12. 92
      pages/topics/interactive/topicArticle/index.js
  13. 37
      pages/topics/interactive/topicArticle/index.wxml
  14. 46
      pages/topics/interactive/topicArticle/index.wxss
  15. 39
      pages/topics/message/index.js
  16. 21
      pages/topics/message/index.wxml
  17. 27
      pages/topics/message/index.wxss
  18. 36
      pages/user/index.js
  19. 22
      pages/user/myIdea/index.js
  20. 3
      pages/user/myIdea/index.wxml
  21. 2
      pages/user/myMessage/cell/index.js
  22. 24
      pages/user/myMessage/cell/index.wxml
  23. 9
      pages/user/myMessage/cell/index.wxss
  24. 8
      pages/user/myMessage/index.js
  25. 1
      pages/user/myTopics/index.js
  26. 53
      pages/user/myTopics/myParticipant/cell/index.js
  27. 2
      pages/user/myTopics/myParticipant/cell/index.wxss
  28. 2
      pages/user/myTopics/myParticipant/index.wxml
  29. 3
      pages/user/myTopics/myRelease/index.wxml

2
config.js

@ -1,5 +1,5 @@
const config = { const config = {
// api_url: 'http://192.168.42.44:8083/fqsb', // 服务器地址 // api_url: 'http://192.168.42.44:8083/fqsb', // 服务器地址
api_url: 'http://121.42.41.42:8092/fqsb' api_url: 'https://shibeirencai.elinkit.com.cn:8083/fqsb'
} }
export { config } export { config }

16
models/topic.js

@ -8,6 +8,7 @@ const TopicBaseUrl = {
topic_detail_url:'/api/group/queryById/', // 议题详情 topic_detail_url:'/api/group/queryById/', // 议题详情
topic_detailComment_url:'/api/comment/page', // 评论列表 topic_detailComment_url:'/api/comment/page', // 评论列表
topic_addComment_url:'/api/comment/addComment',// 新建议题评论 topic_addComment_url:'/api/comment/addComment',// 新建议题评论
topic_deleteComment_url:'/api/comment/deleteComment/', // 删除议题评论
topic_collect_url:'/api/group/collectGroup/', // 收藏 topic_collect_url:'/api/group/collectGroup/', // 收藏
topic_unCollect_url: '/api/collect/deleteCollection/', // 取消收藏 topic_unCollect_url: '/api/collect/deleteCollection/', // 取消收藏
topic_commentPraise_url: '/api/comment/addSupport/', // 点赞 topic_commentPraise_url: '/api/comment/addSupport/', // 点赞
@ -67,7 +68,17 @@ class TopicModel extends HTTP {
} }
this.request(params) this.request(params)
} }
deleteComment(id, success) {
let params = {
url: TopicBaseUrl.topic_deleteComment_url + `${id}`,
method: Method.POST,
data: {},
success: success
}
this.request(params)
}
getTopicDetailComment(id, page,success) { getTopicDetailComment(id, page,success) {
let params = { let params = {
@ -140,11 +151,12 @@ class TopicModel extends HTTP {
this.request(params) this.request(params)
} }
addMessage(content,success){ addMessage(title,content,success){
let params = { let params = {
url: TopicBaseUrl.topic_addMessage_url, url: TopicBaseUrl.topic_addMessage_url,
method: Method.POST, method: Method.POST,
data: { data: {
title:title,
content: content content: content
}, },
success: success success: success

54
pages/topics/goodIdea/cell/index.js

@ -1,4 +1,6 @@
// pages/topics/common/goodIdea/cell/index.js // pages/topics/common/goodIdea/cell/index.js
import { store } from '../../../../utils/store.js'
Component({ Component({
/** /**
@ -17,7 +19,10 @@ Component({
*/ */
data: { data: {
unPraise: '/images/common/zan.png', unPraise: '/images/common/zan.png',
praise: '/images/common/star_light.png' praise: '/images/common/star_light.png',
isTouchMove:false,
startX: 0, //开始坐标
startY: 0
}, },
/** /**
@ -32,6 +37,53 @@ Component({
wx.navigateTo({ wx.navigateTo({
url: `/pages/topics/interactive/topicArticle/index?topicId=${topicId}`, url: `/pages/topics/interactive/topicArticle/index?topicId=${topicId}`,
}) })
},
touchstart: function (e) {
let { nickName } = store.readUserInfo()
if (e.currentTarget.dataset.name === nickName) {
//开始触摸时 重置所有删除
if (this.data.isTouchMove) {
this.setData({
isTouchMove: false
})
}
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY,
})
}
},
touchmove: function (e) {
let { nickName } = store.readUserInfo()
if (e.currentTarget.dataset.name === nickName) {
var that = this
// index = e.currentTarget.dataset.index,//当前索引
const startX = that.data.startX//开始X坐标
const startY = that.data.startY//开始Y坐标
const touchMoveX = e.changedTouches[0].clientX//滑动变化坐标
const touchMoveY = e.changedTouches[0].clientY//滑动变化坐标
//获取滑动角度
const angle = that.angle({ X: startX, Y: startY }, { X: touchMoveX, Y: touchMoveY })
if (Math.abs(angle) > 30) return;
if (touchMoveX > startX) //右滑
that.setData({
isTouchMove: false
})
else //左滑
that.setData({
isTouchMove: true
})
}
},
angle: function (start, end) {
var _X = end.X - start.X,
_Y = end.Y - start.Y
//返回角度 /Math.atan()返回数字的反正切值
return 360 * Math.atan(_Y / _X) / (2 * Math.PI);
},
del: function (e) {
this.triggerEvent('deleteTopicComment', { id: e.currentTarget.dataset.id })
} }
} }
}) })

65
pages/topics/goodIdea/cell/index.wxml

@ -1,40 +1,45 @@
<!--pages/topics/common/goodIdea/cell/index.wxml--> <!--pages/topics/common/goodIdea/cell/index.wxml-->
<view class="cell" id="cell" > <view class="cell" id="cell" >
<view class="content-left"> <view class="touch-item {{isTouchMove ? 'touch-move-active' : ''}}" data-index="{{itemIndex}}" data-name="{{itemData.commentName}}" bindtouchstart="touchstart" bindtouchmove="touchmove" >
<image src="{{itemData.commentIcon}}" style="width:20px;height:20px;"></image> <view class="content">
</view> <view class="content-left">
<view class="content-right"> <image src="{{itemData.commentIcon}}" style="width:20px;height:20px;"></image>
<view class="userInfo">
<view class="userInfo-left">
<view class="userName">{{itemData.commentName}}</view>
<view class="comment-time">{{itemData.commentTime}}</view>
</view> </view>
<view class="userInfo-right" bindtap="onClickPraise" data-item="{{itemData}}" data-index='{{itemIndex}}'> <view class="content-right">
<view class="praiseNum">{{itemData.praiseNum}}</view> <view class="userInfo">
<view class="praise-icon"> <view class="userInfo-left">
<image src="{{item.isPraise ? praise : unPraise}}" style="width:100%;"></image> <view class="userName">{{itemData.commentName}}</view>
</view> <view class="comment-time">{{itemData.commentTime}}</view>
</view> </view>
</view> <view class="userInfo-right" bindtap="onClickPraise" data-item="{{itemData}}" data-index='{{itemIndex}}'>
<view style="color:#3B3B3B;font-size:14px;padding: 0 0 5px 0;">{{itemData.comment}}</view> <view class="praiseNum">{{itemData.praiseNum}}</view>
<view class="detail" bindtap="pushTopic"> <view class="praise-icon">
<view class="detail-title">{{itemData.topicTtitle}}</view> <image src="{{item.isPraise ? praise : unPraise}}" style="width:100%;"></image>
<view class="detail-userInfo"> </view>
<view class="detail-userInfo-left">
<view class="detail-user-icon">
<image src="{{itemData.topicGroupAvator}}"></image>
</view> </view>
<view class="detail-userName">{{itemData.topicAuthor}}</view>
<view class="detail-time">{{itemData.topicGroupCreateTime}}</view>
</view> </view>
<view class="detail-userInfo-right"> <view style="color:#3B3B3B;font-size:14px;padding: 0 0 5px 0;">{{itemData.comment}}</view>
<view class="detail-comments-icon"> <view class="detail" bindtap="pushTopic">
<image src="/images/common/com_count.png"></image> <view class="detail-title">{{itemData.topicTtitle}}</view>
<view class="detail-userInfo">
<view class="detail-userInfo-left">
<view class="detail-user-icon">
<image src="{{itemData.topicGroupAvator}}"></image>
</view>
<view class="detail-userName">{{itemData.topicAuthor}}</view>
<view class="detail-time">{{itemData.topicGroupCreateTime}}</view>
</view>
<view class="detail-userInfo-right">
<view class="detail-comments-icon">
<image src="/images/common/com_count.png"></image>
</view>
<view class="detail-commentNum">{{itemData.topicCommentNum}}</view>
</view>
</view> </view>
<view class="detail-commentNum">{{itemData.topicCommentNum}}</view> <view class="detail-text">{{itemData.topicDetail}}</view>
</view> </view>
</view> </view>
<view class="detail-text">{{itemData.topicDetail}}</view>
</view> </view>
</view> <view class="del" data-index="{{itemIndex}}" data-id="{{itemData.commentId}}" catchtap="del">删除</view>
</view>
</view> </view>

46
pages/topics/goodIdea/cell/index.wxss

@ -1,8 +1,8 @@
/* pages/topics/common/goodIdea/cell/index.wxss */ /* pages/topics/common/goodIdea/cell/index.wxss */
.cell{ .cell{
display: flex; /* display: flex;
flex-direction: row; flex-direction: row;
padding: 10px; padding: 10px; */
} }
.content-left{ .content-left{
width: 20px; width: 20px;
@ -114,4 +114,46 @@ image{
color: #373737; color: #373737;
font-size: 13px; font-size: 13px;
/* padding: 0 10px 0 10px; */ /* padding: 0 10px 0 10px; */
}
.touch-item {
font-size: 14px;
display: flex;
justify-content: space-between;
border-bottom:1px solid #E7E7E7;
width: 100%;
overflow: hidden
}
.content {
width: 100%;
/* padding: 10px; */
line-height: 22px;
margin-right:0;
-webkit-transition: all 0.4s;
transition: all 0.4s;
-webkit-transform: translateX(120px);
transform: translateX(120px);
margin-left: -120px;
display: flex;
flex-direction: row;
padding: 10px;
}
.del {
background-color: orangered;
width: 120px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff;
-webkit-transform: translateX(120px);
transform: translateX(120px);
-webkit-transition: all 0.4s;
transition: all 0.4s;
}
.touch-move-active .content,
.touch-move-active .del {
-webkit-transform: translateX(0);
transform: translateX(0);
} }

3
pages/topics/goodIdea/index.js

@ -27,6 +27,9 @@ Component({
onClickPraise(e){ onClickPraise(e){
const itemData = e.detail.itemData; const itemData = e.detail.itemData;
this.triggerEvent('tapGoodIdeaPraise', { commentId: itemData.commentId }) this.triggerEvent('tapGoodIdeaPraise', { commentId: itemData.commentId })
},
deleteTopicComment(e){
this.triggerEvent('deleteTopicComment', { id: e.detail.id })
} }
} }
}) })

3
pages/topics/goodIdea/index.wxml

@ -4,6 +4,7 @@
<cell <cell
itemData="{{item}}" itemData="{{item}}"
itemIndex="{{index}}" itemIndex="{{index}}"
bind:onClickPraise="onClickPraise"/> bind:onClickPraise="onClickPraise"
bind:deleteTopicComment="deleteTopicComment"/>
</block> </block>
</view> </view>

25
pages/topics/index.js

@ -204,7 +204,7 @@ Page({
} }
}, },
deleteTopic(e) { deleteTopic(e) {
console.log(e.detail.id) // console.log(e.detail.id)
let that = this let that = this
topicModel.deleteGroup(e.detail.id, res => { topicModel.deleteGroup(e.detail.id, res => {
console.log(res) console.log(res)
@ -227,6 +227,29 @@ Page({
} }
}) })
}, },
deleteTopicComment(e){
let that = this
topicModel.deleteComment(e.detail.id,res=>{
if(res.code === 200){
wx.showToast({
title: '删除成功',
icon: 'none',
success() {
that.setData({
currPage: 1,
})
switch (that.data.segmentIndex) {
case 0:
return that.fetchTopicList()
case 1:
return that.fetchGoodIdeaList()
}
}
})
}
})
},
tapGoodIdeaPraise(e){ tapGoodIdeaPraise(e){
this.fetchGoodIdeaPraise(e.detail.commentId) this.fetchGoodIdeaPraise(e.detail.commentId)
}, },

2
pages/topics/index.wxml

@ -2,6 +2,6 @@
<view class="content-wrapper"> <view class="content-wrapper">
<e-segment bind:tapSegment="tapSegment" headerTitles="{{headerTitles}}" defaultSelectIndex="{{selectedTitle}}"/> <e-segment bind:tapSegment="tapSegment" headerTitles="{{headerTitles}}" defaultSelectIndex="{{selectedTitle}}"/>
<interactive wx:if="{{segmentIndex==0}}" list="{{topicList}}" bind:deleteTopic="deleteTopic"/> <interactive wx:if="{{segmentIndex==0}}" list="{{topicList}}" bind:deleteTopic="deleteTopic"/>
<goodIdea wx:if="{{segmentIndex==1}}" list="{{goodIdeaList}}" bind:tapGoodIdeaPraise="tapGoodIdeaPraise"/> <goodIdea wx:if="{{segmentIndex==1}}" list="{{goodIdeaList}}" bind:tapGoodIdeaPraise="tapGoodIdeaPraise" bind:deleteTopicComment="deleteTopicComment"/>
<message wx:if="{{segmentIndex==2}}" /> <message wx:if="{{segmentIndex==2}}" />
</view> </view>

2
pages/topics/interactive/cell/index.wxss

@ -114,7 +114,7 @@ image{
font-size: 14px; font-size: 14px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
border-bottom:1px solid #ccc; border-bottom:1px solid #E7E7E7;
width: 100%; width: 100%;
overflow: hidden overflow: hidden
} }

16
pages/topics/interactive/submitTopic/index.wxml

@ -1,15 +1,15 @@
<!--pages/topics/interactive/submitTopic/index.wxml--> <!--pages/topics/interactive/submitTopic/index.wxml-->
<view class="container"> <view class="container">
<view class="item">
<view class="must_fill">*</view>
<input class="title" value="{{topicTitle}}" bindinput="bindTextInput" placeholder="议题标题"></input>
</view>
<view class="line-view"></view>
<view class="item"> <view class="item">
<view class="must_fill">*</view> <view class="must_fill">*</view>
<textarea class="textArea" value="{{topicDetail}}" bindinput="bindTextAreaInput" placeholder="议题内容" /> <input class="title" value="{{topicTitle}}" bindinput="bindTextInput" placeholder="议题标题"></input>
</view> </view>
<view class="line-view"></view>
<view class="item">
<view class="must_fill">*</view>
<textarea class="textArea" value="{{topicDetail}}" bindinput="bindTextAreaInput" placeholder="议题内容" />
</view>
<mp-cells ext-class="uploader_bd"> <mp-cells ext-class="uploader_bd">
<mp-cell> <mp-cell>

92
pages/topics/interactive/topicArticle/index.js

@ -2,6 +2,7 @@
import dayjs from '../../../../utils/dayjs/index.js' import dayjs from '../../../../utils/dayjs/index.js'
import relativeTime from '../../../../utils/dayjs/relativeTime.js' import relativeTime from '../../../../utils/dayjs/relativeTime.js'
dayjs.extend(relativeTime); dayjs.extend(relativeTime);
import { store } from '../../../../utils/store.js'
import { TopicModel } from '../../../../models/topic.js' import { TopicModel } from '../../../../models/topic.js'
let topicModel = new TopicModel() let topicModel = new TopicModel()
@ -31,6 +32,9 @@ Page({
praise: '/images/common/zan.png', praise: '/images/common/zan.png',
hiddenmodalput:true, hiddenmodalput:true,
currentComment:'', currentComment:'',
startX: 0, //开始坐标
startY: 0,
}, },
/** /**
@ -90,7 +94,8 @@ Page({
isGoldenIdea: item.isGoldenIdea, isGoldenIdea: item.isGoldenIdea,
detail: item.comment, detail: item.comment,
time: item.createTime, time: item.createTime,
praiseNum: item.supportNum praiseNum: item.supportNum,
isTouchMove:false,
}) })
}) })
if (page == 1) { if (page == 1) {
@ -157,6 +162,19 @@ Page({
} }
}) })
}, },
fetchDeleteComment(commentId){
topicModel.deleteComment(commentId, res => {
if (res.code === 200) {
wx.showToast({
title: res.message,
icon: 'none'
})
this.fetchDetailComment()
}
})
},
onClickCollect() { onClickCollect() {
this.setData({ this.setData({
isCollect: !this.data.isCollect isCollect: !this.data.isCollect
@ -175,13 +193,7 @@ Page({
if (sIndex === index){ if (sIndex === index){
this.fetchTopicCommentPraise(selectItem.id) this.fetchTopicCommentPraise(selectItem.id)
} }
// tempList.push(item)
}) })
// this.setData({
// commentList:tempList,
// })
// this.fetchTopicCommentPraise(selectItem.id)
// 评论点赞
}, },
// 点击查看图片 // 点击查看图片
@ -238,5 +250,71 @@ Page({
this.setData({ this.setData({
currentComment: e.detail.value currentComment: e.detail.value
}) })
},
touchstart: function (e) {
let { nickName } = store.readUserInfo()
if (e.currentTarget.dataset.name === nickName) {
//开始触摸时 重置所有删除
this.data.commentList.forEach( item=>{
if (item.isTouchMove) {
item.isTouchMove = false
}
})
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY,
commentList: this.data.commentList
})
}
},
touchmove: function (e) {
let { nickName } = store.readUserInfo()
if (e.currentTarget.dataset.name === nickName) {
var that = this
const currentIndex = e.currentTarget.dataset.index//当前索引
const startX = that.data.startX//开始X坐标
const startY = that.data.startY//开始Y坐标
const touchMoveX = e.changedTouches[0].clientX//滑动变化坐标
const touchMoveY = e.changedTouches[0].clientY//滑动变化坐标
//获取滑动角度
const angle = that.angle({ X: startX, Y: startY }, { X: touchMoveX, Y: touchMoveY })
this.data.commentList.forEach((item,index) => {
item.isTouchMove = false
if (currentIndex == index) {
if (touchMoveX > startX) //右滑
item.isTouchMove = false
else //左滑
item.isTouchMove = true
}
})
that.setData({
commentList: that.data.commentList
})
}
},
angle: function (start, end) {
var _X = end.X - start.X,
_Y = end.Y - start.Y
//返回角度 /Math.atan()返回数字的反正切值
return 360 * Math.atan(_Y / _X) / (2 * Math.PI);
},
del: function (e) {
let that = this
let id = e.currentTarget.dataset.id
topicModel.deleteComment(id,res=>{
if (res.code === 200) {
wx.showToast({
title: '删除成功',
icon: 'none',
success() {
that.setData({
currPage: 1,
})
that.fetchDetailComment()
}
})
}
})
} }
}) })

37
pages/topics/interactive/topicArticle/index.wxml

@ -44,25 +44,30 @@
</view> </view>
<button class="commnetBtn" size="mini" bindtap="onTapComment">评论</button> <button class="commnetBtn" size="mini" bindtap="onTapComment">评论</button>
</view> </view>
<view class="comment_info" wx:for="{{commentList}}" wx:key="{{index}}"> <view class="comment_info" >
<view class="comment_info_left"> <view class="touch-item {{item.isTouchMove ? 'touch-move-active' : ''}}" data-index="{{index}}" data-name="{{item.userName}}" bindtouchstart="touchstart" bindtouchmove="touchmove" wx:for="{{commentList}}" wx:key="{{index}}">
<image class="comment_icon" src="{{item.commentAvator}}"></image> <view class="comment_content">
</view> <view class="comment_info_left">
<view class="comment_info_right"> <image class="comment_icon" src="{{item.commentAvator}}"></image>
<view class="comment_top">
<view class="comment_info_userName">{{item.userName}}</view>
<view class="goodIdeaIcon" wx:if="{{item.isGoldenIdea === 1}}">
<image style="width:100%;height:100%;" src="/images/topic/gidea.png"></image>
</view> </view>
</view> <view class="comment_info_right">
<view class="comment_info_detail">{{item.detail}}</view> <view class="comment_top">
<view class="comment_info_time"> <view class="comment_info_userName">{{item.userName}}</view>
<view class="comment_info_time_left">{{item.time}}</view> <view class="goodIdeaIcon" wx:if="{{item.isGoldenIdea === 1}}">
<view class="comment_info_time_right" bindtap="onClickPraise" data-item="{{item}}" data-index='{{index}}'> <image style="width:100%;height:100%;" src="/images/topic/gidea.png"></image>
<view class="praiseNum">{{item.praiseNum}}</view> </view>
<image class="praiseIcon" src="{{praise}}"></image> </view>
<view class="comment_info_detail">{{item.detail}}</view>
<view class="comment_info_time">
<view class="comment_info_time_left">{{item.time}}</view>
<view class="comment_info_time_right" bindtap="onClickPraise" data-item="{{item}}" data-index='{{index}}'>
<view class="praiseNum">{{item.praiseNum}}</view>
<image class="praiseIcon" src="{{praise}}"></image>
</view>
</view>
</view> </view>
</view> </view>
<view class="del" data-index="{{index}}" data-id="{{item.id}}" catchtap="del">删除</view>
</view> </view>
</view> </view>
</view> </view>

46
pages/topics/interactive/topicArticle/index.wxss

@ -117,10 +117,10 @@ image{
margin: 0; margin: 0;
} }
.comment_info{ .comment_info{
padding: 10px 0; /* padding: 10px 0;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
border-top: 1px solid #E7E7E7; border-top: 1px solid #E7E7E7; */
} }
.comment_info_left{ .comment_info_left{
width: 30px; width: 30px;
@ -173,4 +173,46 @@ image{
margin-left: 5px; margin-left: 5px;
width: 10px; width: 10px;
height: 10px; height: 10px;
}
.touch-item {
font-size: 14px;
display: flex;
justify-content: space-between;
/* border-top: 1px solid #E7E7E7; */
width: 100%;
overflow: hidden
}
.comment_content {
width: 100%;
line-height: 22px;
margin-right:0;
-webkit-transition: all 0.4s;
transition: all 0.4s;
-webkit-transform: translateX(120px);
transform: translateX(120px);
margin-left: -120px;
padding: 10px 0;
display: flex;
flex-direction: row;
border-top: 1px solid #E7E7E7;
}
.del {
background-color: orangered;
width: 120px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff;
-webkit-transform: translateX(120px);
transform: translateX(120px);
-webkit-transition: all 0.4s;
transition: all 0.4s;
}
.touch-move-active .comment_content,
.touch-move-active .del {
-webkit-transform: translateX(0);
transform: translateX(0);
} }

39
pages/topics/message/index.js

@ -14,42 +14,55 @@ Component({
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
textAreaString:"" messageTitle:"",
messageDetail:"",
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
bindTextInput(e) {
this.setData({
messageTitle: e.detail.value
})
},
bindTextAreaInput(e) { bindTextAreaInput(e) {
this.setData({ this.setData({
textAreaString: e.detail.value messageDetail: e.detail.value
}) })
}, },
submit() { submit() {
if (this.data.textAreaString === ''){ if (this.data.messageTitle === '') {
wx.showModal({
title: '提示',
content: '请输入标题',
showCancel: false
})
return
}
if (this.data.messageDetail === ''){
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: '请输入留言内容', content: '请输入正文内容',
showCancel:false showCancel:false
}) })
return return
} }
topicModel.addMessage(this.data.textAreaString,res=>{ topicModel.addMessage(this.data.messageTitle, this.data.messageDetail,res=>{
console.log(res)
if(res.code === 200){ if(res.code === 200){
this.setData({ this.setData({
textAreaString: '' messageTitle:'',
}) messageDetail: ''
},()=>{
wx.showToast({ wx.showToast({
title: res.message, title: res.message,
icon: 'success' icon: 'none'
})
}) })
} }
}) })
} }
} }
}) })

21
pages/topics/message/index.wxml

@ -1,11 +1,16 @@
<!--pages/topics/common/message/index.wxml--> <!--pages/topics/common/message/index.wxml-->
<view class="mian"> <view class="container">
<view class="content-wrapper"> <view class="item">
<view class="section"> <view class="must_fill">*</view>
<textarea class="textArea" value="{{textAreaString}}" bindinput="bindTextAreaInput" placeholder="有什么想留言的内容?" /> <input class="title" value="{{messageTitle}}" bindinput="bindTextInput" placeholder="请输入标题"></input>
<view class="btnView"> </view>
<e-ibutton title="提交" bind:onTap="submit"/>
</view> <view class="line-view"></view>
<view class="item">
<view class="must_fill">*</view>
<textarea class="textArea" value="{{messageDetail}}" bindinput="bindTextAreaInput" placeholder="请输入正文" />
</view>
<view class="btnView">
<e-ibutton title="提交" bind:onTap="submit"/>
</view> </view>
</view>
</view> </view>

27
pages/topics/message/index.wxss

@ -1,16 +1,29 @@
/* pages/topics/common/message/index.wxss */ /* pages/topics/common/message/index.wxss */
.main{ .container{
position: relative; padding: 20px;
} }
.section{ .item{
display: flex; display: flex;
flex-direction: column; flex-direction: row;
padding: 5px 20px 5px 20px;
/* align-items: center; */
}
.must_fill{
font-size: 13px;
color: red;
margin-right: 5px;
}
.title{
font-size: 15px;
} }
.textArea{ .textArea{
width: 100%;
height: 400px;
font-size: 14px; font-size: 14px;
line-height: 10px;
}
.line-view{
height: 1px;
background-color: #F1F1F1;
margin: 10px 0 10px 0;
} }
.btnView{ .btnView{
position: fixed; position: fixed;

36
pages/user/index.js

@ -37,42 +37,6 @@ Page({
onShow: function () { onShow: function () {
this.getUserInfo() this.getUserInfo()
}, },
// isAuthUserInfo () {
// let that = this
// wx.showLoading()
// console.log('未授权')
// return new Promise(resolve => {
// wx.getSetting({
// success (res) {
// if (res.authSetting['scope.userInfo']) {
// // 已经授权,可以直接调用 getUserInfo 获取头像昵称
// wx.getUserInfo({
// success: function (res) {
// let nickName = res.userInfo.nickName
// let avatarUrl = res.userInfo.avatarUrl
// store.saveUserInfo({
// nickName: nickName,
// avatarUrl: avatarUrl,
// phone: ''
// })
// if (nickName && avatarUrl) {
// that.setData({
// isAuth: false
// }, () => {
// wx.hideLoading()
// })
// }
// that.getUserInfo()
// }
// })
// }
// }
// })
// })
// },
// 授权登录 // 授权登录
bindGetUserInfo (e) { bindGetUserInfo (e) {

22
pages/user/myIdea/index.js

@ -121,5 +121,27 @@ Page({
this.onPullDownRefresh() this.onPullDownRefresh()
} }
}) })
},
deleteTopicComment(e) {
let that = this
topicModel.deleteComment(e.detail.id, res => {
if (res.code === 200) {
wx.showToast({
title: '删除成功',
icon: 'none',
success() {
that.setData({
currPage: 1,
})
switch (that.data.segmentIndex) {
case 0:
return that.fetchTopicList()
case 1:
return that.fetchGoodIdeaList()
}
}
})
}
})
} }
}) })

3
pages/user/myIdea/index.wxml

@ -3,7 +3,8 @@
<block wx:for="{{list}}" wx:key="{{index}}"> <block wx:for="{{list}}" wx:key="{{index}}">
<cell <cell
itemData="{{item}}" itemData="{{item}}"
bind:onClickPraise="onClickPraise"/> bind:onClickPraise="onClickPraise"
bind:deleteTopicComment="deleteTopicComment"/>
</block> </block>
<e-empty empty="{{list.length <= 0}}" message="暂无内容"/> <e-empty empty="{{list.length <= 0}}" message="暂无内容"/>
</view> </view>

2
pages/user/myMessage/cell/index.js

@ -11,7 +11,7 @@ Component({
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
}, },
/** /**

24
pages/user/myMessage/cell/index.wxml

@ -1,15 +1,17 @@
<!--pages/user/myMessage/cell/index.wxml--> <!--pages/user/myMessage/cell/index.wxml-->
<view class="cell" id="cell" bindtap="onTap"> <view class="cell" id="cell" bindtap="onTap">
<view class="item-left"> <view class="content">
<!-- <image wx:if="{{itemData.msgType === 0}}" src="/images/user/activity_icon.png"></image> --> <view class="item-left">
<image class="img" wx:if="{{itemData.msgType === 1}}" src="/images/user/msg_icon.png"></image> <!-- <image wx:if="{{itemData.msgType === 0}}" src="/images/user/activity_icon.png"></image> -->
<image class="img" wx:if="{{itemData.msgType === 2}}" src="/images/user/activity_icon.png"></image> <image class="img" wx:if="{{itemData.msgType === 1}}" src="/images/user/msg_icon.png"></image>
</view> <image class="img" wx:if="{{itemData.msgType === 2}}" src="/images/user/activity_icon.png"></image>
<view class="item-right"> </view>
<view class="item-text"> <view class="item-right">
<view class="msgName">{{itemData.msgName}}</view> <view class="item-text">
<view class="title">{{itemData.title}}</view> <view class="msgName">{{itemData.msgName}}</view>
<view class="title">{{itemData.title}}</view>
</view>
<view class="item-time">{{itemData.time}}</view>
</view>
</view> </view>
<view class="item-time">{{itemData.time}}</view>
</view>
</view> </view>

9
pages/user/myMessage/cell/index.wxss

@ -1,8 +1,6 @@
/* pages/user/myMessage/cell/index.wxss */ /* pages/user/myMessage/cell/index.wxss */
.cell{ .cell{
display: flex;
flex-direction: row;
align-items: center;
padding: 5px 10px 5px 10px; padding: 5px 10px 5px 10px;
} }
.item-left{ .item-left{
@ -32,4 +30,9 @@
.item-time{ .item-time{
font-size: 13px; font-size: 13px;
color: #ABABAB; color: #ABABAB;
}
.content {
display: flex;
flex-direction: row;
align-items: center;
} }

8
pages/user/myMessage/index.js

@ -4,6 +4,8 @@ import relativeTime from '../../../utils/dayjs/relativeTime.js'
dayjs.extend(relativeTime); dayjs.extend(relativeTime);
import { UserModel } from '../../../models/user.js' import { UserModel } from '../../../models/user.js'
let userModel = new UserModel() let userModel = new UserModel()
import { TopicModel } from '../../../models/topic.js'
let topicModel = new TopicModel()
Page({ Page({
@ -28,7 +30,7 @@ Page({
console.log('我的消息') console.log('我的消息')
const datas = res.result.list const datas = res.result.list
let tempDatas = [] let tempDatas = []
datas.forEach(item => { datas.forEach((item,index) => {
tempDatas.push({ tempDatas.push({
contentId: item.contentId, contentId: item.contentId,
messageId:item.id, messageId:item.id,
@ -36,7 +38,9 @@ Page({
time: item.createTime, time: item.createTime,
messageStatus: item.messageStatus, messageStatus: item.messageStatus,
msgType: Number(item.messageType), msgType: Number(item.messageType),
msgName: item.messageType === '1' ? '评论消息' : '活动消息' msgName: item.messageType === '1' ? '评论消息' : '活动消息',
dataIndex: index + ((page - 1) * 10),
isTouchMove: false,
}) })
}) })
if (page == 1) { if (page == 1) {

1
pages/user/myTopics/index.js

@ -65,6 +65,7 @@ Page({
time: item.createTime, time: item.createTime,
dataIndex: index + ((page - 1) * 10), dataIndex: index + ((page - 1) * 10),
isTouchMove: false, isTouchMove: false,
selectedTitle: this.data.selectedTitle,
}) })
}) })
if (page == 1) { if (page == 1) {

53
pages/user/myTopics/myParticipant/cell/index.js

@ -14,6 +14,7 @@ Component({
type:String, type:String,
dataIndex: Number, dataIndex: Number,
isTouchMove: Boolean, isTouchMove: Boolean,
selectedTitle:Number,
}, },
/** /**
@ -42,35 +43,39 @@ Component({
this.triggerEvent('clickListItem', { item: item }) this.triggerEvent('clickListItem', { item: item })
}, },
touchstart: function (e) { touchstart: function (e) {
//开始触摸时 重置所有删除 if(this.properties.selectedTitle === 1){
if (this.properties.isTouchMove) { //开始触摸时 重置所有删除
if (this.properties.isTouchMove) {
this.setData({
isTouchMove: false
})
}
this.setData({ this.setData({
isTouchMove: false startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY,
}) })
} }
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY,
})
}, },
touchmove: function (e) { touchmove: function (e) {
var that = this if (this.properties.selectedTitle === 1) {
// index = e.currentTarget.dataset.index,//当前索引 var that = this
const startX = that.data.startX//开始X坐标 // index = e.currentTarget.dataset.index,//当前索引
const startY = that.data.startY//开始Y坐标 const startX = that.data.startX//开始X坐标
const touchMoveX = e.changedTouches[0].clientX//滑动变化坐标 const startY = that.data.startY//开始Y坐标
const touchMoveY = e.changedTouches[0].clientY//滑动变化坐标 const touchMoveX = e.changedTouches[0].clientX//滑动变化坐标
//获取滑动角度 const touchMoveY = e.changedTouches[0].clientY//滑动变化坐标
const angle = that.angle({ X: startX, Y: startY }, { X: touchMoveX, Y: touchMoveY }) //获取滑动角度
if (Math.abs(angle) > 30) return; const angle = that.angle({ X: startX, Y: startY }, { X: touchMoveX, Y: touchMoveY })
if (touchMoveX > startX) //右滑 if (Math.abs(angle) > 30) return;
that.setData({ if (touchMoveX > startX) //右滑
isTouchMove: false that.setData({
}) isTouchMove: false
else //左滑 })
that.setData({ else //左滑
isTouchMove: true that.setData({
}) isTouchMove: true
})
}
}, },
angle: function (start, end) { angle: function (start, end) {
var _X = end.X - start.X, var _X = end.X - start.X,

2
pages/user/myTopics/myParticipant/cell/index.wxss

@ -114,7 +114,7 @@ image{
font-size: 14px; font-size: 14px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
border-bottom:1px solid #ccc; border-bottom:1px solid #E7E7E7;
width: 100%; width: 100%;
overflow: hidden overflow: hidden
} }

2
pages/user/myTopics/myParticipant/index.wxml

@ -4,7 +4,7 @@
<cell <cell
topicId="{{item.topicId}}" topicId="{{item.topicId}}"
title="{{item.title}}" title="{{item.title}}"
userIcon="{{item.groupAvator}}" userIcon="{{item.userIcon}}"
topicImg="{{item.topicImg}}" topicImg="{{item.topicImg}}"
userName="{{item.userName}}" userName="{{item.userName}}"
time="{{item.time}}" time="{{item.time}}"

3
pages/user/myTopics/myRelease/index.wxml

@ -9,6 +9,9 @@
userName="{{item.userName}}" userName="{{item.userName}}"
time="{{item.time}}" time="{{item.time}}"
commentNum="{{item.commentNum}}" commentNum="{{item.commentNum}}"
dataIndex="{{item.dataIndex}}"
selectedTitle="{{item.selectedTitle}}"
isTouchMove="{{item.isTouchMove}}"
bind:clickListItem="clickListItem" bind:clickListItem="clickListItem"
bind:deleteListItem="deleteListItem"/> bind:deleteListItem="deleteListItem"/>
</block> </block>

Loading…
Cancel
Save