栏目内容列表、删除、修改、提交接口对接

This commit is contained in:
itgaojian 2021-07-01 17:19:41 +08:00
parent cc9495386c
commit afa042ae16
9 changed files with 836 additions and 542 deletions

View File

@ -752,7 +752,7 @@ radio.white[checked] .wx-radio-input {
position: fixed;
width: 100%;
bottom: 0;
z-index: 1024;
z-index: 10;
}
.cu-btn.round[class*="line"]::after {

View File

@ -136,7 +136,7 @@ Page({
case '1': //跳转小程序内部
case '3': //链接
wx.navigateTo({
url: path + '?id=' + item.configColumnId + '&mode=' + item.configTableMode + '&type=' + item.configColumnType
url: path + '?id=' + item.configColumnId + '&mode=' + item.configTableMode + '&type=' + item.configColumnType+'&title='+item.configColumnName
})
break
case '2': //其他小程序

View File

@ -17,6 +17,10 @@ Page({
data: {
uploadCount: 0,
uploadVideoCount: 0,
currentIndex: 0,
columnId: '', //栏目Id
uId: '', //内容UID
fieldList: [], //栏目字段
textList: [], //文本添加内容
textareaList: [], //文本域添加内容
audioList: [], //音频添加内容
@ -40,44 +44,120 @@ Page({
speedStep: 5, //快进快退秒数
setInter: '', //定时器
currentItem: undefined,
items: [{
title: '标题', //标题
count: 3, //数量
type: 'TEXT', //类型
}, {
title: '标题', //标题
count: 9, //数量
type: 'TEXTAREA', //类型
}, {
title: '标题', //标题
count: 2, //数量
type: 'AUDIO', //类型
}, {
title: '标题', //标题
count: 3, //数量
type: 'VIDEO', //类型
}, {
title: '标题', //标题
count: 9, //数量
type: 'PHOTO', //类型
}, {
title: '标题', //标题
count: 9, //数量
type: 'LINK', //类型
}, {
title: '标题', //标题
count: 2, //数量
type: 'LOCATION', //类型
}],
isAuthAudio: false
isAuthAudio: false,
title:'栏目内容修改'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
columnId: options.id,
uId: options.uid,
title:options.title+'修改'
})
this.checkPermission()
this.getMomentContent()
},
getMomentContent() {
wx.showLoading({
title: '加载中...',
})
var _self = this
app.http.get(app.urls.getMomentsContent.format({
configColumnId: _self.data.columnId,
uid: _self.data.uId
}), {
header: {
token: app.globalData.token
}
})
.then(res => {
wx.hideLoading({})
//构建数据
_self.buildDetail(res.data)
})
.catch(err => {
wx.hideLoading({})
console.log(err)
})
},
//构建展示数据
buildDetail(data) {
var _self = this
data.list.forEach(it => {
switch (it.dataType) {
case '2': //图片
var items = it.value.split(',')
var tempList = []
items.forEach(item => {
var tempItem = {
id: item,
path: app.urls.baseImgUrl + item,
}
tempList.push(tempItem)
})
it.valueList = tempList
break
case '4': //视频
var items = it.value.split(',')
var tempList = []
items.forEach(item => {
var tempItem = {
id: item,
path: app.urls.baseImgUrl + item,
imgPath: '../../../images/ic_temp.png'
}
tempList.push(tempItem)
})
it.valueList = tempList
break
case '3': //音频
var items = it.value.split(',')
var tempList = []
items.forEach(item => {
var tempItem = {
id: item, //id
path: app.urls.baseImgUrl + item, //地址
isPlay: false, //是否播放中
duration: 100, //时长
curDuation: 0,
curDurationStr: '00:00',
totalDurationStr: '00:00'
}
tempList.push(tempItem)
})
it.valueList = tempList
break
case '6': //定位
var items = it.value.split('-')
var tempList = []
items.forEach(item => {
var latlng = item.split(',')
var tempItem = {
name: '',
address: '',
latitude: latlng[0],
longitude: latlng[1],
}
tempList.push(tempItem)
})
it.valueList = tempList
break
}
})
_self.setData({
fieldList: data.list
})
},
inputText(e) {
var index = e.currentTarget.dataset.index
var _self = this
_self.data.fieldList[index].value = e.detail.value
_self.setData({
fieldList: _self.data.fieldList
})
},
//申请录音权限
checkPermission() {
@ -122,10 +202,11 @@ Page({
},
onShow() {
if (chooseLocation.getLocation() != null) {
if (this.data.locationList.length < this.data.currentItem.count) {
this.data.locationList.push(chooseLocation.getLocation())
var item = this.data.fieldList[this.data.curMapIndex]
if (item.valueList.length < item.maxCount) {
this.data.fieldList[this.data.curMapIndex].valueList.push(chooseLocation.getLocation())
this.setData({
locationList: this.data.locationList
fieldList: this.data.fieldList
})
}
}
@ -150,17 +231,17 @@ Page({
//选择视频来源
chooseVideo(e) {
var _self = this
var countNum = _self.data.currentItem.count - _self.data.videoList.length
console.log(countNum)
var type = e.currentTarget.dataset.type
var item = e.currentTarget.dataset.item
var countNum = item.maxCount - item.valueList.length
var index = e.currentTarget.dataset.index
wx.chooseMedia({
count: Number.parseInt(countNum),
mediaType: ['video'],
sourceType: [type],
sourceType: ['camera', 'album'],
maxDuration: 60,
success: (res) => {
if (res.tempFiles.length > 0) {
_self.doUploadVideo(1, res.tempFiles, _self.data.uploadVideoCount)
_self.doUploadVideo(index, res.tempFiles, _self.data.uploadVideoCount)
}
},
fail: (err) => {
@ -173,8 +254,7 @@ Page({
})
},
//上传视频
doUploadVideo(type, paths, curIndex) {
console.log(paths)
doUploadVideo(index, paths, curIndex) {
wx.showLoading({
title: '上传中...',
})
@ -198,14 +278,14 @@ Page({
path: pathStr,
imgPath: paths[_self.data.uploadVideoCount].thumbTempFilePath
}
_self.data.videoList.push(item)
_self.data.fieldList[index].valueList.push(item)
_self.setData({
videoList: _self.data.videoList
fieldList: _self.data.fieldList
})
_self.setData({
uploadVideoCount: ++_self.data.uploadVideoCount
})
_self.doUploadVideo(1, paths, _self.data.uploadVideoCount)
_self.doUploadVideo(index, paths, _self.data.uploadVideoCount)
})
.catch(err => {
wx.hideLoading({})
@ -236,6 +316,8 @@ Page({
//删除视频
delVideo(e) {
let _self = this
var index = e.currentTarget.dataset.index
var idx = e.currentTarget.dataset.idx
wx.showModal({
title: '提示',
content: '确定要删除该视频吗?',
@ -243,9 +325,9 @@ Page({
confirmText: '确定',
success: res => {
if (res.confirm) {
_self.data.videoList.splice(e.currentTarget.dataset.index, 1)
_self.data.fieldList[index].valueList.splice(idx, 1)
_self.setData({
videoList: _self.data.videoList
fieldList: _self.data.fieldList
})
}
}
@ -410,13 +492,15 @@ Page({
//选择图片
choosePhoto(e) {
var _self = this
var countNum = _self.data.currentItem.count - _self.data.photoList.length
var type = e.currentTarget.dataset.type
var item = e.currentTarget.dataset.item
var index = e.currentTarget.dataset.index
var countNum = item.maxCount - item.valueList.length
wx.chooseImage({
count: Number.parseInt(countNum),
sourceType: [type],
sourceType: ['album', 'camera'],
success: (res) => {
_self.doUploadImg(1, res.tempFilePaths, _self.data.uploadCount)
_self.doUploadImg(index, res.tempFilePaths, _self.data.uploadCount)
},
fail: (err) => {
@ -432,9 +516,9 @@ Page({
confirmText: '确定',
success: res => {
if (res.confirm) {
this.data.photoList.splice(e.currentTarget.dataset.index, 1)
this.data.fieldList[e.currentTarget.dataset.itemindex].valueList.splice(e.currentTarget.dataset.index, 1)
this.setData({
photoList: this.data.photoList
fieldList: this.data.fieldList
})
}
}
@ -448,7 +532,7 @@ Page({
current: e.currentTarget.dataset.url
});
},
doUploadImg(type, paths, curIndex) {
doUploadImg(index, paths, curIndex) {
wx.showLoading({
title: '上传中...',
})
@ -471,21 +555,21 @@ Page({
id: id,
path: pathStr
}
_self.data.photoList.push(item)
_self.data.fieldList[index].valueList.push(item)
_self.setData({
photoList: _self.data.photoList
fieldList: _self.data.fieldList
})
_self.setData({
uploadCount: ++_self.data.uploadCount
})
_self.doUploadImg(1, paths, _self.data.uploadCount)
_self.doUploadImg(index, paths, _self.data.uploadCount)
})
.catch(err => {
wx.hideLoading({})
_self.setData({
uploadCount: ++_self.data.uploadCount
})
_self.doUploadImg(1, paths, _self.data.uploadCount)
_self.doUploadImg(index, paths, _self.data.uploadCount)
})
} else {
wx.hideLoading({})
@ -495,13 +579,10 @@ Page({
}
},
//地图选点
chooseLocation() {
this.data.items.forEach(it => {
if (it.type == 'LOCATION') {
this.setData({
currentItem: it
})
}
chooseLocation(e) {
var index = e.currentTarget.dataset.index
this.setData({
curMapIndex: index
})
wx.navigateTo({
url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
@ -652,7 +733,7 @@ Page({
})
.then(res => {
wx.hideLoading({})
if (_self.data.audioList.length < _self.data.currentItem.count) {
if (_self.data.fieldList[_self.data.currentIndex].valueList.length < _self.data.currentItem.maxCount) {
wx.hideLoading({})
//插入到集合中
var id = JSON.parse(res).data
@ -673,12 +754,11 @@ Page({
curDurationStr: '00:00',
totalDurationStr: totalStr
}
_self.data.audioList.push(item)
_self.data.fieldList[_self.data.currentIndex].valueList.push(item)
_self.setData({
audioList: _self.data.audioList
fieldList: _self.data.fieldList
})
console.log(_self.data.audioList)
if (_self.data.audioList.length == _self.data.currentItem.count) {
if (_self.data.fieldList[_self.data.currentIndex].valueList.length == _self.data.currentItem.maxCount) {
_self.setData({
isShowAudio: false
})
@ -691,9 +771,10 @@ Page({
//进行播放
var index = e.currentTarget.dataset.index
var idx = e.currentTarget.dataset.idx
var item = e.currentTarget.dataset.item
var _self = this
_self.data.audioList.forEach(it => {
_self.data.fieldList[index].valueList.forEach(it => {
if (it.isPlay) {
innerAudioContext.stop()
}
@ -706,15 +787,15 @@ Page({
//找到该文件
innerAudioContext = wx.createInnerAudioContext()
// 播放音频文件
innerAudioContext.src = _self.data.audioList[index].path
innerAudioContext.src = _self.data.fieldList[index].valueList[idx].path
innerAudioContext.autoplay = true
}
//先需要停止其他录音文件的播放
innerAudioContext.onPlay(() => {
_self.data.audioList[index].isPlay = true
_self.data.fieldList[index].valueList[idx].isPlay = true
_self.setData({
audioList: _self.data.audioList
fieldList: _self.data.fieldList
})
});
@ -727,27 +808,27 @@ Page({
}
})
innerAudioContext.onStop((res) => {
_self.data.audioList[index].isPlay = false
_self.data.audioList[index].curDuration = 0
_self.data.audioList[index].curDurationStr = '00:00'
_self.data.fieldList[index].valueList[idx].isPlay = false
_self.data.fieldList[index].valueList[idx].curDuration = 0
_self.data.fieldList[index].valueList[idx].curDurationStr = '00:00'
_self.setData({
audioList: _self.data.audioList,
fieldList: _self.data.fieldList,
})
})
innerAudioContext.onEnded((res) => {
_self.data.audioList[index].isPlay = false
_self.data.audioList[index].curDuration = 0
_self.data.audioList[index].curDurationStr = '00:00'
_self.data.fieldList[index].valueList[idx].isPlay = false
_self.data.fieldList[index].valueList[idx].curDuration = 0
_self.data.fieldList[index].valueList[idx].curDurationStr = '00:00'
_self.setData({
audioList: _self.data.audioList,
fieldList: _self.data.fieldList,
})
})
innerAudioContext.onError((res) => {
_self.data.audioList[index].isPlay = false
_self.data.audioList[index].curDuration = 0
_self.data.audioList[index].curDurationStr = '00:00'
_self.data.fieldList[index].valueList[idx].isPlay = false
_self.data.fieldList[index].valueList[idx].curDuration = 0
_self.data.fieldList[index].valueList[idx].curDurationStr = '00:00'
_self.setData({
audioList: _self.data.audioList,
fieldList: _self.data.fieldList,
})
})
innerAudioContext.onSeeking(() => {
@ -761,8 +842,8 @@ Page({
})
innerAudioContext.onTimeUpdate(() => {
if (innerAudioContext.duration != Infinity) {
_self.data.audioList[index].curDuration = parseInt(innerAudioContext.currentTime)
_self.data.audioList[index].duration = parseInt(innerAudioContext.duration)
_self.data.fieldList[index].valueList[idx].curDuration = parseInt(innerAudioContext.currentTime)
_self.data.fieldList[index].valueList[idx].duration = parseInt(innerAudioContext.duration)
console.log(innerAudioContext.duration)
var curM = parseInt(innerAudioContext.currentTime / 60) //分钟
var curS = parseInt(innerAudioContext.currentTime % 60) //秒
@ -772,10 +853,10 @@ Page({
var curSStr = curS > 9 ? curS : '0' + curS
var totalMStr = tM > 9 ? tM : '0' + tM
var totalSStr = +tS > 9 ? tS : '0' + tS
_self.data.audioList[index].curDurationStr = curMStr + ':' + curSStr
_self.data.audioList[index].totalDurationStr = totalMStr + ':' + totalSStr
_self.data.fieldList[index].valueList[idx].curDurationStr = curMStr + ':' + curSStr
_self.data.fieldList[index].valueList[idx].totalDurationStr = totalMStr + ':' + totalSStr
_self.setData({
audioList: _self.data.audioList
fieldList: _self.data.fieldList
})
}
})
@ -784,31 +865,32 @@ Page({
rewind(e) {
var _self = this
var index = e.currentTarget.dataset.index
var idx = e.currentTarget.dataset.idx
var item = e.currentTarget.dataset.item
if (item.isPlay) {
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration - _self.data.speedStep
innerAudioContext.seek(_self.data.audioList[index].curDuration)
_self.data.fieldList[index].valueList[idx].curDuration = _self.data.fieldList[index].valueList[idx].curDuration - _self.data.speedStep
innerAudioContext.seek(_self.data.fieldList[index].valueList[idx].curDuration)
_self.setData({
audioList: _self.data.audioList
fieldList: _self.data.fieldList
})
}
},
//快进5秒
speed(e) {
var _self = this
var index = e.currentTarget.dataset.index
var idx = e.currentTarget.dataset.idx
var item = e.currentTarget.dataset.item
var _self = this
if (item.isPlay) {
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration + _self.data.speedStep
innerAudioContext.seek(_self.data.audioList[index].curDuration)
_self.data.fieldList[index].valueList[idx].curDuration = _self.data.fieldList[index].valueList[idx].curDuration + _self.data.speedStep
innerAudioContext.seek(_self.data.fieldList[index].valueList[idx].curDuration)
_self.setData({
audioList: _self.data.audioList
fieldList: _self.data.fieldList
})
}
},
slider4change(e) {
var index = e.currentTarget.dataset.index
var item = e.currentTarget.dataset.item
if (item.isPlay) {
innerAudioContext.seek(e.detail.value)
@ -816,19 +898,105 @@ Page({
},
//显示弹框
showDialog(e) {
var type = e.currentTarget.dataset.type
var keyType = e.currentTarget.dataset.keytype
console.log(e)
this.data.items.forEach(it => {
if (it.type == type) {
this.setData({
currentItem: it
})
return
}
})
this.setData({
[keyType]: true
isShowAudio: true,
currentItem: e.currentTarget.dataset.item,
currentIndex: e.currentTarget.dataset.index
})
},
//提交保存
doPublish() {
var _self = this
if (_self.checkParams()) {
wx.showToast({
title: '保存中...',
})
var params = _self.buildParams()
app.http.post(app.urls.doSaveMoments.format({
configColumnId: _self.data.columnId
}), {
data: params,
header: {
token: app.globalData.token
}
})
.then(res => {
wx.hideLoading({})
let pages = getCurrentPages();
let beforePage = pages[pages.length - 2];
beforePage.setData({
isRefresh: true
})
wx.navigateBack({
delta: 1
})
})
.catch(err => {
wx.hideLoading({})
console.log(err)
})
}
},
//校验参数
checkParams() {
var _self = this
var isLegal = true
for (var i = 0; i < _self.data.fieldList.length; i++) {
var field = _self.data.fieldList[i]
if (field.must) {
if (field.dataType == '1' || field.dataType == '7') {
if (field.value.length <= 0) {
wx.showToast({
title: '请输入' + field.comment,
icon: 'none'
})
isLegal = false
break
}
} else {
if (field.valueList.length <= 0) {
wx.showToast({
title: '请上传' + field.comment,
icon: 'none'
})
isLegal = false
break
}
}
}
}
return isLegal
},
//构建提交参数
buildParams() {
var _self = this
var params = {
uid: _self.data.uId
}
for (var i = 0; i < _self.data.fieldList.length; i++) {
var field = _self.data.fieldList[i]
if (field.dataType == '1' || field.dataType == '7') {
if (field.value.length > 0) {
params[field.name] = field.value
}
} else {
if (field.valueList.length > 0) {
var ids = ""
if (field.dataType == '6') {
field.valueList.forEach(it => {
ids += it.latitude + ',' + it.longitude + '-'
})
} else {
field.valueList.forEach(it => {
ids += it.id + ','
})
}
ids = ids.substr(0, ids.length - 1)
params[field.name] = ids
}
}
}
return params
}
})

View File

@ -1,240 +1,203 @@
<cu-custom isBack="{{true}}">
<view slot="content">内容修改</view>
<view slot="content">{{title}}</view>
</cu-custom>
<!-- 内容 -->
<view wx:for="{{items}}" wx:key="index">
<!-- 文本 -->
<view class="flex flex-direction" wx:if="{{item.type=='TEXT'}}">
<view class="hint-title">
<image src="/images/title-bg.png" mode="scaleToFill"></image>
<text>文本内容</text>
</view>
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
<view wx:if="{{textList.length>0}}" class="flex flex-direction" style="width:100%;">
<!--输入的文本内容 -->
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{textList}}" wx:key="index"
wx:for-item="txt" style="width:100%;">
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
<view class="cu-tag bg-gray margin-left-xs" catchtap="delText" data-index="{{index}}">
<text class="cuIcon-close"></text>
<view wx:if="{{fieldList.length>0}}" class="flex flex-direction radius align-center">
<view class="flex flex-direction self-center" style="width:95%;margin-bottom:100rpx;">
<!-- 内容 1:文字,2:照片,3:音频,4:视频,5:链接,6:定位,7:文章 -->
<view wx:for="{{fieldList}}" wx:key="index">
<!-- 文本 -->
<view wx:if="{{item.dataType == '1'}}" class="margin-top-xs">
<view class="cu-form-group">
<view class="title margin-left-sm">{{item.comment}}</view>
<input placeholder="请输入内容" maxlength="{{item.maxLength}}" data-key="{{item.name}}"
data-value="{{item.value}}" value="{{item.value}}" bindinput="inputText"
data-index="{{index}}"></input>
</view>
</view>
<!-- 文本域 -->
<view wx:if="{{item.dataType == '7'}}" class=" margin-top-xs">
<view class="cu-bar bg-white margin-top-xs">
<view class="action">
<text>{{item.comment}}</text>
</view>
</view>
<view class="bg-white">
<view class="cu-form-group">
<textarea class="border-line padding-left-xs padding-right-xs margin-left-xs margin-right-xs"
maxlength="{{item.maxLength}}" data-key="{{item.name}}" data-value="{{item.value}}"
bindinput="inputText" value="{{item.value}}" data-index="{{index}}"
placeholder="请输入内容"></textarea>
</view>
</view>
</view>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
<text class="text-gray">
用一段话,向名片访客介绍自己吧
</text>
</view>
<view wx:if="{{textList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
style="width:60%;" bindtap="showDialog" data-type="TEXT" data-keyType="isShowText">点击添加</view>
</view>
</view>
<!-- 文本域 -->
<view class="flex flex-direction" wx:elif="{{item.type=='TEXTAREA'}}">
<view class="hint-title">
<image src="/images/title-bg.png" mode="scaleToFill"></image>
<text>文本域内容</text>
</view>
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
<view wx:if="{{textareaList.length>0}}" class="flex flex-direction" style="width:100%;">
<!--输入的文本内容 -->
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{textareaList}}" wx:key="index"
wx:for-item="txt" style="width:100%;">
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
<view class="cu-tag bg-gray margin-left-xs" catchtap="delDesc" data-index="{{index}}">
<text class="cuIcon-close"></text>
<!-- 图片 -->
<view wx:elif="{{item.dataType == '2'}}" class=" margin-top-xs">
<view class="cu-bar bg-white margin-top-xs">
<view class="action">
<text>{{item.comment}}</text>
</view>
<view class="action">
{{item.valueList.length}}/{{item.maxCount}}
</view>
</view>
</view>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
<text class="text-gray">
用一段话,向名片访客介绍自己吧
</text>
</view>
<view wx:if="{{textareaList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
style="width:60%;" bindtap="showDialog" data-type="TEXTAREA" data-keyType="isShowDesc">点击添加</view>
</view>
</view>
<!-- 图片 -->
<view class="flex flex-direction" wx:elif="{{item.type=='PHOTO'}}">
<view class="hint-title">
<image src="/images/title-bg.png" mode="scaleToFill"></image>
<text>图片内容</text>
</view>
<view class="flex flex-direction bg-white margin-sm radius padding-sm">
<view class="flex flex-direction self-end" style="width:100%;text-align:right;"
wx:if="{{photoList.length>0}}">
{{'数量'+'('+photoList.length+'/'+ currentItem.count+')'}}
</view>
<view wx:if="{{photoList.length>0}}" class="cu-form-group">
<view class="grid col-4 grid-square flex-sub">
<view class="bg-img" wx:for="{{photoList}}" wx:key="index" wx:for-item="photo" bindtap="viewImg"
data-url="{{photo.path}}">
<image src='{{photo.path}}' mode='scaleToFill'></image>
<view class="cu-tag bg-red" catchtap="delImg" data-index="{{index}}">
<text class="cuIcon-close"></text>
<view class="cu-form-group">
<view class="grid col-4 grid-square flex-sub">
<view class="bg-img" wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx"
bindtap="viewImg" wx:for-item="photo" data-url="{{photo.path}}">
<image src='{{photo.path}}' mode='aspectFill'></image>
<view class="cu-tag bg-red" catchtap="delImg" data-index="{{idx}}"
data-itemIndex="{{index}}">
<text class="cuIcon-close"></text>
</view>
</view>
<view class="solids" bindtap="choosePhoto" data-item="{{item}}" data-index="{{index}}"
wx:if="{{item.valueList.length<item.maxCount}}">
<text class="cuIcon-cameraadd"></text>
</view>
</view>
</view>
</view>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
</image>
<text class="text-gray">
用一段话,向名片访客介绍自己吧
</text>
</view>
<view wx:if="{{photoList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm selfcenter"
style="width:60%;" bindtap="showDialog" data-type="PHOTO" data-keyType="isShowPhoto">点击添加</view>
</view>
</view>
<!-- 音频 -->
<view class="flex flex-direction" wx:elif="{{item.type=='AUDIO'}}">
<view class="hint-title">
<image src="/images/title-bg.png" mode="scaleToFill"></image>
<text>语音介绍</text>
</view>
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
<view wx:if="{{audioList.length > 0}}" style="width:100%;">
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;" wx:for="{{audioList}}"
wx:key="index" wx:for-item="audio">
<image src="/images/ic_user_default.png" mode="scaleToFill" style="width:80rpx;height:80rpx;">
</image>
<view class="play-box">
<view class="flex justify-between align-center" style="width:80%;">
<text>{{audio.curDurationStr}}</text>
<slider class="flex-sub" bindchange="slider4change" min="{{0}}" max="{{audio.duration}}"
value="{{audio.curDuration}}" backgroundColor="#cacaca" activeColor="#1296db" data-index="{{index}}" data-item="{{audio}}"
block-size="14" block-color="#1296db" />
<text>{{audio.totalDurationStr}}</text>
</view>
<view class="flex justify-between" style="width:80%;">
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}" data-item="{{audio}}" bindtap="rewind"></image>
<image
src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-item="{{audio}}"></image>
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed" data-index="{{index}}" data-item="{{audio}}"></image>
<!-- 音频 -->
<view wx:elif="{{item.dataType == '3'}}" class=" margin-top-xs">
<view class="cu-bar bg-white margin-top-xs">
<view class="action">
<text>{{item.comment}}</text>
</view>
<view class="action">
{{item.valueList.length}}/{{item.maxCount}}
</view>
</view>
<view class="flex flex-direction align-center bg-white radius padding-sm">
<view wx:if="{{item.valueList.length > 0}}" style="width:100%;">
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;"
wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx" wx:for-item="audio">
<image src="/images/ic_user_default.png" mode="scaleToFill"
style="width:80rpx;height:80rpx;">
</image>
<view class="play-box">
<view class="flex justify-between align-center" style="width:80%;">
<text>{{audio.curDurationStr}}</text>
<slider class="flex-sub" bindchange="slider4change" min="{{0}}"
max="{{audio.duration}}" value="{{audio.curDuration}}" backgroundColor="#cacaca"
activeColor="#1296db" data-index="{{index}}" data-idx="{{idx}}"
data-item="{{audio}}" block-size="14" block-color="#1296db" />
<text>{{audio.totalDurationStr}}</text>
</view>
<view class="flex justify-between" style="width:80%;">
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}"
data-idx="{{idx}}" data-item="{{audio}}" bindtap="rewind"></image>
<image
src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-idx="{{idx}}"
data-item="{{audio}}">
</image>
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed"
data-index="{{index}}" data-idx="{{idx}}" data-item="{{audio}}"></image>
</view>
</view>
<view class="cu-tag bg-gray margin-left-xs" style="border-radius:50%;" catchtap="delAudio"
data-index="{{index}}" data-idx="{{idx}}">
<text class="cuIcon-close"></text>
</view>
</view>
</view>
<view class="cu-tag bg-gray margin-left-xs" style="border-radius:50%;" catchtap="delAudio"
data-index="{{index}}">
<text class="cuIcon-close"></text>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_voice.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
</image>
<text class="text-gray">
语音,可以给名片访客留下更深的印象
</text>
</view>
<view wx:if="{{item.valueList.length<item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
style="width:60%;" data-index="{{index}}" data-item="{{item}}" bindtap="showDialog">点击添加
</view>
</view>
</view>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_voice.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
<text class="text-gray">
语音,可以给名片访客留下更深的印象
</text>
</view>
<view wx:if="{{audioList.length<item.count}}" class="cu-btn bg-blue radius margin-top-sm" style="width:60%;"
data-type="AUDIO" data-keyType="isShowAudio" bindtap="showDialog">点击添加</view>
</view>
</view>
<!-- 视频 -->
<view class="flex flex-direction" wx:elif="{{item.type=='VIDEO'}}">
<view class="hint-title">
<image src="/images/title-bg.png" mode="scaleToFill"></image>
<text>视频内容</text>
</view>
<view class="flex flex-direction bg-white margin-sm radius padding-sm">
<view class="flex flex-direction self-end" style="width:100%;text-align:right;"
wx:if="{{videoList.length>0}}">
{{'数量'+'('+videoList.length+'/'+ currentItem.count+')'}}
</view>
<view wx:if="{{videoList.length>0}}" class="cu-form-group">
<view class="grid col-1 grid-square flex-sub">
<view class="bg-img" wx:for="{{videoList}}" wx:key="index" wx:for-item="video" bindtap="viewVideo"
style="height:280rpx;padding-bottom:0rpx;" data-url="{{video.path}}">
<image src='{{video.imgPath}}' mode='scaleToFill'></image>
<view class="cu-tag bg-red" catchtap="delVideo" data-index="{{index}}">
<text class="cuIcon-close"></text>
<!-- 视频 -->
<view wx:elif="{{item.dataType == '4'}}" class=" margin-top-xs">
<view class="cu-bar bg-white margin-top-xs">
<view class="action">
{{item.comment}}
</view>
<view class="action">
{{item.valueList.length}}/{{item.maxCount}}
</view>
</view>
<view class="cu-form-group">
<view class="grid col-4 grid-square flex-sub">
<view class="bg-img" wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx"
wx:for-item="video" bindtap="viewVideo" data-url="{{video.path}}">
<image src='{{video.imgPath}}' mode='aspectFill'></image>
<view class="cu-tag bg-red" catchtap="delVideo" data-index="{{index}}" data-idx="{{idx}}">
<text class="cuIcon-close"></text>
</view>
</view>
<view class="solids" bindtap="chooseVideo" wx:if="{{item.valueList.length<item.maxCount}}"
data-item="{{item}}" data-index="{{index}}">
<text class="cuIcon-cameraadd"></text>
</view>
</view>
</view>
</view>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
</image>
<text class="text-gray">
用一段话,向名片访客介绍自己吧
</text>
</view>
<view wx:if="{{videoList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm selfcenter"
style="width:60%;" bindtap="showDialog" data-type="VIDEO" data-keyType="isShowVideo">点击添加</view>
</view>
</view>
<!-- 连接 -->
<view class="flex flex-direction" wx:elif="{{item.type=='LINK'}}">
<view class="hint-title">
<image src="/images/title-bg.png" mode="scaleToFill"></image>
<text>链接</text>
</view>
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
<view wx:if="{{linkList.length>0}}" class="flex flex-direction" style="width:100%;">
<!--输入的文本内容 -->
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{linkList}}" wx:key="index"
wx:for-item="txt" style="width:100%;">
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
<view class="cu-tag bg-gray margin-left-xs" catchtap="delLink" data-index="{{index}}">
<text class="cuIcon-close"></text>
</view>
<!-- 链接 -->
<view wx:if="{{item.dataType == '5'}}" class=" margin-top-xs">
<view class="cu-form-group">
<view class="title margin-left-sm">{{item.comment}}</view>
<input placeholder="请输入内容" maxlength="{{item.maxLength}}" data-key="{{item.name}}"
data-value="{{item.value}}" bindinput="inputText" data-index="{{index}}"></input>
</view>
</view>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
<text class="text-gray">
用一段话,向名片访客介绍自己吧
</text>
</view>
<view wx:if="{{linkList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
style="width:60%;" bindtap="showDialog" data-type="LINK" data-keyType="isShowLink">点击添加</view>
</view>
</view>
<!-- 定位 -->
<view class="flex flex-direction" wx:elif="{{item.type=='LOCATION'}}">
<view class="hint-title">
<image src="/images/title-bg.png" mode="scaleToFill"></image>
<text>定位</text>
</view>
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
<view wx:if="{{locationList.length>0}}">
<view wx:for="{{locationList}}" wx:key="index" wx:for-item="m" style="width:100%;"
class="margin-top-xs">
<view class="flex justify-between">
<view>
{{m.name}}-{{m.address}}
</view>
<view class="cu-tag bg-gray margin-left-xs" catchtap="delMap" data-index="{{index}}">
<text class="cuIcon-close"></text>
</view>
<!-- 定位 -->
<view wx:elif="{{item.dataType=='6'}}" class=" margin-top-xs">
<view class="cu-bar bg-white">
<view class="action">
<text>{{item.comment}}</text>
</view>
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}" latitude="{{m.latitude}}"
scale="12" markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
<view class="action">
</view>
</view>
<view class="flex flex-direction align-center bg-white radius padding-sm">
<view wx:if="{{item.valueList.length>0}}">
<view wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx" wx:for-item="m"
style="width:100%;" class="margin-top-xs">
<view class="flex justify-between">
<view>
{{m.name}}-{{m.address}}
</view>
<view class="cu-tag bg-gray margin-left-xs" catchtap="delMap" data-index="{{index}}"
data-idx="{{idx}}">
<text class="cuIcon-close"></text>
</view>
</view>
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}"
latitude="{{m.latitude}}" scale="12"
markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
</view>
</view>
</view>
<view class="flex align-center bg-white flex-direction" wx:else>
<image src="/images/ic_empty_map.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
</image>
<text class="text-gray">
在地图上选取一个地点
</text>
</view>
<view wx:if="{{item.valueList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
data-index="{{index}}" style="width:60%;" bindtap="chooseLocation">点击添加</view>
</view>
</view>
<view class="flex align-center flex-direction" wx:else>
<image src="/images/ic_empty_map.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
<text class="text-gray">
在地图上选取一个地点
</text>
</view>
<view wx:if="{{locationList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
style="width:60%;" bindtap="chooseLocation">点击添加</view>
</view>
</view>
</view>
<view wx:else style="margin-top:200rpx;width:100%;">
<van-empty description="暂无数据" image="../../../images/ic_empty_data.png" />
</view>
<view class="padding-xs foot bg-white" wx:if="{{fieldList.length > 0}}">
<button class="cu-btn bg-blue" style="width:100%" bindtap="doPublish">保存</button>
</view>
<!-- 语音弹框 -->
<van-action-sheet show="{{ isShowAudio }}" title="语音介绍添加" bind:close="onHide" data-type="1"

View File

@ -13,104 +13,40 @@ Page({
waitFlag: false,
configMode: '2', //1单条数据 2多条数据
dataList: [],
trendsList: [{
auto: false,
seeMore: false,
text: '小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟',
}, {
auto: false,
seeMore: false,
text: '小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟',
}],
photoList: [{
path: 'https://t7.baidu.com/it/u=2604797219,1573897854&fm=193&f=GIF'
},
{
path: 'https://t7.baidu.com/it/u=2942499027,2479446682&fm=193&f=GIF'
},
{
path: 'https://t7.baidu.com/it/u=3165657288,4248157545&fm=193&f=GIF'
},
{
path: 'https://t7.baidu.com/it/u=3240224891,3518615655&fm=193&f=GIF'
},
{
path: 'https://t7.baidu.com/it/u=3240224891,3518615655&fm=193&f=GIF'
}
],
videoList: [{
imgPath: '../../../images/ic_temp.png',
path: 'https://media.w3.org/2010/05/sintel/trailer.mp4'
}],
locationList: [{
name: '满都海公园',
address: '乌兰察布西街南',
latitude: 40.816084,
longitude: 111.688774
}],
audioList: [{
id: '', //id
path: 'http://em.sycdn.kuwo.cn/0e15005756dcda91a39bec26dd824614/60d99781/resource/n3/30/66/2205407643.mp3', //地址
isPlay: false, //是否播放中
duration: 100, //时长
curDuation: 0,
curDurationStr: '00:00',
totalDurationStr: '00:56'
}, {
id: '', //id
path: 'http://em.sycdn.kuwo.cn/0e15005756dcda91a39bec26dd824614/60d99781/resource/n3/30/66/2205407643.mp3', //地址
isPlay: false, //是否播放中
duration: 100, //时长
curDuation: 0,
curDurationStr: '00:00',
totalDurationStr: '00:56'
}],
linkList: [{
url: 'https://www.baidu.com'
}, {
url: 'https://www.baidu.com'
}, {
url: 'https://www.baidu.com'
}],
count: 2,
isLoadMore: false
isLoadMore: false,
imgUrl: app.urls.baseImgUrl,
isRefresh: false,
title: '栏目内容'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const query = wx.createSelectorQuery()
let _self = this
console.log(options.type)
_self.setData({
columnId: options.id,
configMode: options.mode,
type: options.type
type: options.type,
title: options.title
})
query.selectAll('.textFour_box').boundingClientRect(res => {
var lineHeight = 26
for (var i = 0; i < res.length; i++) {
if (res[i].height / lineHeight > 3) {
_self.data.trendsList[i].auto = true
_self.data.trendsList[i].seeMore = true
}
}
_self.setData({
trendsList: _self.data.trendsList
})
}).exec()
query.select('#it').boundingClientRect(res => {
if (res.height > app.globalData.windowHeight) {
}
}).exec()
_self.getList()
},
onShow() {
if (this.data.isRefresh) {
wx.startPullDownRefresh({})
this.setData({
isRefresh: false
})
}
},
//获取栏目数据
getList() {
var _self = this
wx.showLoading({})
wx.showLoading({
title: '加载中...',
})
app.http.get(app.urls.getMomentsList.format({
configColumnId: _self.data.columnId
}), {
@ -120,12 +56,67 @@ Page({
})
.then(res => {
wx.hideLoading({})
// 构建数据
// 1:文字,2:照片,3:音频,4:视频,5:链接,6:定位,7:文章
res.data.forEach(it => {
it.list.forEach(item => {
switch (item.dataType) {
case '2':
case '4':
var items = item.value.split(',')
var tempList = []
for (var i = 0; i < items.length; i++) {
var urls = _self.data.imgUrl + items[i]
var tempItem = {
path: urls,
imgPath: '../../../images/ic_temp.png'
}
tempList.push(tempItem)
}
item.valueList = tempList
break
case '6': //定位
var items = item.value.split('-')
var tempList = []
for (var i = 0; i < items.length; i++) {
//截取经纬度
var latlng = items[i].split(',')
var tempItem = {
latitude: latlng[0], //纬度
longitude: latlng[1], //经度
}
tempList.push(tempItem)
}
item.valueList = tempList
break
case '3': //音频
var items = item.value.split(',')
var tempList = []
for (var i = 0; i < items.length; i++) {
var urls = _self.data.imgUrl + items[i]
var tempItem = {
path: urls, //地址
isPlay: false, //是否播放中
duration: 100, //时长
curDuation: 0,
curDurationStr: '00:00',
totalDurationStr: '00:00'
}
tempList.push(tempItem)
}
item.valueList = tempList
break
}
})
})
_self.setData({
dataList: res.data
})
wx.stopPullDownRefresh({})
})
.catch(err => {
console.log(err)
wx.stopPullDownRefresh({})
})
},
//展开更多
@ -172,39 +163,47 @@ Page({
})
},
onPullDownRefresh() {
wx.stopPullDownRefresh({})
this.getList()
},
onReachBottom() {
console.log('触底了')
},
play(e) {
//进行播放
var index = e.currentTarget.dataset.index
var item = e.currentTarget.dataset.item
var idx = e.currentTarget.dataset.idx
var ix = e.currentTarget.dataset.i
var _self = this
_self.data.audioList.forEach(it => {
if (it.isPlay) {
innerAudioContext.stop()
}
it.isPlay = false
it.curDuation = 0
it.curDuationStr = '00:00'
_self.data.dataList.forEach(it => {
it.list.forEach(item => {
if (item.valueList) {
item.valueList.forEach(ii => {
if (ii.isPlay) {
innerAudioContext.stop()
}
ii.isPlay = false
ii.curDuation = 0
ii.curDuationStr = '00:00'
})
}
})
})
if (!item.isPlay) {
// innerAudioContext.stop()
//找到该文件
innerAudioContext = wx.createInnerAudioContext()
// 播放音频文件
innerAudioContext.src = _self.data.audioList[index].path
innerAudioContext.src = _self.data.dataList[index].list[idx].valueList[ix].path
innerAudioContext.autoplay = true
}
//先需要停止其他录音文件的播放
innerAudioContext.onPlay(() => {
_self.data.audioList[index].isPlay = true
_self.data.dataList[index].list[idx].valueList[ix].isPlay = true
_self.setData({
audioList: _self.data.audioList
dataList: _self.data.dataList
})
});
@ -217,27 +216,27 @@ Page({
}
})
innerAudioContext.onStop((res) => {
_self.data.audioList[index].isPlay = false
_self.data.audioList[index].curDuration = 0
_self.data.audioList[index].curDurationStr = '00:00'
_self.data.dataList[index].list[idx].valueList[ix].isPlay = false
_self.data.dataList[index].list[idx].valueList[ix].curDuration = 0
_self.data.dataList[index].list[idx].valueList[ix].curDurationStr = '00:00'
_self.setData({
audioList: _self.data.audioList,
dataList: _self.data.dataList,
})
})
innerAudioContext.onEnded((res) => {
_self.data.audioList[index].isPlay = false
_self.data.audioList[index].curDuration = 0
_self.data.audioList[index].curDurationStr = '00:00'
_self.data.dataList[index].list[idx].valueList[ix].isPlay = false
_self.data.dataList[index].list[idx].valueList[ix].curDuration = 0
_self.data.dataList[index].list[idx].valueList[ix].curDurationStr = '00:00'
_self.setData({
audioList: _self.data.audioList,
dataList: _self.data.dataList,
})
})
innerAudioContext.onError((res) => {
_self.data.audioList[index].isPlay = false
_self.data.audioList[index].curDuration = 0
_self.data.audioList[index].curDurationStr = '00:00'
_self.data.dataList[index].list[idx].valueList[ix].isPlay = false
_self.data.dataList[index].list[idx].valueList[ix].curDuration = 0
_self.data.dataList[index].list[idx].valueList[ix].curDurationStr = '00:00'
_self.setData({
audioList: _self.data.audioList,
dataList: _self.data.dataList,
})
})
innerAudioContext.onSeeking(() => {
@ -251,9 +250,8 @@ Page({
})
innerAudioContext.onTimeUpdate(() => {
if (innerAudioContext.duration != Infinity) {
_self.data.audioList[index].curDuration = parseInt(innerAudioContext.currentTime)
_self.data.audioList[index].duration = parseInt(innerAudioContext.duration)
console.log(innerAudioContext.duration)
_self.data.dataList[index].list[idx].valueList[ix].curDuration = parseInt(innerAudioContext.currentTime)
_self.data.dataList[index].list[idx].valueList[ix].duration = parseInt(innerAudioContext.duration)
var curM = parseInt(innerAudioContext.currentTime / 60) //分钟
var curS = parseInt(innerAudioContext.currentTime % 60) //秒
var tM = parseInt(innerAudioContext.duration / 60) //分钟
@ -262,10 +260,10 @@ Page({
var curSStr = curS > 9 ? curS : '0' + curS
var totalMStr = tM > 9 ? tM : '0' + tM
var totalSStr = +tS > 9 ? tS : '0' + tS
_self.data.audioList[index].curDurationStr = curMStr + ':' + curSStr
_self.data.audioList[index].totalDurationStr = totalMStr + ':' + totalSStr
_self.data.dataList[index].list[idx].valueList[ix].curDurationStr = curMStr + ':' + curSStr
_self.data.dataList[index].list[idx].valueList[ix].totalDurationStr = totalMStr + ':' + totalSStr
_self.setData({
audioList: _self.data.audioList
dataList: _self.data.dataList
})
}
})
@ -275,11 +273,13 @@ Page({
var _self = this
var index = e.currentTarget.dataset.index
var item = e.currentTarget.dataset.item
var idx = e.currentTarget.dataset.idx
var ix = e.currentTarget.dataset.i
if (item.isPlay) {
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration - _self.data.speedStep
innerAudioContext.seek(_self.data.audioList[index].curDuration)
_self.data.dataList[index].list[idx].valueList[ix].curDuration = _self.data.dataList[index].list[idx].valueList[ix].curDuration - _self.data.speedStep
innerAudioContext.seek(_self.data.dataList[index].list[idx].valueList[ix].curDuration)
_self.setData({
audioList: _self.data.audioList
dataList: _self.data.dataList
})
}
@ -289,11 +289,13 @@ Page({
var _self = this
var index = e.currentTarget.dataset.index
var item = e.currentTarget.dataset.item
var idx = e.currentTarget.dataset.idx
var ix = e.currentTarget.dataset.i
if (item.isPlay) {
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration + _self.data.speedStep
innerAudioContext.seek(_self.data.audioList[index].curDuration)
_self.data.dataList[index].list[idx].valueList[ix].curDuration = _self.data.dataList[index].list[idx].valueList[ix] + _self.data.speedStep
innerAudioContext.seek(_self.data.dataList[index].list[idx].valueList[ix].curDuration)
_self.setData({
audioList: _self.data.audioList
dataList: _self.data.dataList
})
}
},
@ -306,11 +308,59 @@ Page({
},
//删除
delItem(e) {
wx.showModal({
title: '提示',
content: '确定要删除该条数据吗?',
cancelText: '取消',
confirmText: '确定',
success: res => {
if (res.confirm) {
this.doDelMoment(e.currentTarget.dataset.index)
}
}
})
},
doDelMoment(index) {
var _self = this
wx.showLoading({
title: '删除中...',
})
var item = _self.data.dataList[index]
app.http.delete(app.urls.doDelMoment.format({
configColumnId: _self.data.columnId,
uid: item.uid
}), {
header: {
token: app.globalData.token
}
})
.then(res => {
wx.hideLoading({})
wx.showToast({
title: '删除成功',
icon: 'success'
})
this.data.dataList.splice(index, 1)
this.setData({
dataList: this.data.dataList
})
wx.startPullDownRefresh({})
})
.catch(err => {
console.log(err)
wx.hideLoading({})
})
},
doPublish() {
wx.navigateTo({
url: '../publish/momentpublishline?id=' + this.data.columnId,
url: '../publish/momentpublishline?id=' + this.data.columnId + '&title=' + this.data.title
})
},
editMoment(e) {
var _self = this
var item = _self.data.dataList[e.currentTarget.dataset.index]
wx.navigateTo({
url: '../edit/momentedit?id=' + _self.data.columnId + '&uid=' + item.uid + '&title=' + _self.data.title
})
}
})

View File

@ -1,109 +1,125 @@
<cu-custom isBack="{{true}}">
<view slot="content">内容列表</view>
<view slot="content">{{title}}</view>
</cu-custom>
<view id="it" class="flex flex-direction bg-white margin-sm radius padding-sm">
<view class="flex justify-between padding-xs align-center">
<view class="text-black text-df text-bold ">
发表时间:2021年12月12日 12:12:12
</view>
<image src="../../../images/ic_squareness_del.png" mode="scaleToFill" style="width:48rpx;height:48rpx;"
catchtap="delItem"></image>
</view>
<!-- 文本 -->
<view wx:for="{{trendsList}}" wx:key='index'>
<view class="box">
<view class="textFour_box {{item.seeMore?'three':''}}">{{item.text}}</view>
<view class="text_toggle_box" style="display:flex;align-items:center;" wx:if='{{item.seeMore}}'
data-index='{{index}}' catchtap='toggleHandler'>
<text class="text_toggle_text">查看更多</text>
<image class="toggle-icon" src="/images/ic_arrow_down.png"></image>
</view>
<view class="text_toggle_box" style="display:flex;align-items:center;"
wx:if='{{!item.seeMore && item.auto}}' data-index='{{index}}' catchtap='toggleContent'>
<text class="text_toggle_text">收起</text>
<image class="toggle-icon" src="/images/ic_arrow_up.png"></image>
<view wx:if="{{dataList.length>0}}">
<view id="it" class="flex flex-direction bg-white margin-sm radius padding-sm" wx:for="{{dataList}}" wx:key="index"
data-index="{{index}}" bindtap="editMoment">
<view class="flex justify-between padding-xs align-center">
<view class="text-black text-df text-bold ">
发表时间:{{item.gmtCreate}}
</view>
<image src="../../../images/ic_squareness_del.png" mode="scaleToFill" style="width:48rpx;height:48rpx;"
data-index="{{index}}" catchtap="delItem"></image>
</view>
</view>
<!-- 图片 -->
<view wx:if="{{photoList.length>0}}" class="cu-form-group margin-top-xs">
<view class="grid col-4 grid-square flex-sub">
<view class="bg-img" wx:for="{{photoList}}" wx:key="index" wx:for-item="photo" catchtap="viewImg"
data-url="{{photo.path}}">
<image src='{{photo.path}}' mode='scaleToFill'></image>
<view wx:for="{{item.list}}" wx:for-index="idx" wx:key="idx" wx:for-item="child">
<!-- 文本 -->
<view wx:if="{{child.dataType=='1'}}">
<view class="cu-bar bg-white">
<view class="action">
<text>{{child.comment}}</text>
</view>
</view>
<view class="bg-white">
<view class="cu-form-group">
<view id="content" class="padding-left-xs padding-right-xs margin-left-xs margin-right-xs"
style="line-height:40rpx;">
{{child.value}}
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 视频 -->
<view wx:if="{{videoList.length>0}}" class="cu-form-group">
<view class="grid col-{{count>3 ? count : 1}} grid-square flex-sub">
<view class="bg-img" wx:for="{{videoList}}" wx:key="index" wx:for-item="video" catchtap="viewVideo"
style="{{count > 3 ? '' :'height:280rpx;width:100%;padding-bottom:0px;'}}" data-url="{{video.path}}">
<image style="width:100%;height:100%;" src='{{video.imgPath}}' mode='scaleToFill'></image>
<view class="{{count > 3 ? 'play-box-arrow-pos':'play-box-arrow-flex'}}">
<image src="/images/ic_video_play.png" mode="scaleToFill"
style="{{count > 3 ? 'width:32px;height:32px':'height:64px;width:64px;'}}"></image>
<!-- 图片 -->
<view wx:if="{{child.dataType=='2'}}" class="cu-form-group margin-top-xs">
<view class="grid col-4 grid-square flex-sub">
<view class="bg-img" wx:for="{{child.valueList}}" wx:key="index" wx:for-item="photo"
catchtap="viewImg" data-url="{{photo.path}}">
<image src='{{photo.path}}' mode='scaleToFill'></image>
</view>
</view>
</view>
<!-- 视频 -->
<view wx:if="{{child.dataType=='4'}}" class="cu-form-group margin-top-sm" style="border:1rpx solid #eee;">
<view class="grid col-{{count>3 ? count : 1}} grid-square flex-sub">
<view class="bg-img" wx:for="{{child.valueList}}" wx:key="index" wx:for-item="video"
catchtap="viewVideo" style="{{count > 3 ? '' :'height:280rpx;width:100%;padding-bottom:0px;'}}"
data-url="{{video.path}}">
<image style="width:100%;height:100%;" src='{{video.imgPath}}' mode='scaleToFill'></image>
<view class="{{count > 3 ? 'play-box-arrow-pos':'play-box-arrow-flex'}}">
<image src="/images/ic_video_play.png" mode="scaleToFill"
style="{{count > 3 ? 'width:32px;height:32px':'height:64px;width:64px;'}}"></image>
</view>
</view>
</view>
</view>
<!-- 音频 -->
<view wx:if="{{child.dataType=='3'}}" style="width:100%;">
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;"
wx:for="{{child.valueList}}" wx:for-index="i" wx:key="i" wx:for-item="audio">
<image src="/images/ic_user_default.png" mode="scaleToFill" style="width:80rpx;height:80rpx;">
</image>
<view class="play-box">
<view class="flex justify-between align-center" style="width:80%;">
<text>{{audio.curDurationStr}}</text>
<slider class="flex-sub" bindchange="slider4change" min="{{0}}" max="{{audio.duration}}"
value="{{audio.curDuration}}" backgroundColor="#cacaca" activeColor="#1296db"
data-index="{{index}}" data-idx="{{idx}}" data-i="{{i}}" data-item="{{audio}}"
block-size="14" block-color="#1296db" />
<text>{{audio.totalDurationStr}}</text>
</view>
<view class="flex justify-between" style="width:80%;">
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}"
data-idx="{{idx}}" data-i="{{i}}" data-item="{{audio}}" bindtap="rewind"></image>
<image src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-i="{{i}}"
data-idx="{{idx}}" data-item="{{audio}}"></image>
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed"
data-index="{{index}}" data-idx="{{idx}}" data-i="{{i}}" data-item="{{audio}}"></image>
</view>
</view>
</view>
</view>
<!-- 地图定位 -->
<view wx:if="{{child.dataType=='6'}}">
<view wx:for="{{child.valueList}}" wx:key="index" wx:for-item="m" style="width:100%;"
class="margin-top-xs">
<view class="flex justify-between">
<view>
</view>
<view></view>
</view>
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}" latitude="{{m.latitude}}"
scale="12" enable-scroll="{{false}}" enable-zoom="{{false}}" enable-rotate="{{false}}"
enable-traffic="{{false}}"
markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
</view>
</view>
</view>
<!-- 文本域 -->
<view wx:if="{{child.dataType == '7'}}" class=" margin-top-xs">
<view class="cu-bar bg-white">
<view class="action">
<text>{{child.comment}}</text>
</view>
</view>
<view class="bg-white">
<view class="cu-form-group">
<view id="content" class="padding-left-xs padding-right-xs margin-left-xs margin-right-xs"
style="line-height:40rpx;">
{{child.value}}
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 音频 -->
<view wx:if="{{audioList.length > 0}}" style="width:100%;">
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;" wx:for="{{audioList}}"
wx:key="index" wx:for-item="audio">
<image src="/images/ic_user_default.png" mode="scaleToFill" style="width:80rpx;height:80rpx;">
</image>
<view class="play-box">
<view class="flex justify-between align-center" style="width:80%;">
<text>{{audio.curDurationStr}}</text>
<slider class="flex-sub" bindchange="slider4change" min="{{0}}" max="{{audio.duration}}"
value="{{audio.curDuration}}" backgroundColor="#cacaca" activeColor="#1296db"
data-index="{{index}}" data-item="{{audio}}" block-size="14" block-color="#1296db" />
<text>{{audio.totalDurationStr}}</text>
</view>
<view class="flex justify-between" style="width:80%;">
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}"
data-item="{{audio}}" bindtap="rewind"></image>
<image src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-item="{{audio}}"></image>
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed" data-index="{{index}}"
data-item="{{audio}}"></image>
</view>
</view>
</view>
</view>
<!-- 连接 -->
<view wx:if="{{linkList.length > 0}}" style="width:100%;">
<view class="flex align-center margin-top-xs" style="width:100%;" wx:for="{{linkList}}" wx:key="index"
wx:for-item="link">
<view class="flex-sub">
{{link.url}}
</view>
<view class="cu-btn bg-blue radius">
打开
</view>
</view>
</view>
<!-- 地图定位 -->
<view wx:for="{{locationList}}" wx:key="index" wx:for-item="m" style="width:100%;" class="margin-top-xs">
<view class="flex justify-between">
<view>
{{m.name}}-{{m.address}}
</view>
<view></view>
</view>
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}" latitude="{{m.latitude}}" scale="12"
enable-scroll="{{false}}" enable-zoom="{{false}}" enable-rotate="{{false}}" enable-traffic="{{false}}"
markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
</view>
</view>
</view>
<view wx:else style="margin-top:200rpx;width:100%;">
<van-empty description="暂无数据" image="../../../images/ic_empty_data.png" />
</view>
<view class="padding-xs foot bg-white" wx:if="{{configMode == '2' || dataList.length <= 0}}">
<button class="cu-btn bg-blue" style="width:100%" bindtap="doPublish">发布</button>
<button class="cu-btn bg-blue" style="width:100%" bindtap="doPublish">去发布</button>
</view>
<view

View File

@ -43,7 +43,8 @@ Page({
speedStep: 5, //快进快退秒数
setInter: '', //定时器
currentItem: undefined,
isAuthAudio: false
isAuthAudio: false,
title: '栏目内容发布'
},
/**
@ -51,7 +52,8 @@ Page({
*/
onLoad: function (options) {
this.setData({
columnId: options.id
columnId: options.id,
title: options.title + '发布'
})
this.checkPermission()
this.getFieldList()
@ -142,10 +144,11 @@ Page({
},
onShow() {
if (chooseLocation.getLocation() != null) {
if (this.data.locationList.length < this.data.currentItem.count) {
this.data.locationList.push(chooseLocation.getLocation())
var item = this.data.fieldList[this.data.curMapIndex]
if (item.valueList.length < item.maxCount) {
this.data.fieldList[this.data.curMapIndex].valueList.push(chooseLocation.getLocation())
this.setData({
locationList: this.data.locationList
fieldList: this.data.fieldList
})
}
}
@ -518,7 +521,7 @@ Page({
}
},
//地图选点
chooseLocation() {
chooseLocation(e) {
var index = e.currentTarget.dataset.index
this.setData({
curMapIndex: index
@ -697,7 +700,7 @@ Page({
_self.setData({
fieldList: _self.data.fieldList
})
if (_self.data.fieldList[_self.data.currentIndex].valueList == _self.data.currentItem.maxCount) {
if (_self.data.fieldList[_self.data.currentIndex].valueList.length == _self.data.currentItem.maxCount) {
_self.setData({
isShowAudio: false
})
@ -843,5 +846,97 @@ Page({
currentItem: e.currentTarget.dataset.item,
currentIndex: e.currentTarget.dataset.index
})
},
//提交保存
doPublish() {
var _self = this
if (_self.checkParams()) {
wx.showToast({
title: '保存中...',
})
var params = _self.buildParams()
app.http.post(app.urls.doSaveMoments.format({
configColumnId: _self.data.columnId
}), {
data: params,
header: {
token: app.globalData.token
}
})
.then(res => {
wx.hideLoading({})
let pages = getCurrentPages();
let beforePage = pages[pages.length - 2];
beforePage.setData({
isRefresh: true
})
wx.navigateBack({
delta: 1
})
})
.catch(err => {
wx.hideLoading({})
console.log(err)
})
}
},
//校验参数
checkParams() {
var _self = this
var isLegal = true
for (var i = 0; i < _self.data.fieldList.length; i++) {
var field = _self.data.fieldList[i]
if (field.must) {
if (field.dataType == '1' || field.dataType == '7') {
if (field.value.length <= 0) {
wx.showToast({
title: '请输入' + field.comment,
icon: 'none'
})
isLegal = false
break
}
} else {
if (field.valueList.length <= 0) {
wx.showToast({
title: '请上传' + field.comment,
icon: 'none'
})
isLegal = false
break
}
}
}
}
return isLegal
},
//构建提交参数
buildParams() {
var params = {}
var _self = this
for (var i = 0; i < _self.data.fieldList.length; i++) {
var field = _self.data.fieldList[i]
if (field.dataType == '1' || field.dataType == '7') {
if (field.value.length > 0) {
params[field.name] = field.value
}
} else {
if (field.valueList.length > 0) {
var ids = ""
if (field.dataType == '6') {
field.valueList.forEach(it => {
ids += it.latitude + ',' + it.longitude + '-'
})
} else {
field.valueList.forEach(it => {
ids += it.id + ','
})
}
ids = ids.substr(0, ids.length - 1)
params[field.name] = ids
}
}
}
return params
}
})

View File

@ -1,8 +1,8 @@
<cu-custom isBack="{{true}}">
<view slot="content">内容发布</view>
<view slot="content">{{title}}</view>
</cu-custom>
<view wx:if="{{fieldList.length>0}}" class="flex flex-direction radius align-center">
<view class="flex flex-direction self-center" style="width:95%;">
<view class="flex flex-direction self-center" style="width:95%;margin-bottom:100rpx;">
<!-- 内容 1:文字,2:照片,3:音频,4:视频,5:链接,6:定位,7:文章 -->
<view wx:for="{{fieldList}}" wx:key="index">
<!-- 文本 -->
@ -182,7 +182,7 @@
在地图上选取一个地点
</text>
</view>
<view wx:if="{{locationList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
<view wx:if="{{item.valueList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
data-index="{{index}}" style="width:60%;" bindtap="chooseLocation">点击添加</view>
</view>
</view>

View File

@ -52,6 +52,8 @@ var apis = {
getMomentsList: `app/configcolumndata/listrelease/{configColumnId}`, //获取栏目数据列表
doSaveMoments: `app/configcolumndata/saverelease/{configColumnId}`, //保存栏目数据
getMomentsField: `app/configcolumndata/listfieldrelease/{configColumnId}`, //获取栏目字段列表
doDelMoment: `app/configcolumndata/deleterelease/{configColumnId}/{uid}`, //删除栏目数据
getMomentsContent: `app/configcolumndata/getrelease/{configColumnId}/{uid}`, //获取栏目数据
}
module.exports = {