zoukankan      html  css  js  c++  java
  • 调用手机相册和照相机

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title></title>
    </head>
    <style type="text/css">
    .space{
    100px;
    height: 100px;
    background: aqua;
    }
    #image-list{
    110px;
    height: 110px;
    background: antiquewhite;
    }
    </style>
    <body>
    <div class="space" onclick="showActionSheet()">

    </div>
    </body>
    <script type="text/javascript">
    function showActionSheet(){
    var bts = [{
    title:"拍照"
    },{
    title:'从相册选择'
    }];
    plus.nativeUI.actionSheet(
    {
    cancel:'取消1',
    buttons:bts
    // buttons:[{title:'拍照'},{title:'从相册选择q'}]
    },
    function(e){
    if(e.index == 1){
    getImage();
    }else if(e.index == 2){
    galleryImgs();
    }
    })
    }
    //相机
    function getImage(){
    var cmr = plus.camera.getCamera();
    cmr.captureImage(function(p){
    plus.io.resolveLocalFileSystemURL(p,function(entry){
    createItem(entry);
    // compressImage(entry.toLocalURL(),entry.name);
    },function(e){
    plus.nativeUI.toast("错误"+e.message);
    });
    },function(e){
    filter:'image'
    })
    }
    //相册
    function galleryImgs(){
    plus.gallery.pick(function(e){
    var name = e.substr(e.lastIndexOf('/')+1);
    compressImage(e,name);
    },function(e){
    filter:'image'
    })
    }


    </script>
    </html>

  • 相关阅读:
    Dialog对话框
    Intent的七大属性
    Activity启动模式
    Android知识体系
    Activity生命周期
    Intent实现页面跳转和传值
    Android超链接
    上传文件
    XMLSAX解析
    XmlPull
  • 原文地址:https://www.cnblogs.com/impossible1994727/p/6657336.html
Copyright © 2011-2022 走看看