码迷,mamicode.com
首页 > Web开发 > 详细

利用ajax判断钱包余额支付成功

时间:2016-04-18 13:15:54      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:

前台:

 1 <div class="cardexplain"  style="margin:0;padding:0;">
 2     <ul class="round" style="margin:0;padding:0;border-radius:0;border:0px;border-bottom:1px solid #C6C6C6">
 3         <table width="100%" border="0" cellpadding="0" cellspacing="0" class="cpbiaoge">
 4             <tr>
 5                 <td> <span>订单详情</span> <!--span style=‘float:right‘><a href=‘./index.php?g=App&m=Index&a=index_info‘>继续购物>>></a></span--> </td>
 6             </tr>
 7         </table>
 8     </ul>
 9 </div>
10 
11 
12 <div class="cardexplain" style="margin-bottom: 0px;">
13     <ul class="round"  style="margin-left:0;margin-right:0;">
14         <li class="title mb"><span class="none">收货人信息</span></li>
15         <li class="nob">
16             <table>
17                 <tr><td>联系人:{$username}</td></tr>
18                 <tr><td>联系电话:{$phone}</td></tr>
19                 <tr><td>联系地址:{$address}</td></tr>
20             </table>
21         </ul>
22 </div>
23 
24 <div class="cardexplain">
25     <ul class="round" style="margin-left:0;margin-right:0;">
26         <li class="title mb"><span class="none">产品信息</span></li>
27         <li class="nob">
28             <table>
29                 <tr><td><img width=‘70‘ height=‘70‘ src=‘/Public/Uploads/{$image}‘></td>
30                     <td><table>
31                     <tr><td>{$menu_name}<td></tr>
32                     <tr><td>¥{$price} * {$count}<td></tr>
33                     </table></td>
34                 </tr>
35             </table>
36             <div name ="payNum" id="payNum" style=‘text-align:center;color:red;‘>购物合计总金额:{$price*$count}元</div>
37         </ul>
38 </div>
39 <div id="payDom" class="cardexplain">
40     <div class="footReturn" style="text-align:center">
41         <input type="button" style="margin:0 auto 20px auto;width:100%" onclick="callpay({$price*$count})" class="submit" value="钱包支付"/>
42     </div>
43 </div>
44 <div id="failDom" style="display:none" class="cardexplain">
45     <ul class="round">
46         <li class="title mb"><span class="none">支付结果</span></li>
47         <li class="nob">
48             <table width="100%" border="0" cellspacing="0" cellpadding="0" class="kuang">
49                 <tr><th>支付失败</th><td><div id="failRt">您的余额不足,请选择其他支付方式!</div></td></tr>
50             </table>
51         </li>
52     </ul>
53     <div class="footReturn"style="text-align:center">
54         <input type="button"style="margin:0 auto 20px auto;width:100%"onclick="window.location.href = ‘{$url}‘"class="submit"value="重新进行支付"/>
55     </div>
56 </div>
57 <div id="successDom" style="display:none" class="cardexplain">
58     <ul class="round"><li class="title mb"><span class="none">支付成功</span></li>
59     <li class="nob">
60         <table width="100%"border="0"cellspacing="0"cellpadding="0"class="kuang">
61             <tr><th>您已支付成功,页面正在跳转...</td></tr>
62         </table>
63         <div id="failRt"></div>
64     <!--/td></tr></table-->
65     </li>
66     </ul>
67 </div>

 

ajax函数体:(出现过写在上面不加载的问题,推荐放在页面下方)

<script src="/Application/Tpl/App/default/Public/Static/js/jquery-1.9.1.min.js"></script>
<script language="javascript">
function callpay(num)
{
    $.ajax({
        url:"./index.php?g=App&m=Index&a=ajaxqianpay",
        type:"POST",
        data:‘payNum=‘+num,
        success:function(msg){
            alert(msg.data);
            if(msg.data==‘right‘){
                document.getElementById(‘payDom‘).style.display=‘none‘;
                document.getElementById(‘successDom‘).style.display=‘‘;
                setTimeout(‘window.location.href="/index.php?g=App&m=Index&a=order"‘, 3000);
            }else{
                document.getElementById(‘payDom‘).style.display=‘none‘;
                document.getElementById(‘failDom‘).style.display=‘‘;
            }
        }
    });
}

</script>

后台:

 1 public function ajaxqianpay(){
 2         $uid = $_SESSION[‘uid‘];
 3         $moneyBySql = M(‘User‘)->where(‘id=‘.$uid)->field(‘price,d_price‘)->find();
 4 
 5         if($moneyall<=$_POST[‘payNum‘]){
 6             $this->ajaxReturn(array(‘wrong‘),‘failed‘,0);
 7             }else{
 8                 $this->ajaxReturn(array(‘right‘),‘success‘,1);
 9                 }
10   }

 

利用ajax判断钱包余额支付成功

标签:

原文地址:http://www.cnblogs.com/cuidawen/p/5403854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!