uni-app功能分享
压缩图片
function compressImage(url, filename) { var name = 'file:///storage/emulated/0/Documents/weiliao/' + filename; plus.zip.compressImage( { src: url, //src: (String 类型 )压缩转换原始图片的路径 dst: name, //压缩转换目标图片的路径 quality: 60, //quality: (Number 类型 )压缩图片的质量.取值范围为1-100 overwrite: true //overwrite: (Boolean 类型 )覆盖生成新文件 }, function(e) { //压缩后 // openFile(e.target) uni.showLoading({ title: '发送中' }); sendPhoto(e.target); //发送 }, function(error) { console.log('压缩图片失败,请稍候再试'); } ); }
压缩视频
function compressVideo(url, filename) { // var name = 'file:///storage/emulated/0/Documents/weiliao/compress/' + filename; plus.zip.compressVideo( { src: url, //src: (String 类型 )压缩转换原始路径 // filename: name, //压缩后的路径 quality: 'medium' //压缩级别low medium high }, function(e) { //压缩后 // openFile(e.tempFilePath) uni.showLoading({ title: '发送中' }); sendVideo(e.tempFilePath); //发送 }, function(error) { console.log('压缩视频失败,请稍候再试'); } ); }
滚动到页面底部
scrolltoBottom() { this.$nextTick(() => { this.timer = setTimeout(() => { uni.pageScrollTo({ scrollTop: 9999999, duration: 10 }); }, 200); }); }