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

PC端微信掃碼支付成功之后自動(dòng)跳轉(zhuǎn)php版代碼

 更新時(shí)間:2017年07月07日 15:51:05   作者:依然范兒特西  
這篇文章主要為大家詳細(xì)介紹了微信掃碼支付成功之后自動(dòng)跳轉(zhuǎn)php版代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了php微信掃碼支付成功之后自動(dòng)跳轉(zhuǎn)的具體代碼,供大家參考,具體內(nèi)容如下

場(chǎng)景: PC端   微信掃碼支付

結(jié)果: 支付成功 自動(dòng)跳轉(zhuǎn)

實(shí)現(xiàn)思路:

支付二維碼頁面,寫ajax請(qǐng)求支付狀態(tài),請(qǐng)求到結(jié)果,無論成功還是失敗,都跳轉(zhuǎn)到相應(yīng)的結(jié)果頁面

具體實(shí)現(xiàn)方法:

html部分:

支付結(jié)果狀態(tài)設(shè)定: 0 未支付  1 支付成功 2 支付失敗

<input type="hidden" id="order_id" value="<?php echo $order_id;?>">
<script type="text/javascript">
function pay_status(){
  var order_id = $("#order_id").val();
  $.ajax({ 
  url:'http://' + window.location.host+ '/home/cart/pay_status_check',
  dataType:'json', 
  type:'post', 
  data:{'order_id':order_id}, 
  success:function(data){ 
   if(data == '1' ){
    window.clearInterval(int); //銷毀定時(shí)器
    setTimeout(function(){
     //跳轉(zhuǎn)到結(jié)果頁面,并傳遞狀態(tài)
     window.location.href="http://" rel="external nofollow" rel="external nofollow" +window.location.host+"/home/cart/pay_result?pay_status=success";
    },1000)
    
   }else if(data =='2'){
    window.clearInterval(int); //銷毀定時(shí)器
    setTimeout(function(){
     //跳轉(zhuǎn)到結(jié)果頁面,并傳遞狀態(tài)
     window.location.href="http://" rel="external nofollow" rel="external nofollow" +window.location.host+"/home/cart/pay_result?pay_status=fail";
    },1000)
   }
  }, 
  error:function(){ 
   alert("error");
   
  }, 

 });
}
//啟動(dòng)定時(shí)器
var int=self.setInterval(function(){pay_status()},1000);
</script>

PHP 部分:

//支付狀態(tài)檢測(cè)
 public function pay_status_check(){
  $order_id = I("order_id");
  $result = M('table')->where("order_id = $order_id")->find();
  echo $result['pay_status'];
 }

基礎(chǔ)功能就這些,如果想效果好看一點(diǎn),可以再加一些樣式,比如:支付成功,加一個(gè)對(duì)號(hào)的動(dòng)畫!

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

相關(guān)文章

最新評(píng)論