增加功能
This commit is contained in:
parent
2cacf47305
commit
b556f340e9
|
@ -129,10 +129,9 @@ Page({
|
|||
callback(false);
|
||||
}
|
||||
},
|
||||
//上传数据
|
||||
//上传文件数据
|
||||
handleUploadFile(e){
|
||||
const { file } = e.detail;
|
||||
console.log(file,'file');
|
||||
let _fileList = this.data.fileList;
|
||||
_fileList.push({
|
||||
name:file.name,
|
||||
|
@ -144,6 +143,47 @@ Page({
|
|||
})
|
||||
},
|
||||
|
||||
//上传图片数据
|
||||
handleUploadImg(){
|
||||
let _this = this;
|
||||
wx.chooseMedia({
|
||||
count:3,
|
||||
mediaType:['image','video'],
|
||||
sourceType:['album', 'camera'],
|
||||
maxDuration:60, //视频拍摄时长,3s-60s
|
||||
success(res){
|
||||
let _isUpload = false;
|
||||
res.tempFiles.forEach(item => {
|
||||
if(item.size > 10485760){
|
||||
_isUpload = true;
|
||||
}
|
||||
});
|
||||
if(_isUpload){
|
||||
wx.showToast({
|
||||
title:'图片或视频不能大于10MB!',
|
||||
icon:'none',
|
||||
duration:1500
|
||||
})
|
||||
return false;
|
||||
}
|
||||
let _filesArr = res.tempFiles;
|
||||
let _fileList = _this.data.fileList;
|
||||
_filesArr.forEach(item => {
|
||||
let _lastNum = item.tempFilePath.lastIndexOf('/')+1;
|
||||
let _name =item.tempFilePath.substr(_lastNum,item.tempFilePath.length);
|
||||
_fileList.push({
|
||||
name:_name,
|
||||
url:item.tempFilePath,
|
||||
index:_fileList.length
|
||||
})
|
||||
})
|
||||
_this.setData({
|
||||
fileList:_fileList
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//预览文件
|
||||
handlePreView(e){
|
||||
let _url = e.currentTarget.dataset.url;
|
||||
|
@ -247,15 +287,20 @@ Page({
|
|||
duration:1500
|
||||
});
|
||||
setTimeout(function () {
|
||||
_this.setData({
|
||||
"searchForm.target":'',
|
||||
"searchForm.targetId":'',
|
||||
targetOpt:[],
|
||||
mainActiveIndex:0,
|
||||
activeId:null,
|
||||
detailData:null,
|
||||
fileList:[]
|
||||
})
|
||||
if(_this.data.isRadio){
|
||||
wx.navigateBack();
|
||||
}else{
|
||||
_this.setData({
|
||||
"searchForm.target":'',
|
||||
"searchForm.targetId":'',
|
||||
targetOpt:[],
|
||||
mainActiveIndex:0,
|
||||
activeId:null,
|
||||
detailData:null,
|
||||
fileList:[]
|
||||
})
|
||||
_this.loadTargetData({type:_this.data.searchForm.type});
|
||||
}
|
||||
},1500)
|
||||
}else{
|
||||
wx.showToast({
|
||||
|
|
|
@ -41,8 +41,15 @@
|
|||
bind:before-read="handleBeforeUpload"
|
||||
bind:after-read="handleUploadFile"
|
||||
>
|
||||
<van-button icon="plus" size="small" type="info">上传附件</van-button>
|
||||
<van-button icon="orders-o" size="small" type="info">上传附件</van-button>
|
||||
</van-uploader>
|
||||
<van-button
|
||||
icon="photo-o"
|
||||
size="small"
|
||||
type="info"
|
||||
style="margin-left:10px"
|
||||
bindtap="handleUploadImg"
|
||||
>上传图片</van-button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="file_list">
|
||||
|
|
|
@ -52,5 +52,5 @@
|
|||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"appid": "wx34ec155189941298"
|
||||
"appid": "wxe692498cf5fe6b82"
|
||||
}
|
Loading…
Reference in New Issue