|
|
@@ -120,17 +120,19 @@ Page({
|
|
|
title: '上传图片'
|
|
|
})
|
|
|
const arr = []
|
|
|
- if (value.poster.length !== 0) {
|
|
|
+ if (value.poster.length !== 0 && value.poster[0].substr(0, 8) !== 'cloud://') {
|
|
|
arr.push(wx.cloud.uploadFile({
|
|
|
cloudPath: `messagePoster/${util.randomString(16)}.jpg`,
|
|
|
filePath: value.poster[0]
|
|
|
}))
|
|
|
}
|
|
|
for (let i = 0; i < value.photo.length; i++) {
|
|
|
- arr.push(wx.cloud.uploadFile({
|
|
|
- cloudPath: `messagePhoto/${util.randomString(16)}.jpg`,
|
|
|
- filePath: value.photo[i]
|
|
|
- }))
|
|
|
+ if (value.photo[i].substr(0, 8) !== 'cloud://') {
|
|
|
+ arr.push(wx.cloud.uploadFile({
|
|
|
+ cloudPath: `messagePhoto/${util.randomString(16)}.jpg`,
|
|
|
+ filePath: value.photo[i]
|
|
|
+ }))
|
|
|
+ }
|
|
|
}
|
|
|
Promise.all(arr).then(res => {
|
|
|
wx.hideLoading()
|
|
|
@@ -138,17 +140,30 @@ Page({
|
|
|
title: '正在发布'
|
|
|
})
|
|
|
value.pub_id = this.data.publisherId
|
|
|
- if (value.poster.length !== 0) {
|
|
|
+ if (value.poster.length !== 0 && value.poster[0].substr(0, 8) !== 'cloud://') {
|
|
|
value.poster[0] = res[0].fileID
|
|
|
res.splice(0, 1)
|
|
|
}
|
|
|
for (let i = 0; i < value.photo.length; i++) {
|
|
|
- value.photo[i] = res[i].fileID
|
|
|
+ if (value.photo[i].substr(0, 8) !== 'cloud://') {
|
|
|
+ value.photo[i] = res[0].fileID
|
|
|
+ res.splice(0, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.data.messageId) {
|
|
|
+ return wx.cloud.callFunction({
|
|
|
+ name: 'updateMessage',
|
|
|
+ data: {
|
|
|
+ msg_id: this.data.messageId,
|
|
|
+ ...util.msgToDb(value)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ return wx.cloud.callFunction({
|
|
|
+ name: 'createMessage',
|
|
|
+ data: util.msgToDb(value)
|
|
|
+ })
|
|
|
}
|
|
|
- return wx.cloud.callFunction({
|
|
|
- name: 'createMessage',
|
|
|
- data: util.msgToDb(value)
|
|
|
- })
|
|
|
}).then(res => {
|
|
|
wx.hideLoading()
|
|
|
if (res.result.status !== 'OK') {
|