uni.chooseVideo({
sourceType: ['camera', 'album'],
success: (res) => {
this.uploads.push(res.tempFilePath)
console.log("视频的res", res)
this.$emit('successVideo', res.tempFilePath)
},
fail: (err) => {
uni.showModal({
content: JSON.stringify(err)
});
}
});
// 发布
commit(data){
console.log("发布数据",data)
if(this.fbdata.summary==''){
uni.showToast({
title: '请输入发布内容',
icon: 'none',
duration: 500
});
return false
}
if( this.tempFilePath!=''){
uni.showLoading({
title: '视频正在上传',
icon: 'loading,
mask: true
});
console.log(baseApi+'/rest/common/oss/upload/video')
console.log(this.tempFilePath)
uni.uploadFile({
url: baseApi+'/rest/common/oss/upload/video', //仅为示例,非真实的接口地址
filePath: this.tempFilePath,
name: 'file',
formData:{
},
success: (res) => {
console.log("上传后的地址",res)
this.fbdata.videoUrl=JSON.parse(res.data).data.url
uni.hideLoading();
if(this.fbdata.videoUrl==""){
uni.showToast({
title: '视频上传失败',
duration: 500
});
return false
}else{
uni.showToast({
title: '视频上传完成',
duration: 500
});
}
douhuoedit(data).then(res=>{
console.log("保存成功",res)
if(res.data.message="请求成功"){
uni.showToast({
title: '发布成功',
duration: 500
});
// this.fbdata={}
this.fbdata.summary='',
this.fbdata.location='',
this.fbdata.title='',
this.fbdata.productId='',
this.fbdata.videoUrl='',
this.videoList=[]
// uni.navigateTo({
// url:'/pages/douhuo/index'
// })
}else{
uni.showToast({
title: res.data.message,
duration: 500
});
}
})
},
fail:(err)=>{
uni.hideLoading();
uni.showToast({
title: "上传失败",
duration: 500
});
console.log("上传失败",err)
}
});
}else{
uni.showToast({
title: '请选择要上传的视频',
duration: 500
});
return false
}
}
0 个回复