增加功能

This commit is contained in:
duxp 2023-09-20 13:47:58 +08:00
parent 2cacf47305
commit b556f340e9
3 changed files with 65 additions and 13 deletions

View File

@ -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,6 +287,9 @@ Page({
duration:1500
});
setTimeout(function () {
if(_this.data.isRadio){
wx.navigateBack();
}else{
_this.setData({
"searchForm.target":'',
"searchForm.targetId":'',
@ -256,6 +299,8 @@ Page({
detailData:null,
fileList:[]
})
_this.loadTargetData({type:_this.data.searchForm.type});
}
},1500)
}else{
wx.showToast({

View File

@ -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">

View File

@ -52,5 +52,5 @@
"ignore": [],
"include": []
},
"appid": "wx34ec155189941298"
"appid": "wxe692498cf5fe6b82"
}