帖子
帖子
用户
博客
课程
12下一页
返回列表 发新帖
显示全部楼层
1
帖子
0
勋章
13
Y币

[多端开发] apicloud 3 上传图片 闪退

[复制链接]
发表于 2021-8-25 18:04:20
app上传图片选择图片后 app停止运行 强制退出 ,请问是哪里的问题api.actionSheet({
                    title: '上传身份证',
                    cancelTitle: '取消',
                    buttons: ['拍照', '从手机相册选择']
                }, function (ret, err) {
                    if (ret) {
                        getPicture(ret.buttonIndex);
                    }
                });




function getPicture(sourceType) {
        if (sourceType == 1) { // 拍照
            api.getPicture({
                sourceType: 'camera',
                encodingType: 'jpg',
                mediaValue: 'pic',
                allowEdit: false,
                destinationType: 'url',
                quality: 90,
                saveToPhotoAlbum: true
            }, function (ret, err) {
                if (ret) {
                    alert(JSON.stringify(ret));
                } else {
                    alert(JSON.stringify(err));
                }
                api.showProgress({
                    style: 'default',
                    animationType: 'fade',
                    text: '图片上传中...',
                    modal: false
                });
                if (ret.data == "") {
                    api.hideProgress();
                } else {
                    // mcmupload(ret.data);
                }
            });
        } else if (sourceType == 2) { // 从相机中选择
            api.getPicture({
                sourceType: 'library',
                encodingType: 'jpg',
                mediaValue: 'pic',
                destinationType: 'url',
                quality: 100,
                targetWidth: 200,
                targetHeight: 200
            }, function (ret, err) {
                if (ret) {
                    alert(JSON.stringify(ret));
                } else {
                    alert(JSON.stringify(err));
                }
                api.showProgress({
                    style: 'default',
                    animationType: 'fade',
                    text: '图片上传中...',
                    modal: false
                })

                if (ret.data == "") {
                    api.hideProgress();
                } else {
                    // mcmupload(ret.data)
                }
            });
        } else {
            return;
        }
    }



微信截图_20210825180135.png
380
帖子
4
勋章
6
Y币
把alert 改成 api.alert   或console.log

avm 里不支持alert
1
帖子
0
勋章
13
Y币
你好,还是一样的问题 ,并且控制台没有输出信息 ,在选择图片后闪退
1
帖子
0
勋章
13
Y币
  1. api.getPicture({
  2.                                 sourceType: 'library',
  3.                                 encodingType: 'jpg',
  4.                                 mediaValue: 'pic',
  5.                                 destinationType: 'url',
  6.                                 quality: 100,
  7.                                 targetWidth: 200,
  8.                                 targetHeight: 200
  9.                         }, function (ret, err) {
  10.                                 if (ret) {
  11.                                         console.log(JSON.stringify(ret));
  12.                                 } else {
  13.                                         console.log(JSON.stringify(err));
  14.                                 }
  15.                                 api.showProgress({
  16.                                         style: 'default',
  17.                                         animationType: 'fade',
  18.                                         text: '图片上传中...',
  19.                                         modal: false
  20.                                 })
  21.                                 console.log(22222)
  22.                                 if (ret.data == "") {
  23.                                         api.hideProgress();
  24.                                 } else {
  25.                                        
  26.                                 }
  27.                         });
复制代码


这里api.getPicture 的回调方法没有触发
1
帖子
0
勋章
13
Y币
技术支持-F 发表于 2021-8-25 18:37
把alert 改成 api.alert   或console.log

avm 里不支持alert

改了还是不行,还有可能是什么问题,谢谢
380
帖子
4
勋章
6
Y币
在瘦了 发表于 2021-8-25 19:30
这里api.getPicture 的回调方法没有触发

改成api.alert , 肯定会触发的
1
帖子
0
勋章
13
Y币
技术支持-F 发表于 2021-8-25 22:03
改成api.alert , 肯定会触发的

改成这样会弹框,但是没有内容,包括api.alert(1111) 弹出的提示框都不显示内容
111111111.png
1
帖子
0
勋章
13
Y币
技术支持-F 发表于 2021-8-25 22:03
改成api.alert , 肯定会触发的

麻烦再看一下
380
帖子
4
勋章
6
Y币

相册能打开吗,能选择图片吗
1
帖子
0
勋章
13
Y币
技术支持-F 发表于 2021-8-26 10:35
相册能打开吗,能选择图片吗

可以打开相册,选择完图片后就会弹出alert 但是都是空的,没有显示内容
12下一页
您需要登录后才可以回帖 登录

本版积分规则