1. 程式人生 > >JS處理支付寶和微信(同步提交/非同步提交)方式

JS處理支付寶和微信(同步提交/非同步提交)方式

PHP交流群:294088839
Python交流群:652376983
GO交流群:874512552
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>個人資訊</title>
   
</head>

<body>

                <form id="form1" action="/agt/type" method="post" target="_blank" onsubmit="return zhifu() ;">
                    <div class="basic-info-detail clearfix">
                        <div class="unit-style padding-big-lr clearfix">
                            <div class="real-name-con margin-tb-25 clearfix">
                                <p class="content-left-zoon">
                                    充值金額:
                                </p>
                                <div class="content-right-zoon">
                                    <input class="width-main input text-a7 h6"  value="" name="money" type="text">
                                </div>
                            </div>
                            <div class="real-name-con margin-tb-25 clearfix">
                                <p class="content-left-zoon">
                                    充值型別
                                </p>
                                <div class="content-right-zoon">
                                    <input id="zfb" name="pay" checked value="1"  type="radio"> <label for="zfb">支付寶</label>
                                    <input id="wx" name="pay"  value="2" type="radio" style="margin-left: 20px;"> <label for="wx">微信</label>

                                </div>
                            </div>
                            <div class="real-name-con margin-tb-25 clearfix">
                                <div class="content-right-zoon">
                                    <input type="submit" value="充值"  class="submit fl">
                                </div>
                            </div>
                        </div>
                    </div>
                </form>


<div id="weixin" style="width: 580px;height: 436px;display:none;">

    <div class="ewm" id="qrcode" style="width: 580px;height: 436px;text-align: center">;

    </div>

</div>

<script>
  
     function zhifu(){
         var pay=$("input[name='pay']:checked").val();
         switch (pay){
             case '1':
                 return true;
                 break;
             case '2':
                 $.post('/agt/type',$('#form1').serialize(),function(res){
                     if(res.code===1){
                         var  html='<img alt="模式二掃碼支付" style="margin-top:100px;width:210px;" src="http://paysdk.weixin.qq.com/qrcode.php?data='+res.msg+'"/>';
                         $('#qrcode').html(html);
                         layer.open({
                             type:1,
                             title:'微信掃一掃',
                             skin:'login-class',
                             area:'580px',
                             scrollbar:false,
                             content:$('#weixin'),
                         });
                     }else{
                         layer.msg(res.msg,{icon:2,time:1000})
                     }

                 })
                 return false;
                 break;
         }


     }

</script>
</body>

</html>