Browse Source

update 议题删除功能

master
fanp 6 years ago
parent
commit
0b3e98b5e8
  1. 12
      models/topic.js
  2. 28
      pages/topics/index.js
  3. 2
      pages/topics/index.wxml
  4. 58
      pages/topics/interactive/cell/index.js
  5. 45
      pages/topics/interactive/cell/index.wxml
  6. 54
      pages/topics/interactive/cell/index.wxss
  7. 4
      pages/topics/interactive/index.js
  8. 6
      pages/topics/interactive/index.wxml
  9. 2
      pages/topics/interactive/topicArticle/index.wxml
  10. 86
      pages/user/index.js
  11. 6
      pages/user/myInfo/index.js
  12. 1
      pages/user/myInfo/index.json
  13. 16
      pages/user/myInfo/index.wxml
  14. 10
      pages/user/myInfo/index.wxss
  15. 48
      pages/user/myTopics/index.js
  16. 1
      pages/user/myTopics/index.json
  17. 2
      pages/user/myTopics/index.wxml
  18. 47
      pages/user/myTopics/myParticipant/cell/index.js
  19. 45
      pages/user/myTopics/myParticipant/cell/index.wxml
  20. 87
      pages/user/myTopics/myParticipant/cell/index.wxss
  21. 3
      pages/user/myTopics/myParticipant/index.js
  22. 3
      pages/user/myTopics/myParticipant/index.wxml
  23. 3
      pages/user/myTopics/myRelease/index.js
  24. 5
      pages/user/myTopics/myRelease/index.wxml

12
models/topic.js

@ -3,6 +3,7 @@ import {HTTP, Method} from '../utils/http.js'
const TopicBaseUrl = { const TopicBaseUrl = {
topic_list_url:'/api/group/page', // 议题列表 topic_list_url:'/api/group/page', // 议题列表
topic_addGroup_url:'/api/group/addGroup', // 新建议题 topic_addGroup_url:'/api/group/addGroup', // 新建议题
topic_deleteGroup_url:'/api/group/deleteGroup/',// 删除议题
topic_goldenList_url:'/api/comment/goldenList', // 金点子列表 topic_goldenList_url:'/api/comment/goldenList', // 金点子列表
topic_detail_url:'/api/group/queryById/', // 议题详情 topic_detail_url:'/api/group/queryById/', // 议题详情
topic_detailComment_url:'/api/comment/page', // 评论列表 topic_detailComment_url:'/api/comment/page', // 评论列表
@ -57,6 +58,17 @@ class TopicModel extends HTTP {
this.request(params) this.request(params)
} }
deleteGroup(id, success) {
let params = {
url: TopicBaseUrl.topic_deleteGroup_url + `${id}`,
method: Method.POST,
data: {},
success: success
}
this.request(params)
}
getTopicDetailComment(id, page,success) { getTopicDetailComment(id, page,success) {
let params = { let params = {
url: TopicBaseUrl.topic_detailComment_url, url: TopicBaseUrl.topic_detailComment_url,

28
pages/topics/index.js

@ -61,7 +61,7 @@ Page({
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({
topicId: item.id, topicId: item.id,
userIcon: item.groupAvator || '', userIcon: item.groupAvator || '',
@ -71,6 +71,8 @@ Page({
commentNum: item.commentNum, commentNum: item.commentNum,
topicImg: item.image, topicImg: item.image,
time: item.createTime, time: item.createTime,
dataIndex:index+((page-1)*10),
isTouchMove:false,
}) })
}) })
if (page == 1) { if (page == 1) {
@ -201,6 +203,30 @@ Page({
return this.fetchGoodIdeaList() return this.fetchGoodIdeaList()
} }
}, },
deleteTopic(e) {
console.log(e.detail.id)
let that = this
topicModel.deleteGroup(e.detail.id, res => {
console.log(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

@ -1,7 +1,7 @@
<!--pages/topics/index.wxml--> <!--pages/topics/index.wxml-->
<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}}" /> <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"/>
<message wx:if="{{segmentIndex==2}}" /> <message wx:if="{{segmentIndex==2}}" />
</view> </view>

58
pages/topics/interactive/cell/index.js

@ -1,4 +1,5 @@
// pages/topics/common/interactive/common/imageCell/index.js // pages/topics/common/interactive/common/imageCell/index.js
import { store } from '../../../../utils/store.js'
Component({ Component({
/** /**
@ -11,14 +12,17 @@ Component({
userIcon:String, userIcon:String,
userName:String, userName:String,
time: String, time: String,
commentNum: Number commentNum: Number,
dataIndex:Number,
isTouchMove:Boolean,
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
startX: 0, //开始坐标
startY: 0
}, },
/** /**
@ -27,6 +31,56 @@ Component({
methods: { methods: {
onTap() { onTap() {
this.triggerEvent('clickListItem', { topicId: this.properties.topicId }) this.triggerEvent('clickListItem', { topicId: this.properties.topicId })
},
touchstart: function (e) {
let {nickName} = store.readUserInfo()
if (e.currentTarget.dataset.name === nickName) {
//开始触摸时 重置所有删除
if (this.properties.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
})
}
// console.log(e)
},
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('deleteTopic', { id: e.currentTarget.dataset.id })
} }
} }
}) })

45
pages/topics/interactive/cell/index.wxml

@ -1,29 +1,34 @@
<!--pages/topics/common/interactive/common/imageCell/index.wxml--> <!--pages/topics/common/interactive/common/imageCell/index.wxml-->
<view class="cell" bindtap="onTap"> <view class="cell" bindtap="onTap">
<view class="left {{articleImg === '' ? 'leftActive' : ''}}"> <view class="touch-item {{isTouchMove ? 'touch-move-active' : ''}}" data-index="{{dataIndex}}" data-name="{{userName}}" bindtouchstart="touchstart" bindtouchmove="touchmove" >
<view class="left-top"> <view class="content">
<view class="cell_title">{{title}}</view> <view class="left {{articleImg === '' ? 'leftActive' : ''}}">
</view> <view class="left-top">
<view class="left-bottom"> <view class="cell_title">{{title}}</view>
<view class="left-bottom-userInfo">
<view class="user-icon">
<image src="{{userIcon || 'images/avatar.png'}}"></image>
</view> </view>
<view class="userName">{{userName}}</view> <view class="left-bottom">
<view class="cell_info_meta">{{time}}</view>
</view> <view class="left-bottom-userInfo">
<view class="user-icon">
<image src="{{userIcon || 'images/avatar.png'}}"></image>
</view>
<view class="userName">{{userName}}</view>
<view class="cell_info_meta">{{time}}</view>
</view>
<view class="left-bottom-comments">
<view class="comments-icon">
<image src="/images/common/com_count.png"></image>
</view>
<view class="commentNum">{{commentNum}}</view>
</view>
<view class="left-bottom-comments">
<view class="comments-icon">
<image src="/images/common/com_count.png"></image>
</view> </view>
<view class="commentNum">{{commentNum}}</view>
</view> </view>
<view class="right" wx:if="{{topicImg.length > 0}}">
<image class="articleImg" src="{{topicImg}}"></image>
</view>
</view> </view>
</view> <view class="del" data-index="{{dataIndex}}" data-id="{{topicId}}" catchtap="del">删除</view>
<view class="right" wx:if="{{topicImg.length > 0}}">
<image class="articleImg" src="{{topicImg}}"></image>
</view> </view>
</view> </view>

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

@ -1,10 +1,11 @@
/* pages/topics/common/interactive/common/imageCell/index.wxss */ /* pages/topics/common/interactive/common/imageCell/index.wxss */
.cell { .cell {
border-bottom: 1px solid #E7E7E7; /* border-bottom: 1px solid #E7E7E7;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding: 10px 20px; padding: 10px 20px;
align-items: center; align-items: center; */
/* min-height: 80px; */
} }
.left{ .left{
display: flex; display: flex;
@ -23,6 +24,7 @@
justify-content: space-between; justify-content: space-between;
} }
.left-bottom-userInfo{ .left-bottom-userInfo{
padding: 5px 0;
display: flex; display: flex;
flex: row; flex: row;
align-items: center; align-items: center;
@ -67,8 +69,8 @@
color: #3B3B3B; color: #3B3B3B;
} }
.right{ .right{
width: 30%; width: 35%;
height: 70px; height: 80px;
border-radius: 5px; border-radius: 5px;
background-color: #EEEEEE; background-color: #EEEEEE;
} }
@ -96,12 +98,10 @@ image{
color: #9C9C9C; color: #9C9C9C;
} }
.cell_info_meta { .cell_info_meta {
padding-top: 10rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
font-size: 12px; font-size: 12px;
line-height: 12px;
color: #D4D4D4; color: #D4D4D4;
} }
.cell_info_top { .cell_info_top {
@ -109,3 +109,45 @@ image{
width: 20px; width: 20px;
height: 12px; height: 12px;
} }
.touch-item {
font-size: 14px;
display: flex;
justify-content: space-between;
border-bottom:1px solid #ccc;
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 20px;
align-items: center;
}
.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);
}

4
pages/topics/interactive/index.js

@ -27,10 +27,14 @@ Component({
}) })
}, },
clickListItem(e) { clickListItem(e) {
console.log(e)
const topicId = e.detail.topicId; const topicId = e.detail.topicId;
wx.navigateTo({ wx.navigateTo({
url: `/pages/topics/interactive/topicArticle/index?topicId=${topicId}`, url: `/pages/topics/interactive/topicArticle/index?topicId=${topicId}`,
}) })
},
deleteTopic(e){
this.triggerEvent('deleteTopic', { id: e.detail.id })
} }
} }
}) })

6
pages/topics/interactive/index.wxml

@ -9,7 +9,11 @@
userName="{{item.userName}}" userName="{{item.userName}}"
time="{{item.time}}" time="{{item.time}}"
commentNum="{{item.commentNum}}" commentNum="{{item.commentNum}}"
bind:clickListItem="clickListItem"/> bind:clickListItem="clickListItem"
dataIndex="{{item.dataIndex}}"
isTouchMove="{{item.isTouchMove}}"
bind:deleteTopic="deleteTopic"
/>
</block> </block>
<view class="publish" bindtap="onTap"> <view class="publish" bindtap="onTap">

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

@ -68,5 +68,5 @@
</view> </view>
</view> </view>
<modal hidden="{{hiddenmodalput}}" confirm-text="提交" cancel-text="取消" bindcancel="cancel" bindconfirm="confirm"> <modal hidden="{{hiddenmodalput}}" confirm-text="提交" cancel-text="取消" bindcancel="cancel" bindconfirm="confirm">
<textarea bindinput="bingTextAreaInput" value="{{currentComment}}" maxlength="400" placeholder="请输入评论" auto-focus/> <textarea bindinput="bingTextAreaInput" value="{{currentComment}}" maxlength="400" placeholder="请输入评论"/>
</modal> </modal>

86
pages/user/index.js

@ -37,42 +37,44 @@ Page({
onShow: function () { onShow: function () {
this.getUserInfo() this.getUserInfo()
}, },
isAuthUserInfo () { // isAuthUserInfo () {
let that = this // let that = this
wx.showLoading() // wx.showLoading()
console.log('未授权') // console.log('未授权')
return new Promise(resolve => { // return new Promise(resolve => {
wx.getSetting({ // wx.getSetting({
success (res) { // success (res) {
if (res.authSetting['scope.userInfo']) { // if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称 // // 已经授权,可以直接调用 getUserInfo 获取头像昵称
wx.getUserInfo({ // wx.getUserInfo({
success: function (res) { // success: function (res) {
let nickName = res.userInfo.nickName // let nickName = res.userInfo.nickName
let avatarUrl = res.userInfo.avatarUrl // let avatarUrl = res.userInfo.avatarUrl
store.saveUserInfo({ // store.saveUserInfo({
nickName: nickName, // nickName: nickName,
avatarUrl: avatarUrl, // avatarUrl: avatarUrl,
phone: '' // phone: ''
}) // })
if (nickName && avatarUrl) { // if (nickName && avatarUrl) {
that.setData({ // that.setData({
isAuth: false // isAuth: false
}, () => { // }, () => {
wx.hideLoading() // wx.hideLoading()
}) // })
} // }
that.getUserInfo() // that.getUserInfo()
} // }
}) // })
} // }
} // }
}) // })
}) // })
}, // },
// 授权登录
bindGetUserInfo (e) { bindGetUserInfo (e) {
console.log(e.detail.userInfo) console.log(e.detail.userInfo)
if (e.detail.userInfo){ if (e.detail.userInfo){
@ -82,17 +84,16 @@ Page({
this.updateUserInfo(avatarUrl,nickName) this.updateUserInfo(avatarUrl,nickName)
} }
}, },
hasBindUserInfo () {
return store.hasBindUserInfo();
},
// 将用户信息发送服务器 // 将用户信息发送服务器
updateUserInfo (avatarUrl, nickName) { updateUserInfo (avatarUrl, nickName) {
userModel.updateUserInfo(avatarUrl, nickName, res => { userModel.updateUserInfo(avatarUrl, nickName, res => {
if(res.code === 200){ if(res.code === 200){
this.isAuthUserInfo() this.getUserInfo()
} }
}) })
}, },
// 获取用户信息
getUserInfo () { getUserInfo () {
userModel.getUserInfo(res => { userModel.getUserInfo(res => {
let nickName = res.result.nickName let nickName = res.result.nickName
@ -104,7 +105,7 @@ Page({
userInfo: res.result, userInfo: res.result,
avatarUrl: res.result.avatarUrl, avatarUrl: res.result.avatarUrl,
nickName: res.result.nickName, nickName: res.result.nickName,
reAuth: true reAuth: true,
},()=>{ },()=>{
if (store.hasPhone()) { if (store.hasPhone()) {
console.log('已经绑定手机号码') console.log('已经绑定手机号码')
@ -130,6 +131,7 @@ Page({
}) })
}, },
// 获取未读消息
getMsgStatus () { getMsgStatus () {
userModel.getMyMessageTotal(res => { userModel.getMyMessageTotal(res => {
console.log(res.result.total) console.log(res.result.total)
@ -138,13 +140,15 @@ Page({
}) })
}) })
}, },
// cell点击
onTapItem (e) { onTapItem (e) {
const { type } = e.currentTarget.dataset const { type } = e.currentTarget.dataset
console.log(type) console.log(type)
if (type === 'myInfo'){ if (type === 'myInfo'){
// wx.navigateTo({ wx.navigateTo({
// url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}`, url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}`,
// }) })
} else { } else {
wx.navigateTo({ wx.navigateTo({
url: `/pages/user/${type}/index`, url: `/pages/user/${type}/index`,

6
pages/user/myInfo/index.js

@ -32,9 +32,9 @@ Page({
onTapItem(e) { onTapItem(e) {
const { type } = e.currentTarget.dataset const { type } = e.currentTarget.dataset
console.log(type) console.log(type)
if(type === 'userIcon'){ // if(type === 'userIcon'){
this.upload() // this.upload()
} // }
}, },
upload(){ upload(){
let that = this let that = this

1
pages/user/myInfo/index.json

@ -1,5 +1,4 @@
{ {
"enablePullDownRefresh": true,
"navigationBarTitleText": "个人资料", "navigationBarTitleText": "个人资料",
"usingComponents": { "usingComponents": {
"e-ibutton": "/components/image-button/index", "e-ibutton": "/components/image-button/index",

16
pages/user/myInfo/index.wxml

@ -11,28 +11,32 @@
bindtap="onTapItem" data-type="userName" bindtap="onTapItem" data-type="userName"
title="名字" title="名字"
ext-class="cell-item"> ext-class="cell-item">
<input slot="footer" class="msg_footer" bindinput="bindNikeNameInput" value="{{nikeName}}"></input> <view slot="footer" class="msg_footer" >{{nikeName}}</view>
<!-- <input slot="footer" class="footer_input" bindinput="bindNikeNameInput" value="{{nikeName}}"></input> -->
</mp-cell> </mp-cell>
<mp-cell <mp-cell
bindtap="onTapItem" data-type="userPhone" bindtap="onTapItem" data-type="userPhone"
title="手机号" title="手机号"
ext-class="cell-item"> ext-class="cell-item">
<input slot="footer" class="msg_footer" bindinput="bindPhoneInput" value="{{phone}}"></input> <view slot="footer" class="msg_footer" >{{phone}}</view>
<!-- <input slot="footer" class="footer_input" bindinput="bindPhoneInput" value="{{phone}}"></input> -->
</mp-cell> </mp-cell>
<mp-cell <mp-cell
bindtap="onTapItem" data-type="workUnit" bindtap="onTapItem" data-type="workUnit"
title="工作单位" title="工作单位"
ext-class="cell-item"> ext-class="cell-item">
<input slot="footer" class="msg_footer" bindinput="bindCompanyInput" value="{{company}}"></input> <view slot="footer" class="msg_footer" >{{company}}</view>
<!-- <input slot="footer" class="footer_input" bindinput="bindCompanyInput" value="{{company}}"></input> -->
</mp-cell> </mp-cell>
<mp-cell <mp-cell
bindtap="onTapItem" data-type="position" bindtap="onTapItem" data-type="position"
title="职务" title="职务"
ext-class="cell-item"> ext-class="cell-item">
<input slot="footer" class="msg_footer" bindinput="bindPositionInput" value="{{position}}"></input> <view slot="footer" class="msg_footer" >{{position}}</view>
<!-- <input slot="footer" class="footer_input" bindinput="bindPositionInput" value="{{position}}"></input> -->
</mp-cell> </mp-cell>
<view class="btnView"> <!-- <view class="btnView">
<e-ibutton title="提交" bind:onTap="submit"/> <e-ibutton title="提交" bind:onTap="submit"/>
</view> </view> -->
</mp-cells> </mp-cells>
</view> </view>

10
pages/user/myInfo/index.wxss

@ -40,13 +40,13 @@
} }
/* 页面body */ /* 页面body */
.page_bd .weui-cell{ .page_bd .weui-cell{
padding: 10px 16px 10px 16px; /* padding: 10px 16px 10px 16px; */
} }
.weui-cell_wxss{ .weui-cell_wxss{
} }
.weui-cell__ft{ .weui-cell__ft{
width: 70%; /* width: 70%; */
} }
.page_bd .weui-cell__hd { .page_bd .weui-cell__hd {
display: flex; display: flex;
@ -58,13 +58,17 @@
height: 16px; height: 16px;
padding: 0 10px 0 0; padding: 0 10px 0 0;
} }
.msg_footer{ .footer_input{
font-size: 14px; font-size: 14px;
border: 1px solid #AAAAAA; border: 1px solid #AAAAAA;
border-radius: 4px; border-radius: 4px;
height: 30px; height: 30px;
text-align: left; text-align: left;
} }
.msg_footer{
font-size: 14px;
text-align: left;
}
.btnView{ .btnView{
position: fixed; position: fixed;
padding: 10px 20px 20px 20px; padding: 10px 20px 20px 20px;

48
pages/user/myTopics/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({
@ -17,7 +19,8 @@ Page({
list:{ list:{
type:Array, type:Array,
value:[] value:[]
} },
currentPage:1,
}, },
/** /**
@ -26,12 +29,32 @@ Page({
onLoad: function (options) { onLoad: function (options) {
this.fetchMyTopicList() this.fetchMyTopicList()
}, },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.setData({
currentPage: 1
})
this.fetchMyTopicList()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let page = this.data.currentPage + 1
this.setData({
currentPage: page
})
this.fetchMyTopicList()
},
fetchMyTopicList(){ fetchMyTopicList(){
let page = this.data.currentPage let page = this.data.currentPage
userModel.getMyTopics(page,this.data.selectedTitle+1,res=>{ userModel.getMyTopics(page,this.data.selectedTitle+1,res=>{
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({
topicId: item.id, topicId: item.id,
title: item.title, title: item.title,
@ -40,6 +63,8 @@ Page({
commentNum: item.commentNum, commentNum: item.commentNum,
topicImg: item.image, topicImg: item.image,
time: item.createTime, time: item.createTime,
dataIndex: index + ((page - 1) * 10),
isTouchMove: false,
}) })
}) })
if (page == 1) { if (page == 1) {
@ -76,5 +101,24 @@ Page({
list:[] list:[]
}); });
this.fetchMyTopicList() this.fetchMyTopicList()
},
deleteTopic(e){
let that = this
topicModel.deleteGroup(e.detail.id,res=>{
console.log(res)
if(res.code === 200){
wx.showToast({
title: '删除成功',
icon: 'none',
success(){
that.setData({
currentPage: 1
})
that.fetchMyTopicList()
}
})
}
})
} }
}) })

1
pages/user/myTopics/index.json

@ -1,4 +1,5 @@
{ {
"enablePullDownRefresh": true,
"navigationBarTitleText": "我的议题", "navigationBarTitleText": "我的议题",
"usingComponents": { "usingComponents": {
"e-segment": "/components/segment/index", "e-segment": "/components/segment/index",

2
pages/user/myTopics/index.wxml

@ -2,5 +2,5 @@
<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}}"/>
<myParticipant wx:if="{{selectedTitle==0}}" list="{{list}}"/> <myParticipant wx:if="{{selectedTitle==0}}" list="{{list}}"/>
<myRelease wx:if="{{selectedTitle==1}}" list="{{list}}"/> <myRelease wx:if="{{selectedTitle==1}}" list="{{list}}" bind:deleteTopic="deleteTopic"/>
</view> </view>

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

@ -11,14 +11,17 @@ Component({
userName: String, userName: String,
time: String, time: String,
commentNum: Number, commentNum: Number,
type:String type:String,
dataIndex: Number,
isTouchMove: Boolean,
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
startX: 0, //开始坐标
startY: 0
}, },
/** /**
@ -37,6 +40,46 @@ Component({
type: this.properties.type type: this.properties.type
} }
this.triggerEvent('clickListItem', { item: item }) this.triggerEvent('clickListItem', { item: item })
},
touchstart: function (e) {
//开始触摸时 重置所有删除
if (this.properties.isTouchMove) {
this.setData({
isTouchMove: false
})
}
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY,
})
},
touchmove: function (e) {
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('deleteListItem', { id: e.currentTarget.dataset.id })
} }
} }
}) })

45
pages/user/myTopics/myParticipant/cell/index.wxml

@ -1,29 +1,34 @@
<!--pages/topics/common/interactive/common/imageCell/index.wxml--> <!--pages/topics/common/interactive/common/imageCell/index.wxml-->
<view class="cell" id="cell" bindtap="onTap"> <view class="cell" id="cell" bindtap="onTap">
<view class="left {{articleImg === '' ? 'leftActive' : ''}}"> <view class="touch-item {{isTouchMove ? 'touch-move-active' : ''}}" data-index="{{dataIndex}}" bindtouchstart="touchstart" bindtouchmove="touchmove" >
<view class="left-top"> <view class="content">
<view class="cell_title">{{title}}</view> <view class="left {{articleImg === '' ? 'leftActive' : ''}}">
</view> <view class="left-top">
<view class="left-bottom"> <view class="cell_title">{{title}}</view>
<view class="left-bottom-userInfo">
<view class="user-icon" wx:if="{{userIcon.length > 0}}">
<image class="img" src="{{userIcon}}"></image>
</view> </view>
<view class="userName">{{userName}}</view> <view class="left-bottom">
<view class="cell_info_meta">{{time}}</view>
</view> <view class="left-bottom-userInfo">
<view class="user-icon" wx:if="{{userIcon.length > 0}}">
<image class="img" src="{{userIcon}}"></image>
</view>
<view class="userName">{{userName}}</view>
<view class="cell_info_meta">{{time}}</view>
</view>
<view class="left-bottom-comments">
<view class="comments-icon">
<image src="/images/common/com_count.png"></image>
</view>
<view class="commentNum">{{commentNum}}</view>
</view>
<view class="left-bottom-comments">
<view class="comments-icon">
<image src="/images/common/com_count.png"></image>
</view> </view>
<view class="commentNum">{{commentNum}}</view>
</view> </view>
<view class="right" wx:if="{{topicImg.length > 0}}">
<image class="articleImg" src="{{topicImg}}"></image>
</view>
</view> </view>
</view> <view class="del" data-index="{{dataIndex}}" data-id="{{topicId}}" catchtap="del">删除</view>
<view class="right" wx:if="{{topicImg.length > 0}}">
<image class="articleImg" src="{{topicImg}}"></image>
</view> </view>
</view> </view>

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

@ -1,25 +1,17 @@
/* pages/topics/common/interactive/common/imageCell/index.wxss */ /* pages/topics/common/interactive/common/imageCell/index.wxss */
.cell { .cell {
/* border-bottom: 1px solid #E7E7E7;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding: 10px 20rpx; padding: 10px 20px;
box-sizing: border-box; align-items: center; */
align-items: center; /* min-height: 80px; */
position: relative;
}
.cell:after {
content: "";
position: absolute;
bottom: 1px;
left: 20px;
right: 20px;
border-bottom: 1px solid #E7E7E7;
} }
.left{ .left{
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 70%; /* width: 70%; */
flex:1;
} }
.leftActive{ .leftActive{
display: flex; display: flex;
@ -32,6 +24,7 @@
justify-content: space-between; justify-content: space-between;
} }
.left-bottom-userInfo{ .left-bottom-userInfo{
padding: 5px 0;
display: flex; display: flex;
flex: row; flex: row;
align-items: center; align-items: center;
@ -39,15 +32,15 @@
.user-icon{ .user-icon{
width: 20px; width: 20px;
height: 20px; height: 20px;
border-radius: 50%; /* border-radius: 50%; */
background-color: #EEEEEE; /* border: 1px solid #ddd; */
/* background-color: #EEEEEE; */
} }
.img{ .user-icon image {
width: 20px; /* border-radius: 50%; */
height: 20px;
} }
.userName{ .userName{
max-width: 120rpx; max-width: 120rpx;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
@ -76,8 +69,8 @@
color: #3B3B3B; color: #3B3B3B;
} }
.right{ .right{
width: 30%; width: 35%;
height: 70px; height: 80px;
border-radius: 5px; border-radius: 5px;
background-color: #EEEEEE; background-color: #EEEEEE;
} }
@ -94,17 +87,21 @@ image{
font-weight: 300; font-weight: 300;
font-size: 17px; font-size: 17px;
color: #000; color: #000;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
} }
.cell_title_selected { .cell_title_selected {
color: #9C9C9C; color: #9C9C9C;
} }
.cell_info_meta { .cell_info_meta {
padding-top: 10rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
font-size: 12px; font-size: 12px;
line-height: 12px;
color: #D4D4D4; color: #D4D4D4;
} }
.cell_info_top { .cell_info_top {
@ -112,3 +109,45 @@ image{
width: 20px; width: 20px;
height: 12px; height: 12px;
} }
.touch-item {
font-size: 14px;
display: flex;
justify-content: space-between;
border-bottom:1px solid #ccc;
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 20px;
align-items: center;
}
.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/user/myTopics/myParticipant/index.js

@ -28,6 +28,7 @@ Component({
wx.navigateTo({ wx.navigateTo({
url: `/pages/topics/interactive/topicArticle/index?topicId=${id}`, url: `/pages/topics/interactive/topicArticle/index?topicId=${id}`,
}) })
} },
} }
}) })

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

@ -9,7 +9,8 @@
userName="{{item.userName}}" userName="{{item.userName}}"
time="{{item.time}}" time="{{item.time}}"
commentNum="{{item.commentNum}}" commentNum="{{item.commentNum}}"
bind:clickListItem="clickListItem"/> bind:clickListItem="clickListItem"
/>
</block> </block>
<e-empty empty="{{list.length <= 0}}" message="暂无内容"/> <e-empty empty="{{list.length <= 0}}" message="暂无内容"/>
</view> </view>

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

@ -28,6 +28,9 @@ Component({
wx.navigateTo({ wx.navigateTo({
url: `/pages/topics/interactive/topicArticle/index?topicId=${id}`, url: `/pages/topics/interactive/topicArticle/index?topicId=${id}`,
}) })
},
deleteListItem(e) {
this.triggerEvent('deleteTopic', { id: e.detail.id })
} }
} }
}) })

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

@ -4,12 +4,13 @@
<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}}"
commentNum="{{item.commentNum}}" commentNum="{{item.commentNum}}"
bind:clickListItem="clickListItem"/> bind:clickListItem="clickListItem"
bind:deleteListItem="deleteListItem"/>
</block> </block>
<e-empty empty="{{list.length <= 0}}" message="暂无内容"/> <e-empty empty="{{list.length <= 0}}" message="暂无内容"/>
</view> </view>

Loading…
Cancel
Save