let that=this
let time=Date.parse(new Date())/1000
let releaseTime=new Date().toLocaleDateString()
console.log(that.data.userInfo)
// console.log(releaseTime)
// that.setData({
// releaseTime:releaseTime
// })
if(that.data.userInfo==null){
wx.showToast({
title: '请先登录!',
icon:'none'
})
}else{
wx.showLoading({
title: '上传中',
})
//console.log(that.data.src.length)
for(let i=0;i<that.data.src.length;i++){
wx.cloud.uploadFile({
cloudPath:'${releaseTime}/'+time+i, //上传到存储中的名字 为了使上传的图片不重复和成功 需要动态赋值
filePath:that.data.src[i], //图片的临时路径
}).then(res=>{
wx.hideLoading()
wx.showToast({
title: '上传成功',
})
console.log(res.fileID,i)
upbase[i]=res.fileID
}).catch(error=>{
console.log(error)
})
}
}
上传成功了,但是字符串,而不是时间日期的具体值,求大佬指教。
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
const formattedTime = `${year}-${month}-${day}-${hours}:${minutes}:${seconds}`;