diff --git a/class/main.wxss b/class/main.wxss
index fe1e00d..d66b08d 100644
--- a/class/main.wxss
+++ b/class/main.wxss
@@ -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 {
diff --git a/pages/mine/index/index.js b/pages/mine/index/index.js
index 195a46d..d14dc06 100644
--- a/pages/mine/index/index.js
+++ b/pages/mine/index/index.js
@@ -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': //其他小程序
diff --git a/pages/moments/edit/momentedit.js b/pages/moments/edit/momentedit.js
index 726c83e..bea334b 100644
--- a/pages/moments/edit/momentedit.js
+++ b/pages/moments/edit/momentedit.js
@@ -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
}
})
\ No newline at end of file
diff --git a/pages/moments/edit/momentedit.wxml b/pages/moments/edit/momentedit.wxml
index 42d2a3c..0a577e7 100644
--- a/pages/moments/edit/momentedit.wxml
+++ b/pages/moments/edit/momentedit.wxml
@@ -1,240 +1,203 @@
- 内容修改
+ {{title}}
-
-
-
-
-
-
- 文本内容
-
-
-
-
-
- {{txt}}
-
-
+
+
+
+
+
+
+
+ {{item.comment}}
+
+
+
+
+
+
+
+ {{item.comment}}
+
+
+
+
+
-
-
-
- 用一段话,向名片访客介绍自己吧
-
-
-
- 点击添加
-
-
-
-
-
-
- 文本域内容
-
-
-
-
-
- {{txt}}
-
-
+
+
+
+
+ {{item.comment}}
+
+
+ {{item.valueList.length}}/{{item.maxCount}}
-
-
-
-
- 用一段话,向名片访客介绍自己吧
-
-
- 点击添加
-
-
-
-
-
-
- 图片内容
-
-
-
- {{'数量'+'('+photoList.length+'/'+ currentItem.count+')'}}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
- 用一段话,向名片访客介绍自己吧
-
-
- 点击添加
-
-
-
-
-
-
-
- 语音介绍
-
-
-
-
-
-
-
-
- {{audio.curDurationStr}}
-
- {{audio.totalDurationStr}}
-
-
-
-
-
+
+
+
+
+ {{item.comment}}
+
+
+ {{item.valueList.length}}/{{item.maxCount}}
+
+
+
+
+
+
+
+
+
+ {{audio.curDurationStr}}
+
+ {{audio.totalDurationStr}}
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+ 语音,可以给名片访客留下更深的印象
+
+
+ 点击添加
-
-
-
-
- 语音,可以给名片访客留下更深的印象
-
-
- 点击添加
-
-
-
-
-
-
- 视频内容
-
-
-
- {{'数量'+'('+videoList.length+'/'+ currentItem.count+')'}}
-
-
-
-
-
-
-
+
+
+
+
+ {{item.comment}}
+
+
+ {{item.valueList.length}}/{{item.maxCount}}
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
- 用一段话,向名片访客介绍自己吧
-
-
- 点击添加
-
-
-
-
-
-
-
- 链接
-
-
-
-
-
- {{txt}}
-
-
-
+
+
+
+ {{item.comment}}
+
-
-
-
- 用一段话,向名片访客介绍自己吧
-
-
-
- 点击添加
-
-
-
-
-
-
- 定位
-
-
-
-
-
-
- {{m.name}}-{{m.address}}
-
-
-
-
+
+
+
+
+ {{item.comment}}
-
-
+
+
+
+
+
+
+ {{m.name}}-{{m.address}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 在地图上选取一个地点
+
+
+ 点击添加
+
-
-
-
- 在地图上选取一个地点
-
-
-
- 点击添加
+
+
+
+
+
{
- 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
})
}
})
\ No newline at end of file
diff --git a/pages/moments/list/momentslist.wxml b/pages/moments/list/momentslist.wxml
index e12a3a5..0a46fbe 100644
--- a/pages/moments/list/momentslist.wxml
+++ b/pages/moments/list/momentslist.wxml
@@ -1,109 +1,125 @@
- 内容列表
+ {{title}}
-
-
-
- 发表时间:2021年12月12日 12:12:12
-
-
-
-
-
-
- {{item.text}}
-
- 查看更多
-
-
-
- 收起
-
+
+
+
+
+ 发表时间:{{item.gmtCreate}}
+
-
-
-
-
-
-
+
+
+
+
+
+ {{child.comment}}
+
+
+
+
+
+ {{child.value}}
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{audio.curDurationStr}}
+
+ {{audio.totalDurationStr}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{child.comment}}
+
+
+
+
+
+ {{child.value}}
+
+
-
-
-
-
-
-
-
- {{audio.curDurationStr}}
-
- {{audio.totalDurationStr}}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{link.url}}
-
-
- 打开
-
-
-
-
-
-
-
-
- {{m.name}}-{{m.address}}
-
-
-
-
-
-
-
-
+
+
+
{
+ 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
}
})
\ No newline at end of file
diff --git a/pages/moments/publish/momentpublishline.wxml b/pages/moments/publish/momentpublishline.wxml
index 0e7cdaa..4dc9a40 100644
--- a/pages/moments/publish/momentpublishline.wxml
+++ b/pages/moments/publish/momentpublishline.wxml
@@ -1,8 +1,8 @@
- 内容发布
+ {{title}}
-
+
@@ -182,7 +182,7 @@
在地图上选取一个地点
- 点击添加
diff --git a/utils/api.js b/utils/api.js
index 4c7a070..2814c55 100644
--- a/utils/api.js
+++ b/utils/api.js
@@ -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 = {