• 陈-朱-兴- js写法【案例】:


    ajax请求:

    一、从服务器端请求数据:

    var url = '';
    url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='+ appid +'&secret='+ secret +'&code='+ code +'&grant_type=authorization_code';
    $.ajax({ type:
    'GET', url: url, dataType: 'json', success: function(data){ alert(JSON.stringify(data)) }, error: function(xhr, type){ alert('Ajax error!') } });

    二、发送数据到服务器

    // 参与活动
     function joinActivity(msg){
         $.ajax({
            type: 'GET',
            url: 'http://ebsig.mcake.com/ajax-shop/activity/wsj.ajax',
            data: { operFlg: 'join', gid: gid, oid:oid, msg: msg},
            dataType: 'json',
            success: function(data){
                 if(data.code == 200) {
                        $('#js_step9').show();
                 } else {
                        // 已经参加过
                        alert(data.message);
                 }
            },
            error: function(xhr, type){
                alert('Ajax error!')
            }
       });
    }
    函数调用:
    joinActivity(val);

    整体页面js部署:

    //初始化设置
    var
    gid = '', oid = getOid(); $step1 = $('#js_step1'), $step2 = $('#js_step2'), $step3 = $('#js_step3'), $step4 = $('#js_step4'), $step5 = $('#js_step5'), $step6 = $('#js_step6'), $step7 = $('#js_step7'), $step8 = $('#js_step8'), $step9 = $('#js_step9'), $step10 = $('#js_step10'), $step11 = $('#js_step11'), $step12 = $('#js_step12'), $step13 = $('#js_step13'), menTimeer = null; $(function(){ // 初始化weixin 配置 (function initConfig(){ execJs(); })();
    // 授权
        function auth(appId){
    } });
    function execJs() { function imgShow(ele){ var i=-1; var len=ele.children("img").length; function imgAnimate(){ //设置走光动画 i++; if(i<len){ setTimeout(function(){ ele.children("img").eq(i).show().siblings().hide(); imgAnimate(); //内部回调 },300); } } imgAnimate(); //执行一次动画,否则其他动画不隐藏 } } imgShow($("#js_loading"));//立刻执行一次 var timeer = setInterval(function(){imgShow($("#js_loading"))},1200);/*循环执行*/ //loading动画 function imgLoad(ele){} function step1(){
          $step1.hide();
             $step3.show();
        }
    function step2(){} function step3(){} var animation = { menAnimation: function(){}, cdAnimation: function(){}, zdAnimation: function(){}, sdAnimation: function(){}, }
        // 发起活动
        function initActivity(callback){}
    // 查看活动
        function checkActivity(gid){}
        // 参与活动
        function joinActivity(msg){}
        //分享
        function shareWx(url){}

          (function bindEvent () {
         // 步骤
             $step1.on('click', function(){
                 clearInterval(menTimeer);
                 step2();
             });
          $step2.on('click', function(){
                 $("#js_share").find('img').hide();
                location.href = location.origin + location.pathname + '?gid=' + gid;
    step2();
                $step1.hide();
            });
    })(); }
    var $bao = $('#js_bao'),
        $step2 = $('#js_step2'),
        $step3 = $('#js_step3');
    
    
    (function initConfig(){
        execJs();
    })();
    
    function execJs() {
        function step1(){
          $bao.find("li").click(function(){
                $(this).addClass("on").siblings().removeClass("on");
            })
       }
        
        (function bindEvent () {
            step1();
        })();
    }
  • 相关阅读:
    airtest支持Cocos-Creator,SDK接入
    Python的getter和setter方法
    liunx常用命令
    liunx的vim常用命令收集
    django+atx+liunx的一些shell脚本
    django+airtest+atx部署liunx平台
    Android下的鉴权实现方案
    Mate20 pro实现H265 (HEVC)实时硬件编码
    OpenCV C++常用功能介绍
    Ubuntu16.04编译libjpeg-turbo库
  • 原文地址:https://www.cnblogs.com/shimily/p/4897879.html
Copyright © 2020-2023  润新知