欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS制作圖形驗(yàn)證碼實(shí)現(xiàn)代碼

 更新時(shí)間:2020年10月19日 09:21:09   作者:qq_24147051  
這篇文章主要為大家詳細(xì)介紹了JS制作圖形驗(yàn)證碼實(shí)現(xiàn)代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

第一步我們來到要展示驗(yàn)證碼的頁面,當(dāng)我們按下營業(yè)執(zhí)照的時(shí)候讓其,彈出一個(gè)彈框,彈框的上面就是驗(yàn)證碼,如圖一所示:

(圖一)

彈框的樣式如圖二所示:

(圖二)

我們要對(duì)驗(yàn)證碼的值進(jìn)行校驗(yàn),判斷驗(yàn)證碼是否輸入正確,當(dāng)輸入不正確的時(shí)候,我們提示錯(cuò)誤信息,提示信息如圖三所示:

(圖三)

如果頁面了驗(yàn)證正確,這不會(huì)提示錯(cuò)誤信息并且調(diào)到我們的目標(biāo)頁面,如圖四所示:

(圖四)

路由層描述

 /**
  供貨商店鋪-店鋪簡介
  */
  //1-在路由層進(jìn)行設(shè)置,頁面跳轉(zhuǎn)到根目錄下/buyer/vshop/info.ejs頁面進(jìn)行跳轉(zhuǎn),然后在回調(diào)函數(shù)中進(jìn)行接口的調(diào)用
  router.get('/buyer/vshop/info', function(req, res, next) { 
  //2-調(diào)用接口獲取數(shù)據(jù) 
  async.parallel({ 
  verifycode :function(fn){
  //3-調(diào)用接口獲取本機(jī)的IP地址
   var args= {
   userIp: tools.getClientIp(req)
   };

   //4-調(diào)用接口verifyCodeHelper的createVcode方法獲取captcha與 csnonce的數(shù)據(jù),他們的值都是騰訊接口verifyCodeHelper返回的數(shù)據(jù)

   verifyCodeHelper.createVcode(args, function(err, result){
   if (err) {
    console.log(err);
   }
   else{
    fn(null, {
    captcha: result.data.queryUrl,
    csnonce: result.csnonce || 0
    })
   }
   });
  }
  },function(err, result){
  if (err) {
   res.end(err);
  }else{
   result.getDetail= res.shopInfo;
   var fxzStatus = res.fxzStatus || {};

  //5-進(jìn)行根目錄下buyer/vshop/describe頁面的渲染,傳遞相關(guān)參數(shù)到EJS頁面

   res.render("buyer/vshop/describe", { 
   title: srcBizType==1 ? result.getDetail.name : "店鋪簡介",
   pageName:"vshopInfo",
   captcha:result.verifycode.captcha,//驗(yàn)證碼
   isTencent: 1,
   csnonce:result.verifycode.csnonce
   });
  }
  });
 });

EJS層描述

 <%- include ../../header %>
 //1-獲取路由傳遞的 csnonce
 <script>
 APP.newLogin= {
  csnonce: '<%- csnonce %>',
 };
 <link href="/css/vshop/describe.css?v=<%= config.version %>" rel="stylesheet" />
 <style id="dynamic"></style>
 <div class="arrow_mask"></div>
 <div class="arrow">
 <div>
  <img src="/imgs/vshop/verification-code-back.png" class="verification-code-back" />
 </div>
 <ul class="arrow-mess"> <span class="sku-close" id="btn_sku_dialog_close"> </span>
  <li>請(qǐng)輸入下面的圖形驗(yàn)證碼</li>
  <li>
   <img id="J_BtnVerifyPicCodeTencent" src="" class="captcha" style="height:30px;margin:0 15px;" />
  </li>
  <li>
  <div class="btn_mes">
   <input class="btn_mes_text" type="text" maxlength="6">
  </div>
  </li>
 </ul>
 <div class="btn_mes2">
  <input type="button" class="license-submit" value="提交">
 </div>
 </div>
 <div data-role="container" class="body <%= pageName %>">
 <header data-role="header">
  <%- include ./widget_vshop %>
 </header>
 <section data-role="body" class="section-body">
  <div class="div-section div-section-info">
  <ul class="info1">
   <li class="gap"><div class="left">所在地</div><div class="right"><%- detail.address%></div></li>
   <li><div class="left">開店時(shí)間</div><div class="right"><%- detail.createTime%></div></li>
  </ul>
  <ul class="info2">
   <li class="gap"><div class="left">發(fā)貨速度</div><div class="right"><%- detail.score.express%></div></li>
   <li class="gap"><div class="left">服務(wù)態(tài)度</div><div class="right"><%- detail.score.service%></div></li>
   <li><div class="left">描述相符</div><div class="right"><%- detail.score.describe%></div></li>
  </ul>
  <ul class="info3">
   <%if(detail.shopTypeIndex==1||detail.shopTypeIndex==2||detail.shopTypeIndex==3){var bg = '/imgs/vshop/tip.png',color='#39dda5' }else{var bg = '/imgs/vshop/tip3.png',color='#59aaff'}%>
   <li><div class="left anotherC">認(rèn)證</div><div class="right textR"><span style="background: url(<%-bg%>) left 1px no-repeat;background-size: 14px 12px;"><i style="background: <%-color%>"><%- detail.shopType %></i></span></div></li>
  </ul>
  <ul class="info4">
   <li><a href="tel:<%- detail.phone%>" class="tel">服務(wù)電話</a></li>
   <li><a data-aid="<%- aid%>" class="webim">在線客服</a></li>
   <li class="business-license">
   <!--<a href="/buyer/vshop/license?aid=<%- aid%>">-->
   <a href="#">
    <span >營業(yè)執(zhí)照</span>
    <label>查看<span></span></label>
   </a>

   </li>
  </ul>
  </div>
  <%- include ./footer %>
  <div id="vue_hooker">
  <child-nav></child-nav>
  <%- include ../../widget_navBtns %>
  </div> 
 </section>
 </div>
 //2-獲取路由傳遞的captcha
 <script type="text/javascript" src="<%= captcha %>"></script>
 //3-引入相關(guān)JS文件
 <script>
 seajs.use("js_cmd/vshop/home-cmd");
 </script>
 <%- include ../../footer %>

JS層描述

 /**
 這是一個(gè)公用文件,vshop首頁&vshop全部商品共用
 */
 //1-引入頁面所需的各個(gè)模塊
 define(function (require, exports, module) {
 var $ = require("./top-suction-cmd"),
  myDialog = require("lib_cmd/myDialog-cmd"),
  main = require("js_cmd/main-cmd"),
  DataLoader = require("./tool-cmd"),
  fxzTool = require("./fxzTool-cmd"),
  Vue = require("lib_cmd/vue-cmd"),
  widget_navBtns = require("js_cmd/navBtns-cmd"),
  $eles = {},
  eles = {};

 //2-Vue實(shí)例化 
 var vm = new Vue({
  data: {},
  methods: {}
 });

 //3- 頁面初始化函數(shù)

 function initPage() {
  vm.$mount('#vue_hooker');
  window.scroll(0,0);
 }
 //4- 驗(yàn)證碼相關(guān)處理函數(shù)
 function license(){
  $('.info4 .business-license').click(function (ev) { //彈層
  $('.btn_mes_text').val("");
  $('.arrow_mask').show();
  $('.arrow').show();
  $('#nav_omit').remove();
  });
  $('#btn_sku_dialog_close').click(function(ev){//彈窗
  $('.arrow_mask').hide();
  $('.arrow').hide();
  $('.btn_mes_text').val("");
  });

  $('.btn_mes_text').focus(function(){ //輸入框獲得焦點(diǎn)
  $('.btn_mes_text').val("");
  if($('.verification-code').length!=0){
   $('.verification-code').remove();
  }
  });
  $('.license-submit').click(function(){
  APP.verifyPicCode();
  });

 }

 //5- 驗(yàn)證碼初始化函數(shù)() TSOCapObj是騰訊接口里面的方法

 function verify_initPage(){
  $('#J_BtnVerifyPicCodeTencent').on('click', function () {
  TSOCapObj.refresh();
  });
  //初始化,參數(shù)傳入顯示驗(yàn)證碼的元素imgid
  TSOCapObj.init("J_BtnVerifyPicCodeTencent");
  //刷新拉取驗(yàn)證碼圖片
  TSOCapObj.refresh();

  APP.verifyPicCode= function(fn) {
  //獲取用戶輸入
  var ans = $(".btn_mes_text").val();
  //驗(yàn)證答案,驗(yàn)證完成后會(huì)回調(diào)第二個(gè)參數(shù)傳入的函數(shù)
  TSOCapObj.verify(ans , function(ret_json){
   if (ret_json.errorCode!=0) {
   $(".btn_mes_text").val("");
   TSOCapObj.refresh();
   //tip("圖形驗(yàn)證碼輸入錯(cuò)誤!");
   if($('.verification-code').length==0){
    $('.btn_mes').eq(0).append(" <div class='verification-code'>請(qǐng)輸入正確的驗(yàn)證碼</div>");
   }
   $('.btn_mes_text').blur(function(){
    $('.btn_mes_text').text("");
   });
   } else {
   window.location="/buyer/vshop/license?aid=" + APP.aid;
   fn(ret_json.ticket);
   }
  });
  }
 }

  //6- 頁面初始化函數(shù)的執(zhí)行
 $(function () {
  initPage();
  license();
  verify_initPage();
 });

 });

CCS層描述

 @import url(common.css);

 .div-section-info .info4{padding: 0}
 .div-section-info .info4 li{
 padding: 11px 14px;
 line-height: 20px;
 border-bottom: 1px solid #e6e6e6;

 }
 .div-section-info .info4 li a{
 color: #333;

 display: block;
 }
 .div-section-info .info4 li a.tel{
 background: url(/imgs/vshop/callAndMsg.png) no-repeat; 
 background-size: 20px 60px;
  background-position: right 0;
 }
 .div-section-info .info4 li a.webim{
 background: url(/imgs/vshop/callAndMsg.png) no-repeat; 
 background-size: 20px 60px;
 background-position: right -30px;
 }
 .div-section-info .info4 li a label{ 
 display: block;
 float: right;
 }

 .div-section-info .info4 li a label span{ 
 display: block;
 width: 12px;
 height: 12px;
 border-right:1px solid #666;
 border-bottom:1px solid #666;
 -webkit-transform:rotate(-45deg);
 float: right;
 margin-top: 4px;

 }
 .arrow_mask {
 position: fixed;
 top: 0;
 left: 0;
 bottom: 0;
 right: 0;
 z-index: 101;
 display: none;
 background: black;
 opacity: 0.7;
 }
 .arrow{
 width: 250px;
 height: 226px;
 background-color: #FFFFFF;
 position: fixed;
 top: 50%;
 left: 50%;
 z-index: 102;
 -webkit-transform: translate(-50%, -50%);
 -moz-transform: translate(-50%, -50%);
 -ms-transform: translate(-50%, -50%);
 -o-transform: translate(-50%, -50%);
 transform: translate(-50%, -50%);
 border-radius: 10px;
 display: none;
 }
 .arrow-mess li:nth-of-type(1){
 text-align: center;
 margin-bottom: 8px;
 font-size: 14px;
 color: #333333;
 }
 .arrow-mess li:nth-of-type(2){
 text-align: center;
 margin-bottom: 10px;
 }
 .arrow-mess li:nth-of-type(3) input{
 width: 100%;
 height: 30px;
 border: 1px solid #979797;
 text-align: center;
 border-radius: 3px;
 font-family: PingFangSC-Regular;
 font-size: 16px;
 color: #333333;
 letter-spacing: 0px;
 }
 .btn_mes{
 margin-bottom: 15px;
 width: 100%;
 padding-left: 48px;
 padding-right: 48px;
 position: relative;
 }
 .btn_mes2{
 width: 100%;
 padding-left: 70px;
 padding-right: 70px;
 /* position: relative; */
 position: absolute;
 bottom: 0px;
 margin-bottom: 10px;
 }

 .license-submit{
 width: 100%;
 height: 44px;
 background: #FF534C;
 border: 1px solid #FF534C;
 font-size: 14px;
 border-radius: 4px;
 color: #FFFFFF;
 }

 .sku-close {
 background: url(/imgs/vshop/verification-code-del.png) no-repeat right;
 -webkit-background-size: 25px auto;
 display: inline-block;
 width: 26px;
 height: 26px;
 position: absolute;
 right: 0px;
 top: 0px;
 margin-right: -13px;
 margin-top: -13px;
 }
 .verification-code{
 z-index: 102;
 color: #FFAA00;
 position: absolute;
 font-size: 12px;
 top: 4px;
 }
 .verification-code-back{
 width: 100%;
 position: absolute;
 height: 46px;
 }
 .arrow div:nth-of-type(1){
 position: relative;
 }
 .arrow-mess{
 margin-top: 52px;
 }

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JavaScrip數(shù)組去重操作實(shí)例小結(jié)

    JavaScrip數(shù)組去重操作實(shí)例小結(jié)

    這篇文章主要介紹了JavaScrip數(shù)組去重操作,結(jié)合實(shí)例形式總結(jié)分析了javascript針對(duì)數(shù)組的遍歷、判斷、去重等相關(guān)操作技巧,需要的朋友可以參考下
    2019-06-06
  • 微信公眾號(hào)網(wǎng)頁授權(quán)登錄的超簡單實(shí)現(xiàn)步驟

    微信公眾號(hào)網(wǎng)頁授權(quán)登錄的超簡單實(shí)現(xiàn)步驟

    微信開放平臺(tái)為第三方移動(dòng)程序提供分享、傳播的接口,使用戶可將第三方程序的內(nèi)容發(fā)布給好友或分享至朋友圈,下面這篇文章主要給大家介紹了關(guān)于微信公眾號(hào)網(wǎng)頁授權(quán)登錄的超簡單實(shí)現(xiàn)方法,需要的朋友可以參考下
    2022-06-06
  • 使用json對(duì)象轉(zhuǎn)化為key,value的對(duì)象數(shù)組

    使用json對(duì)象轉(zhuǎn)化為key,value的對(duì)象數(shù)組

    這篇文章主要介紹了使用json對(duì)象轉(zhuǎn)化為key,value的對(duì)象數(shù)組方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • JS獲取字符對(duì)應(yīng)的ASCII碼實(shí)例

    JS獲取字符對(duì)應(yīng)的ASCII碼實(shí)例

    下面小編就為大家?guī)硪黄狫S獲取字符對(duì)應(yīng)的ASCII碼實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就想給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-09-09
  • 自己做的模擬模態(tài)對(duì)話框?qū)崿F(xiàn)代碼

    自己做的模擬模態(tài)對(duì)話框?qū)崿F(xiàn)代碼

    最近做完一個(gè)項(xiàng)目,發(fā)現(xiàn)瀏覽器兼容問題,模態(tài)對(duì)話框只有IE支持,但是IE9又不能支持帶框架的對(duì)話框,那個(gè)對(duì)話框的大小打死都設(shè)置不了,在網(wǎng)上查說因?yàn)楹枚喙δ鼙籌E9屏蔽了,于是自己做了一個(gè)模擬對(duì)話框的東西
    2012-05-05
  • JS 連鎖泡泡 v1.1

    JS 連鎖泡泡 v1.1

    前幾天在朋友的iPhone上面玩了一個(gè)連鎖泡泡游戲,頭腦發(fā)熱就想用js寫一個(gè)。
    2009-09-09
  • javascript溫習(xí)的一些筆記 基礎(chǔ)常用知識(shí)小結(jié)

    javascript溫習(xí)的一些筆記 基礎(chǔ)常用知識(shí)小結(jié)

    在電腦上找到多年前的javascript的一些小筆記,因?yàn)橐獙⒐P記本上面的文件整理一下, 不用的刪除掉, 所以將此篇筆記再發(fā)布一下,存檔到自己的博客吧, 電腦上的文件就刪除了
    2011-06-06
  • JavaScript實(shí)現(xiàn)獲取遠(yuǎn)程的html到當(dāng)前頁面中

    JavaScript實(shí)現(xiàn)獲取遠(yuǎn)程的html到當(dāng)前頁面中

    今天做個(gè)項(xiàng)目,需要在當(dāng)前的html頁面中引用一個(gè)遠(yuǎn)程的html頁面,百度了一下,發(fā)現(xiàn)一個(gè)非常好用的代碼,這里分享給大家,有相同需求的小伙伴可以來看看
    2017-03-03
  • javascript數(shù)組元素刪除方法delete和splice解析

    javascript數(shù)組元素刪除方法delete和splice解析

    這篇文章主要介紹了javascaipt數(shù)組元素刪除方法delete和splice解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12
  • 基于JavaScript實(shí)現(xiàn)粒子流動(dòng)效果

    基于JavaScript實(shí)現(xiàn)粒子流動(dòng)效果

    這篇文章主要為大家詳細(xì)介紹了如何通過JavaScript實(shí)現(xiàn)粒子流動(dòng)效果,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下
    2023-09-09

最新評(píng)論