栏目内容评论点赞等-目前做评论

This commit is contained in:
高健 2021-09-07 14:44:34 +08:00
parent 1e86f1a0f0
commit 9a5a5a188d
13 changed files with 273 additions and 102 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

View File

@ -191,13 +191,7 @@
</view>
</view>
<!-- 评论信息 -->
<!-- <view class="comment-box">
<view>评论内容({{10}})</view>
<view class="comment-item">
<image></image>
<view class="comment-content">
</view>
</view>
</view> -->
<scroll-view>
</scroll-view>
</view>

View File

@ -49,7 +49,8 @@ Page({
curSelPhotoDisplay: '1', //图片的显示方式 1.九宫格 2.轮播 3.轮播(自动) 4.平铺
curVideoDisplay: '1', //视频展示方式 1.九宫格 2.平铺
curTextAlign: '1', //文字显示排列 1.居左 2.居中 3.居右
curFieldType: '0', //编辑选择的文件类型
curFieldTypeIndex: 0, //编辑选择的文件类型
curFieldType: 'text', //编辑选择的文件类型
selDirection: '1', //选中的插入方向 1.插入到下面 2.插入的上面
isInsert: false, //是否显示插入选项
topBoxHeight: 100, //顶部类型选择框的高度
@ -57,7 +58,8 @@ Page({
audioDuration: 0, //录音文件的时长
isRecording: false, //是否正在录音
speedStep: 5, //快进快退的时间
sourceType: 'add', //用来标识是添加还是编辑 add添加 edit编辑
sourceType: 'add', //用来标识是添加还是编辑 add添加 edit编辑 insert插入
insertIndex: -1, //插入的索引
optionsList: [{
id: '1',
name: '选项一',
@ -114,7 +116,11 @@ Page({
var tempItem = {}
tempItem['type'] = 'map'
tempItem['value'] = item
_self.data.valueList.push(tempItem)
if (_self.data.sourceType == 'add') {
_self.data.valueList.push(tempItem)
} else {
_self.data.valueList.splice(_self.data.currentIndex, _self.data.sourceType == 'edit' ? 1 : 0, tempItem)
}
_self.setData({
valueList: _self.data.valueList
})
@ -268,8 +274,10 @@ Page({
},
//编辑选择出入的类型
chooseFieldType(e) {
var idx = e.currentTarget.dataset.idx
var type = e.currentTarget.dataset.type
this.setData({
curFieldTypeIndex: idx,
curFieldType: type
})
},
@ -288,7 +296,11 @@ Page({
tempPhoto['type'] = 'photo'
tempPhoto['valueList'] = tempList
tempPhoto['displayType'] = _self.data.curSelPhotoDisplay
_self.data.valueList.push(tempPhoto)
if (_self.data.sourceType == 'add') {
_self.data.valueList.push(tempPhoto)
} else {
_self.data.valueList.splice(_self.data.currentIndex, _self.data.sourceType == 'edit' ? 1 : 0, tempPhoto)
}
_self.setData({
valueList: _self.data.valueList,
photoList: [],
@ -320,7 +332,7 @@ Page({
if (_self.data.sourceType == 'add') {
_self.data.valueList.push(tempVideo)
} else {
_self.data.valueList.splice(_self.data.currentIndex, 1, tempVideo)
_self.data.valueList.splice(_self.data.currentIndex, _self.data.sourceType == 'edit' ? 1 : 0, tempVideo)
}
_self.setData({
valueList: _self.data.valueList,
@ -340,6 +352,49 @@ Page({
//确定插入数据
doInsert() {
//根据选择的类型与方向插入数据
var _self = this
var inIndex = -1
//selDirection 1是上面 2是下面
if (_self.data.selDirection == 1) {
inIndex = _self.data.currentIndex
} else {
inIndex = ++_self.data.currentIndex
}
_self.setData({
insertIndex: inIndex,
sourceType: 'insert',
isInsert: false,
})
switch (_self.data.curFieldType) {
case 'text':
case 'textarea': //文本域
this.setData({
isShowInput: true
})
break
case 'video': //视频
_self.chooseVideo()
break
case 'audio': //音频
_self.checkRecordPermission()
break
case 'photo': //图片
_self.chooseImg()
break
case 'map': //地图
_self.doChooseLocation()
break
case 'select': //选项
_self.setData({
isShowSelect: true
})
break
case 'link': //链接
_self.setData({
isShowLink: true
})
break
}
},
hideEditBox() {
//隐藏编辑框
@ -382,7 +437,11 @@ Page({
var tempText = {}
tempText['type'] = 'link'
tempText['value'] = _self.data.curLinkText
_self.data.valueList.push(tempText)
if (_self.data.sourceType == 'add') {
_self.data.valueList.push(tempText)
} else {
_self.data.valueList.splice(_self.data.currentIndex, _self.data.sourceType == 'edit' ? 1 : 0, tempText)
}
_self.setData({
valueList: _self.data.valueList,
curLinkText: '',
@ -393,41 +452,17 @@ Page({
//保存输入的文本
doConfirmInput() {
var _self = this
if (_self.data.sourceType == 'add') {
if (_self.data.curTextValue == '') {
wx.showToast({
title: '请输入内容',
icon: 'error'
})
} else {
//保存
var tempText = {}
tempText['type'] = 'text'
tempText['value'] = _self.data.curTextValue
var textAlign = 'left'
switch (_self.data.curTextAlign) {
case '1':
textAlign = 'left'
break
case '2':
textAlign = 'center'
break
case '3':
textAlign = 'right'
break
}
tempText['textAlign'] = textAlign
_self.data.valueList.push(tempText)
_self.setData({
valueList: _self.data.valueList,
curTextValue: '',
isShowInput: false,
curTextAlign: '1'
})
}
if (_self.data.curTextValue == '') {
wx.showToast({
title: '请输入内容',
icon: 'error'
})
} else {
//编辑
var textAlign = _self.data.valueList[_self.data.currentIndex].textAlign
//保存
var tempText = {}
tempText['type'] = 'text'
tempText['value'] = _self.data.curTextValue
var textAlign = 'left'
switch (_self.data.curTextAlign) {
case '1':
textAlign = 'left'
@ -439,12 +474,16 @@ Page({
textAlign = 'right'
break
}
_self.data.valueList[_self.data.currentIndex].value = _self.data.curTextValue
_self.data.valueList[_self.data.currentIndex].textAlign = textAlign
tempText['textAlign'] = textAlign
if (_self.data.sourceType == 'add') {
_self.data.valueList.push(tempText)
} else {
_self.data.valueList.splice(_self.data.currentIndex, _self.data.sourceType == 'edit' ? 1 : 0, tempText)
}
_self.setData({
isShowInput: false,
valueList: _self.data.valueList,
curTextValue: '',
isShowInput: false,
curTextAlign: '1'
})
}
@ -547,10 +586,6 @@ Page({
},
//选择定位点
doChooseLocation(e) {
// var index = e.currentTarget.dataset.index
// this.setData({
// curMapIndex: index
// })
var curLoc = JSON.stringify(location)
wx.navigateTo({
url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${curLoc}&category=${category}`
@ -592,18 +627,22 @@ Page({
_self.checkRecordPermission()
break
case 'photo': //图片
console.log(_self.data.valueList[idx])
_self.setData({
curSelPhotoDisplay: _self.data.valueList[idx].displayType,
photoList: _self.data.valueList[idx].valueList,
isShowPhoto: true
})
break
case 'map': //地图
location.latitude = _self.data.valueList[idx].value.latitude
location.longitude = _self.data.valueList[idx].value.longitude
_self.doChooseLocation()
break
case 'select': //选项
_self.setData({
isShowSelect: true
})
break
case 'link': //链接
_self.setData({
curLinkText: _self.data.valueList[idx].value,
isShowLink: true
})
break
@ -678,7 +717,11 @@ Page({
_self.data.audioFile.curDurationStr = '00:00'
_self.data.audioFile.curDuration = 0
_self.data.audioFile.isPlay = false
_self.data.valueList.push(tempAudio)
if (_self.data.sourceType == 'add') {
_self.data.valueList.push(tempAudio)
} else {
_self.data.valueList.splice(_self.data.currentIndex, _self.data.sourceType == 'edit' ? 1 : 0, tempAudio)
}
_self.setData({
valueList: _self.data.valueList,
audioFile: null,
@ -821,6 +864,7 @@ Page({
isShowEdit: false,
isShowVideo: false,
isShowSelect: false,
sourceType: 'add'
})
},
//音频拖动

View File

@ -53,7 +53,8 @@
{{item.value}}</view>
</view>
<!-- 图片 -->
<view wx:if="{{item.type=='photo'}}" catchtap="showEditBox" class="item-box" data-idx="{{index}}">
<view wx:if="{{item.type=='photo'}}" catchtap="showEditBox"
class="item-box {{currentIndex==index ? 'sel-border':''}}" data-idx="{{index}}">
<!-- 九宫格 -->
<view class="grid col-3 grid-square flex-sub" wx:if="{{item.displayType=='1'}}" style="width: 100%;">
<view class="bg-img" wx:for="{{item.valueList}}" wx:key="idx" wx:for-item="photo">
@ -80,7 +81,8 @@
</view>
</view>
<!-- 视频 -->
<view wx:if="{{item.type=='video'}}" catchtap="showEditBox" class="item-box" data-idx="{{index}}">
<view wx:if="{{item.type=='video'}}" catchtap="showEditBox"
class="item-box {{currentIndex==index ? 'sel-border':''}}" data-idx="{{index}}">
<!-- 九宫格 -->
<view class="grid col-3 grid-square flex-sub" wx:if="{{item.displayType=='1'}}" style="width: 100%;">
<view class="bg-img" wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx"
@ -105,7 +107,8 @@
</block>
</view>
<!-- 音频 -->
<view wx:if="{{item.type=='audio'}}" catchtap="showEditBox" class="item-box" data-idx="{{index}}">
<view wx:if="{{item.type=='audio'}}" catchtap="showEditBox"
class="item-box {{currentIndex == index ? 'sel-border': ''}}" data-idx="{{index}}">
<view class="play-box-shadow-little">
<view class="flex justify-between align-center" style="width:80%;">
<text>{{item.value.curDurationStr}}</text>
@ -130,7 +133,8 @@
</view>
</view>
<!-- 地图 -->
<view wx:if="{{item.type=='map'}}" catchtap="showEditBox" class="item-box" data-idx="{{index}}">
<view wx:if="{{item.type=='map'}}" catchtap="showEditBox"
class="item-box {{currentIndex == index ? 'sel-border':''}}" data-idx="{{index}}">
<view class="flex flex-direction align-center bg-white radius item-padding">
<view style="width: 100%;">
<view class="flex justify-between">
@ -147,7 +151,8 @@
</view>
</view>
<!-- 链接 -->
<view wx:if="{{item.type=='link'}}" catchtap="showEditBox" class="item-box" data-idx="{{index}}">
<view wx:if="{{item.type=='link'}}" catchtap="showEditBox"
class="item-box {{currentIndex == index ? 'sel-border':''}}" data-idx="{{index}}">
<view style="width: 100%;font-size: 32rpx;">{{item.value}}</view>
</view>
<!-- 选项 -->
@ -156,7 +161,7 @@
<view
style="display: flex;flex-direction: row;justify-content: flex-start;align-items: center;flex-wrap: wrap;width: 100%;">
<block wx:for="{{item.valueList}}" wx:key="index" wx:for-item="options">
<view class="cu-tag bg-blue" style="margin:15rpx 15rpx 0rpx 15rpx;">
<view class="cu-tag bg-blue">
{{options.name}}
</view>
</block>
@ -164,7 +169,8 @@
</view>
<view wx:if="{{currentIndex == index}}">
<view class="control-box">
<view class="item" catchtap="editItem" data-index="{{index}}" data-type="{{item.type}}">
<view class="item" catchtap="editItem" data-index="{{index}}" data-type="{{item.type}}"
wx:if="{{item.type != 'audio'}}">
<text class="cuIcon-edit bg-yellow-light"></text>
<text style="margin-left: 15rpx;">编辑</text>
</view>
@ -187,7 +193,7 @@
<text class="{{selDirection=='1' ? 'cuIcon-radiobox':'cuIcon-round'}}"></text>
</view>
<view class="cu-tag {{selDirection=='1' ? 'line-yellowlight2':'line-black'}}">
插入到下面
内容上
</view>
</view>
<view class="cu-capsule radius" style="margin-left: 15rpx;" catchtap="chooseDirection"
@ -196,7 +202,7 @@
<text class="{{selDirection== '2' ? 'cuIcon-radiobox':'cuIcon-round'}}"></text>
</view>
<view class="cu-tag {{selDirection=='2' ? 'line-yellowlight2':'line-black'}}">
插入到上面
内容下
</view>
</view>
</view>
@ -204,12 +210,13 @@
<view class="dir-parent-box">
<view class="title">类型:</view>
<view class="choose-box">
<block wx:for="{{fieldList}}" wx:for-index="idx" wx:key="idx">
<view catchtap="chooseFieldType" data-type="{{idx}}" class="item">
<block wx:for="{{fieldList}}" wx:for-index="idx" wx:key="idx" wx:for-item="it">
<view catchtap="chooseFieldType" data-type="{{it.type}}" data-idx="{{idx}}"
class="item">
<text
class="{{curFieldType == idx ? 'bg-yellow-light cuIcon-roundcheck' : 'text-gray2 cuIcon-round'}}"></text>
<text class="{{curFieldType == idx ? 'bg-yellow-light' : 'text-gray2'}}"
style="margin-left: 6rpx;">{{item.type}}</text>
class="{{curFieldTypeIndex == idx ? 'bg-yellow-light cuIcon-roundcheck' : 'text-gray2 cuIcon-round'}}"></text>
<text class="{{curFieldTypeIndex == idx ? 'bg-yellow-light' : 'text-gray2'}}"
style="margin-left: 6rpx;">{{it.type}}</text>
</view>
</block>
</view>

View File

@ -230,7 +230,7 @@ van-action-sheet .noline:active {
.sel-border {
border: 1rpx solid #E6B980;
border-radius: 10rpx;
padding-bottom: 15rpx;
padding: 15rpx;
}
/* 语音弹框 */

View File

@ -285,8 +285,18 @@ Page({
//构建主页显示数据
buildMainData() {
var _self = this
var ids = ''
_self.data.dataList.forEach(it => {
it.list.forEach(item => {
ids += item.uid + ','
// 初始化评论 点赞 收藏状态
item.collectCount = 0
item.collectStatus = false
item.commentCount = 0
item.dispatchCount = 0
item.likeCount = 0
item.likeStatus = false
item.scansCount = 0
item.list.forEach(iem => {
switch (iem.dataType) {
case '2': //图片
@ -397,6 +407,48 @@ Page({
curIndex: 0,
dataList: _self.data.dataList
})
_self.getColumnContentHandle(ids)
},
//获取栏目内容点赞 收藏 评论
getColumnContentHandle(ids) {
var _self = this
wx.showLoading({
title: '加载中...',
})
app.http.get(app.urls.getColumnContentHandle.format({
projectId: 'column',
businessIds: ids
}), {
header: {
token: app.globalData.token
}
})
.then(res => {
wx.hideLoading({})
res.data.forEach(it => {
console.log(it)
_self.data.dataList.forEach(item => {
item.list.forEach(iem => {
if (iem.uid == it.businessId) {
iem.collectCount = it.collectCount
iem.collectStatus = it.collectStatus
iem.commentCount = it.commentCount
iem.dispatchCount = it.dispatchCount
iem.likeCount = it.likeCount
iem.likeStatus = it.likeStatus
iem.scansCount = it.scansCount
}
})
})
})
_self.setData({
curIndex: 0,
dataList: _self.data.dataList
})
})
.catch(err => {
})
},
//显示更多栏目数据
showMore(e) {
@ -1179,16 +1231,84 @@ Page({
},
//显示评论
showComment(e) {
this.setData({
isShowComment: true
//需要跳详情
var cId = e.currentTarget.dataset.cid
var uId = e.currentTarget.dataset.uid
wx.navigateTo({
url: '/packagecard/moments/momentsdetail/momentsdetail?uId=' + uId + '&cId=' + cId,
})
},
//点赞
doLike(e) {
var _self = this
var item = e.currentTarget.dataset.item
var idx = e.currentTarget.dataset.idx //内容索引
var index = e.currentTarget.dataset.index //栏目索引
var favor = item.likeStatus
var msg = ''
if (favor) {
msg = '取消中...'
} else {
msg = '保存中...'
}
wx.showLoading({
title: msg,
})
app.http.post(app.urls.doSaveLike, {
header: {
token: app.globalData.token
},
data: {
businessId: item.uid,
projectId: 'column'
}
})
.then(res => {
wx.hideLoading({})
_self.data.dataList[index].list[idx].likeStatus = !item.likeStatus
if (item.likeStatus) {
--_self.data.dataList[index].list[idx].likeCount
} else {
++_self.data.dataList[index].list[idx].likeCount
}
_self.setData({
dataList: _self.data.dataList
})
})
.catch(err => {})
},
//收藏
doCollect(e) {
var _self = this
var item = e.currentTarget.dataset.item
var idx = e.currentTarget.dataset.idx //内容索引
var index = e.currentTarget.dataset.index //栏目索引
var favor = item.collectStatus
var msg = ''
if (favor) {
msg = '取消收藏...'
} else {
msg = '收藏中...'
}
wx.showLoading({
title: msg,
})
app.http.post(app.urls.doSaveCollect, {
header: {
token: app.globalData.token
},
data: {
businessId: item.uid,
projectId: 'column'
}
})
.then(res => {
wx.hideLoading({})
_self.data.dataList[index].list[idx].collectStatus = !item.collectStatus
_self.setData({
dataList: _self.data.dataList
})
})
.catch(err => {})
}
})

View File

@ -307,37 +307,40 @@
</view>
</view>
<!-- 评论 收藏 点赞 -->
<!-- collectSwitch: datas[_self.data.curIndex].configColumnCollect, //收藏开关
commentSwitch: datas[_self.data.curIndex].configColumnComment, //评论开关
shareSwitch: datas[_self.data.curIndex].configColumnDispatch, //转发开关
likeSwitch: datas[_self.data.curIndex].configColumnLike, //点赞开关 -->
<!-- <view class="func-box">
<view class="func-box">
<view class="line-gray-ssm">
</view>
<view class="func-items">
<button class="func-item" open-type="share" data-sharetype="2"
wx:if="{{item.shareSwitch != '1' && item.shareSwitch != '3'}}"
<!-- 转发 -->
<button class="func-item" open-type="share" data-sharetype="2" data-item="{{it}}" data-idx="{{idx}}"
data-index="{{index}}" wx:if="{{item.shareSwitch != '1' && item.shareSwitch != '3'}}"
style="font-size: 28rpx;font-weight: normal;text-align: center;background-color: #ffffff;width: 0rpx;margin: 0rpx;padding: 0rpx;border-radius: 0rpx;">
<image src="/images/share_count.png" mode="scaleToFill"></image>
<text class="cuIcon-share text-gray" style="font-size: 38rpx;"></text>
<text style="text-align: center;line-height:28rpx;">转发</text>
</button>
<!-- 收藏 -->
<view class="func-item" wx:if="{{item.collectSwitch != '1' && item.collectSwitch != '3'}}"
catchtap="doCollect">
<image src="/images/ic_collect_icon.png" mode="scaleToFill"></image>
data-item="{{it}}" data-idx="{{idx}}" data-index="{{index}}" catchtap="doCollect">
<text class="{{it.collectStatus ? 'cuIcon-favorfill line-yellowlight2': 'cuIcon-favor text-gray'}}"
style="font-size: 38rpx;"></text>
<text>收藏</text>
</view>
<!-- 评论 -->
<view class="func-item" wx:if="{{item.commentSwitch != '1' && item.commentSwitch != '3'}}"
catchtap="showComment">
<image src="/images/ic_comment_icon.png" mode="scaleToFill"></image>
<text>10</text>
catchtap="showComment" data-uid="{{it.uid}}" data-cid="{{item.cId}}">
<text class="cuIcon-comment text-gray" style="font-size: 38rpx;"></text>
<text style="font-size: 30rpx;">{{it.commentCount>1000 ? '1000+':it.commentCount}}</text>
</view>
<view class="func-item" wx:if="{{item.likeSwitch != '1' && item.likeSwitch != '3'}}"
catchtap="doLike">
<image src="/images/ic_unfavour.png" mode="scaleToFill"></image>
<text>12</text>
<!-- 点赞 -->
<view class="func-item" wx:if="{{item.likeSwitch != '1' && item.likeSwitch != '3'}}" catchtap="doLike"
data-item="{{it}}" data-idx="{{idx}}" data-index="{{index}}">
<text
class="{{it.likeStatus ? 'cuIcon-appreciatefill line-yellowlight2' :'cuIcon-appreciate text-gray'}}"
style="font-size: 38rpx;"></text>
<text style="font-size:30rpx;">{{it.likeCount>1000? '1000+':it.likeCount}}</text>
</view>
</view>
</view> -->
</view>
</view>
</view>
</view>
@ -438,6 +441,7 @@
</view>
</van-action-sheet>
<!-- 显示海报 -->
<van-popup show="{{ isShowPoster }}" bind:close="onClose"
custom-style="background-color:transparent;height:100%;width:100%;" round>
<view bindtap="onClose"

View File

@ -782,4 +782,5 @@
.func-item text {
margin-left: 10rpx;
text-align: center;
}

View File

@ -21,9 +21,9 @@
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": false,
"useApiHook": false,
"useApiHostProcess": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],

View File

@ -124,8 +124,9 @@ var apis = {
doOrderColumn: `app/configcolumnset/saveorder`, //保存栏目排序, post {configColumnId, configColumnOrder}
//评论 点赞 收藏
doSaveCollect: `app/contentcollect/save`, //保存取消收藏 businessId=xxx&projectId=poster
doSaveLike: `app/contentlike/save`, //保存取消点赞 ?businessId
doSaveLike: `app/contentlike/save`, //保存取消点赞 ?businessId=xx& projectId=xx
getPosterFavorList: `app/cardtemplate/mylistposter`, //获取我的海报收藏列表
getColumnContentHandle: `app/contentcomment/countlist/{projectId}/{businessIds}`, //获取栏目内容评论 点赞 收藏数量
//名片信息
getCardList: `app/cardtemplate/list`, //获取名片列表
getCardDetail: `app/cardtemplate/get/{cardTemplateId}`, //获取名片详情