Pino丶
Pino丶
  • 发布:2018-05-30 15:35
  • 更新:2018-05-30 15:35
  • 阅读:2466

名片全能王识别名片

分类:HBuilder

1.名片全能王开发网址https://dev.camcard.com/developers/status

  1. 要申请一个账号,自己完善资料后,申请apikey,申请一般要审核两三天吧,我当时是三天。申请成功会邮箱通知,看下图
    下载附件下来,uploadurl改成自己的邮箱和apikey即可测试

    
    <!doctype html>  
    <html>  
    
    <head>  
        <meta charset="UTF-8">  
        <title></title>  
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
        <link href="../css/mui.min.css" rel="stylesheet" />  
    </head>  
    
    <body>  
        <ul class="mui-table-view">  
                    <li class="mui-table-view-cell">  
                        <a class="camera" onclick="scanCard()">Take a picture </a>  
                    </li>  
                    <li class="mui-table-view-cell">  
                        <a class="picture" onclick="galleryImg()">Choose from your phone album</a>  
                    </li>  
        </ul>  
        <script src="../js/mui.min.js"></script>  
        <script type="text/javascript">  
            mui.init()    
            var uploadurl="http://bcr2.intsig.net/BCRService/BCR_VCF2?PIN=**&json=1&user=6@qq.com&pass=&lang=2&size=";  
            // 扫描名片--拍照                           
            function scanCard() {  
                var cmr = plus.camera.getCamera();  
                var res = cmr.supportedImageResolutions[0];  
                var fmt = cmr.supportedImageFormats[0];  
                cmr.captureImage(function(path) {  
                        plus.io.resolveLocalFileSystemURL(path, function(entry) {  
                            var localUrl = entry.toLocalURL();  
                            //压缩照片  
                            plus.zip.compressImage({  
                                src: localUrl,  
                                dst: localUrl,  
                                overwrite: true, //覆盖你拍照的图片  
                                format: "jpg", //对方只接受JPG  
                                quality: 70, //对方建议质量  
                                width: "1024",  
                                height: "auto"  
                            }, function(e) {                                  
                                uploadCardImg(e.target, e.size)                                                                                                           
                            }, function(req) {  
                                mui.toast('压缩失败~')  
                            })  
    
                        })  
    
                    },  
                    function(err) {  
                        console.error("拍照失败:" + err.message);  
                    }, {  
                        index: 1,  
                    });  
            }  
            // 扫描名片--选择相册     
            function galleryImg() {  
                plus.gallery.pick(function(path) {  
                    plus.io.resolveLocalFileSystemURL(path, function(entry) {  
                        var localUrl = entry.toLocalURL();  
                        //压缩照片  
                        plus.zip.compressImage({  
                            src: localUrl,  
                            dst: localUrl,  
                            overwrite: true, //覆盖你拍照的图片  
                            format: "jpg", //对方只接受JPG  
                            quality: 70, //对方建议质量  
                            width: "1024",  
                            height: "auto"  
                        }, function(e) {  
                            uploadCardImg(e.target, e.size)                                                                       
                        }, function(req) {  
                            mui.toast('压缩失败~')  
                        })  
    
                    })  
                }, function(e) {  
                    //outSet("取消选择图片");  
                }, {  
                    filter: "image"  
                })  
            }  
            // 扫描名片--上传图片到指定的api接口  
            function uploadCardImg(fileUrl, ImgSize) {  
                  //上传照片对象  
                var uploadimg = plus.uploader.createUpload(uploadurl + ImgSize, {  
                    method: "POST"  
                }, function(t, status) {                      
                    // 上传完成  
                    if (status == 200) {  
                        //alert(t.responseText);  
                        console.log(t.responseText)  
                    } else {  
    
                    }                   
                });  
                uploadimg.addFile(fileUrl, {  
                    key: "imgcark"  
                });  
                uploadimg.start();  
            }  
        </script>  
    </body>  

</html>

1 关注 分享
DCloud_heavensoft

要回复文章请先登录注册

回梦無痕

回梦無痕

百度也有这些接口,只是百度的有免费额度,超出了要收费。
2018-05-30 17:11