用户
 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,登录网站

回帖奖励 1 浮云 回复本帖可获得 1 浮云奖励! 每人限 1 次

1

主题

1

帖子

25

积分

攻城狮

Rank: 2

积分
25
2018-12-4 11:36:04 w祝翔宇43 攻城狮 楼主 085
            我这样写的,怎么不行呢?
uploadImages: function (e) {
var that = this;
return new Promise(function (resolve, reject) {
var cloudPathp = [];
imgeList.forEach((item, i) => {
cloudPathp.push(that.data.count + '_' + i + imgeList[i].match(/.[^.]+?$/)[0])
})
imgeList.forEach((item, i) => {
var cloudPath = cloudPathp[i];
var filePath = imgeList[i];
wx.cloud.uploadFile({
cloudPath,
filePath,
success: res => {
wx.showLoading(),
console.log('[上传文件] 成功:', cloudPath, res)
fileIDD.push(res.fileID)
fileList[i] = res.fileID;
app.globalData.cloudPath = cloudPath
app.globalData.imagePath = filePath
console.log('指定地点1:', fileIDD)
},
fail: e => {
console.error('[上传文件] 失败:', e)
wx.showToast({
icon: 'none',
title: '上传失败',
})
},
complete: () => {
wx.hideLoading()}
})
})
});
},
publishTopic: function (e) {
var that = this;
return new Promise(function (resolve, reject) {
var data = {
image: fileList,
content: that.data.text,
xqmc: that.data.objectArray1[that.data.brandindex1].brand,
leix: that.data.objectArray[that.data.brandindex].brand,
phone: e.detail.value.phone,
comment: [],
userId: wx.getStorageSync('userId'),
username: wx.getStorageSync('username'),
avatar: wx.getStorageSync('avatar'),
id: Number(that.data.count) + 1,
shareNum: 0,
commentNum: 0,
validStatus: 0,
validTime: 0
}
console.log('dataimage:', data.image.length)
console.log('publishTopic:', resolve)
if (data.content) {
db.collection('funnys').add({
data: data,
success: res => {
wx.showToast({
title: '发布成功',
})
setTimeout(() => {  wx.switchTab({    url: '../index/index',  })}, 1000)},
fail: e => {
wx.showToast({
title: '发布错误',
})
console.log(e)
}
})
} else {
wx.showToast({
title: '请填写文字',
icon: 'none'
})
}
});
},
formSubmit: function (e) {
var that = this;
that.uploadImages().then(that.publishTopic(e));
},
        

发新帖
您需要登录后才可以回帖 登录 | 立即注册