美文网首页
网易云盾

网易云盾

作者: ismyshellyiqi | 来源:发表于2018-08-21 18:23 被阅读0次
  1. 用于 用户的登录注册的 活动验证
    IE7+、Chrome、Firefox、Safari、Opera、主流手机浏览器、iOS 及 Android上的内嵌Webview

  2. web 使用

    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
       <meta  charset="UTF-8">
       <meta  name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
       <meta  http-equiv="X-UA-Compatible" content="ie=edge">
      <title>验证码示例-popup模式</title>
    </head>
    <body>
    <button id="j-popup">点击弹出验证码</button>
    <div id="captcha"></div>
    <script  charset="UTF-8" type="text/javascript" src="http://cstaticdun.126.net/load.min.js"></script>
    <script>
      var captchaIns;
      initNECaptcha({
        element: '#captcha',
        captchaId: '从易盾申请的captchaId',
        mode: 'popup',
        width: '320px'
      }, onReady: function (instance) {
         // 验证码一切准备就绪,此时可正常使用验证码的相关功能
      },
      onVerify: function (err, data) {
          // 验证成功回调
          if(data){
            sendSmsCode(data.validate);
          }else{
            console.log('没有验证成功')
          }
          
      },function (instance) {
        // 初始化成功后得到验证实例instance,可以调用实例的方法
        captchaIns = instance
      }, function (err) {
        // 初始化失败后触发该函数,err对象描述当前错误信息
      })
    
      // 监听button的点击事件,弹出验证码
      document.getElementById('j-popup').addEventListener('click', function () {
        captchaIns && captchaIns.popUp()
      })
    </script>
    </body>
    </html>

相关文章

网友评论

      本文标题:网易云盾

      本文链接:https://www.haomeiwen.com/subject/vmijiftx.html