zoukankan      html  css  js  c++  java
  • APIcoud 手机二维码or条码 生成与扫描模块

    刚接触APIcoud 的时候觉得很多模块真的好难,初次接触二维码的时候觉得,生成二维码真的很费劲呢,其实不然,是真的很难,但是APIcoud 已经封装好生成和扫描二维码的模块,

    我们只需要调用就可以愉快的使用二维码了。

    官方文档里面的使用方法里面,难免有些不易懂,本文教你如何愉快的开发二维码模块。

    废话不多说!上代码

    <!DOCTYPE html>
    <html>

    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>端API</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <style>
    .empty {
    text-align: center;
    padding: 120px 0;
    }

    button {
    background-color: #4682B4;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 6px; //圆角设置
    }

    body {
    text-align: center;
    margin-top: 10%
    }
    </style>
    </head>

    <body>
    <div class="empty">端API</div>
    <button type="button" name="button" onclick="dan()">单击打开二维码扫描器</button>
    <button type="button" name="button" onclick="add()">生成参数二维码</button>
    </body>

    </html>
    <!DOCTYPE html>
    <script type="text/javascript">
    var FNScanner=null;//全局变量
    apiready = function() {
    FNScanner = api.require('FNScanner'); //使用二维码模块
    api.addEventListener({name: 'resume'}, function(ret, err) {FNScanner.onResume();
    // alert('应用回到前台');
    //通知当前本模块app进入回到前台。此时模块会进行一些资源的恢复操作,防止照相机回来之后黑屏
    });
    api.addEventListener({ name: 'pause'}, function(ret, err) {FNScanner.onPause();
    // alert('应用进入后台');
    //通知当前本模块app进入后台。此时模块会进行一些资源的暂停存储操作,防止照相机回来之后黑屏
    });
    };
    function dan() {
    open(); //打开系统二维码扫描模块
    }
    function open() {
    FNScanner.open({
    sound: 'widget://image/MP3/5383.wav',
    //扫描后二维码声音
    autorotation: true , //是否自动旋转
    // saveToAlbum:true, //是否把扫描的二维码保存到相册
    hintText: '请对准二维码', //底部提示文字 默认值:'对准条形码/二维码,即可自动扫描'
    }, function(ret, err) {
    if (ret) {
    if (ret.eventType == "success") {
    var i = JSON.stringify(ret.content);
    alert(i)
    }
    } else {
    alert(JSON.stringify(err));
    }
    });
    }
    //生成二维码
    function add() {
    FNScanner.encodeImg({
    // //取值范围
    // bar_image(生成条形码图片)
    // qr_image(生成二维码图片)
    type: 'bar_image',
    content: 12, //所要生成的二维码/条形码字符串,当 type 为 bar_image 时,该值只能为数字字符串
    saveToAlbum: true, //(可选项)扫描的二维码/条形码图片是否自动保存到相册
    }, function(ret, err) {
    if (ret) {
    if (ret.status) {
    alert("生成成功、地址为:" + JSON.stringify(ret.albumPath))
    }
    } else {
    alert(JSON.stringify(err))
    }

    })
    }
    </script>

    <html>

  • 相关阅读:
    Java高级之类结构的认识
    14.8.9 Clustered and Secondary Indexes
    14.8.4 Moving or Copying InnoDB Tables to Another Machine 移动或者拷贝 InnoDB 表到另外机器
    14.8.3 Physical Row Structure of InnoDB Tables InnoDB 表的物理行结构
    14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用
    14.8.1 Creating InnoDB Tables 创建InnoDB 表
    14.7.4 InnoDB File-Per-Table Tablespaces
    14.7.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量和大小
    14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小
    14.6.11 Configuring Optimizer Statistics for InnoDB 配置优化统计信息用于InnoDB
  • 原文地址:https://www.cnblogs.com/wangshaod/p/9964149.html
Copyright © 2011-2022 走看看