uni-app功能分享

压缩图片
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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('压缩图片失败,请稍候再试');
        }
    );
}

压缩视频

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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('压缩视频失败,请稍候再试');
        }
    );
}

滚动到页面底部

 

1
2
3
4
5
6
7
8
9
10
scrolltoBottom() {
    this.$nextTick(() => {
        this.timer = setTimeout(() => {
            uni.pageScrollTo({
                scrollTop: 9999999,
                duration: 10
            });
        }, 200);
    });
}

 

posted @   Lotos  阅读(53)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示