//上传视频
uploadVideo:function(){
let _this = this;
let list = [‘camera’, ‘album’];
wx.showActionSheet({
itemList: [‘拍摄视频’,’从相册选择视频’,’从视频库选择视频’],
success: function (res) {
if(res.tapIndex==0 || res.tapIndex==1){
wx.chooseVideo({
sourceType:[list[res.tapIndex]],
compressed:true,
maxDuration:app.globalData.isIos?60:180,
success:function(res){
_this.videoLink=null;
_this.setData({
videoUp:0
});
// 视频上传状态
_this.videoUpStatus = true;
const uploadTask = wx.uploadFile({
url: app.globalData.baseUrl+’?r=mpupfile’,
filePath: res.tempFilePath,
name: ‘video’,
header: {
‘token’: app.globalData.token,
‘content-type’: ‘multipart/form-data’
},
formData:{
“test”:”test”
},
success: function (res) {
console.log(res,’===’)
let dat = JSON.parse(res.data)
if(dat.code==1 && dat.data){
wx.showToast({
title: ‘上传成功’,
icon: ‘none’,
mask:true,
duration:2000
})
_this.setData({
videoLink:dat.data
})
}else if(dat.code==0){
wx.showToast({
title: dat.msg?dat.msg:’上传失败’,
icon: ‘none’,
mask:true,
duration:2000
})
}
},
fail: function (err) {
wx.showToast({
title: ‘网络出错’,
icon: ‘none’,
mask:true,
duration:2000
})
},
complete:function(){
_this.videoUpStatus = false;
}
})
uploadTask.onProgressUpdate((res) => {
_this.setData({
videoUp:res.progress
})
})
}
,fail:function(err){
console.log(‘选择没有用’)
}
})
}else{
}
}
,fail:function(err){
console.log(‘fail’,err)
}
})
},