From ba77e4e8f7090cb776e724b6a08d7863ddb0877f Mon Sep 17 00:00:00 2001 From: fanp Date: Fri, 25 Oct 2019 16:41:34 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=89=80=E6=9C=89=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.js | 2 +- models/topic.js | 16 +++- pages/topics/goodIdea/cell/index.js | 54 ++++++++++- pages/topics/goodIdea/cell/index.wxml | 65 +++++++------ pages/topics/goodIdea/cell/index.wxss | 46 +++++++++- pages/topics/goodIdea/index.js | 3 + pages/topics/goodIdea/index.wxml | 3 +- pages/topics/index.js | 25 ++++- pages/topics/index.wxml | 2 +- pages/topics/interactive/cell/index.wxss | 2 +- .../topics/interactive/submitTopic/index.wxml | 16 ++-- .../topics/interactive/topicArticle/index.js | 92 +++++++++++++++++-- .../interactive/topicArticle/index.wxml | 37 ++++---- .../interactive/topicArticle/index.wxss | 46 +++++++++- pages/topics/message/index.js | 39 +++++--- pages/topics/message/index.wxml | 21 +++-- pages/topics/message/index.wxss | 27 ++++-- pages/user/index.js | 36 -------- pages/user/myIdea/index.js | 22 +++++ pages/user/myIdea/index.wxml | 3 +- pages/user/myMessage/cell/index.js | 2 +- pages/user/myMessage/cell/index.wxml | 24 ++--- pages/user/myMessage/cell/index.wxss | 9 +- pages/user/myMessage/index.js | 8 +- pages/user/myTopics/index.js | 1 + .../user/myTopics/myParticipant/cell/index.js | 53 ++++++----- .../myTopics/myParticipant/cell/index.wxss | 2 +- pages/user/myTopics/myParticipant/index.wxml | 2 +- pages/user/myTopics/myRelease/index.wxml | 3 + 29 files changed, 480 insertions(+), 181 deletions(-) diff --git a/config.js b/config.js index e2b108b..628dec5 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,5 @@ const config = { // 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 } \ No newline at end of file diff --git a/models/topic.js b/models/topic.js index 2d197a6..98e87de 100644 --- a/models/topic.js +++ b/models/topic.js @@ -8,6 +8,7 @@ const TopicBaseUrl = { topic_detail_url:'/api/group/queryById/', // 议题详情 topic_detailComment_url:'/api/comment/page', // 评论列表 topic_addComment_url:'/api/comment/addComment',// 新建议题评论 + topic_deleteComment_url:'/api/comment/deleteComment/', // 删除议题评论 topic_collect_url:'/api/group/collectGroup/', // 收藏 topic_unCollect_url: '/api/collect/deleteCollection/', // 取消收藏 topic_commentPraise_url: '/api/comment/addSupport/', // 点赞 @@ -67,7 +68,17 @@ class TopicModel extends HTTP { } 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) { let params = { @@ -140,11 +151,12 @@ class TopicModel extends HTTP { this.request(params) } - addMessage(content,success){ + addMessage(title,content,success){ let params = { url: TopicBaseUrl.topic_addMessage_url, method: Method.POST, data: { + title:title, content: content }, success: success diff --git a/pages/topics/goodIdea/cell/index.js b/pages/topics/goodIdea/cell/index.js index db0f855..fb7bb6d 100644 --- a/pages/topics/goodIdea/cell/index.js +++ b/pages/topics/goodIdea/cell/index.js @@ -1,4 +1,6 @@ // pages/topics/common/goodIdea/cell/index.js +import { store } from '../../../../utils/store.js' + Component({ /** @@ -17,7 +19,10 @@ Component({ */ data: { 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({ 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 }) } } }) diff --git a/pages/topics/goodIdea/cell/index.wxml b/pages/topics/goodIdea/cell/index.wxml index 6b7177c..04b1612 100644 --- a/pages/topics/goodIdea/cell/index.wxml +++ b/pages/topics/goodIdea/cell/index.wxml @@ -1,40 +1,45 @@ - - - - - - - {{itemData.commentName}} - {{itemData.commentTime}} + + + + - - {{itemData.praiseNum}} - - - - - - {{itemData.comment}} - - {{itemData.topicTtitle}} - - - - + + + + {{itemData.commentName}} + {{itemData.commentTime}} + + + {{itemData.praiseNum}} + + + - {{itemData.topicAuthor}} - {{itemData.topicGroupCreateTime}} - - - + {{itemData.comment}} + + {{itemData.topicTtitle}} + + + + + + {{itemData.topicAuthor}} + {{itemData.topicGroupCreateTime}} + + + + + + {{itemData.topicCommentNum}} + - {{itemData.topicCommentNum}} + {{itemData.topicDetail}} - {{itemData.topicDetail}} - + 删除 + diff --git a/pages/topics/goodIdea/cell/index.wxss b/pages/topics/goodIdea/cell/index.wxss index 2bba21e..f3aed0c 100644 --- a/pages/topics/goodIdea/cell/index.wxss +++ b/pages/topics/goodIdea/cell/index.wxss @@ -1,8 +1,8 @@ /* pages/topics/common/goodIdea/cell/index.wxss */ .cell{ - display: flex; + /* display: flex; flex-direction: row; - padding: 10px; + padding: 10px; */ } .content-left{ width: 20px; @@ -114,4 +114,46 @@ image{ color: #373737; font-size: 13px; /* 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); } \ No newline at end of file diff --git a/pages/topics/goodIdea/index.js b/pages/topics/goodIdea/index.js index 788b31f..b00f87b 100644 --- a/pages/topics/goodIdea/index.js +++ b/pages/topics/goodIdea/index.js @@ -27,6 +27,9 @@ Component({ onClickPraise(e){ const itemData = e.detail.itemData; this.triggerEvent('tapGoodIdeaPraise', { commentId: itemData.commentId }) + }, + deleteTopicComment(e){ + this.triggerEvent('deleteTopicComment', { id: e.detail.id }) } } }) diff --git a/pages/topics/goodIdea/index.wxml b/pages/topics/goodIdea/index.wxml index 601211c..8c10700 100644 --- a/pages/topics/goodIdea/index.wxml +++ b/pages/topics/goodIdea/index.wxml @@ -4,6 +4,7 @@ + bind:onClickPraise="onClickPraise" + bind:deleteTopicComment="deleteTopicComment"/> diff --git a/pages/topics/index.js b/pages/topics/index.js index 81fd443..daeb49c 100644 --- a/pages/topics/index.js +++ b/pages/topics/index.js @@ -204,7 +204,7 @@ Page({ } }, deleteTopic(e) { - console.log(e.detail.id) + // console.log(e.detail.id) let that = this topicModel.deleteGroup(e.detail.id, 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){ this.fetchGoodIdeaPraise(e.detail.commentId) }, diff --git a/pages/topics/index.wxml b/pages/topics/index.wxml index 980a759..f4a3402 100644 --- a/pages/topics/index.wxml +++ b/pages/topics/index.wxml @@ -2,6 +2,6 @@ - + diff --git a/pages/topics/interactive/cell/index.wxss b/pages/topics/interactive/cell/index.wxss index 68e225e..2bb93a3 100644 --- a/pages/topics/interactive/cell/index.wxss +++ b/pages/topics/interactive/cell/index.wxss @@ -114,7 +114,7 @@ image{ font-size: 14px; display: flex; justify-content: space-between; - border-bottom:1px solid #ccc; + border-bottom:1px solid #E7E7E7; width: 100%; overflow: hidden } diff --git a/pages/topics/interactive/submitTopic/index.wxml b/pages/topics/interactive/submitTopic/index.wxml index eddd7d6..7840002 100644 --- a/pages/topics/interactive/submitTopic/index.wxml +++ b/pages/topics/interactive/submitTopic/index.wxml @@ -1,15 +1,15 @@ - - - - - - -