<%@ Page Language="C#" AutoEventWireup="true" Inherits="WeiPayWeb.WeiPay" Codebehind="WeiPay.aspx.cs" %>
<%@ Import Namespace="Kesion.Cache" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>[<%=MyCache.GetCacheConfig(1) %>] 微信支付</title>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
    <link href="/3g/Template01/user/images/user.css" rel="stylesheet" type="text/css">
    <link href="/3g/style/user.css" rel="stylesheet" type="text/css">
     <link href="/3g/Template01/user/fonts/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <script src="JS/jquery.js" type="text/javascript"></script>
    <script src="JS/lazyloadv3.js" type="text/javascript"></script>
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
 <style>
    .s_btn{padding:0 10px } 
 	.s_btn .button{display: block; width:100%;font-weight: 400;text-align: center;vertical-align: middle;cursor: pointer;border: 1px solid transparent;padding: 6px 0px;font-size: 14px;line-height: 1.42857143;border-radius: 4px; color:#fff;background-color: #da4453;border-color: #da4453; }
 </style>
</head>
<body>
<div class="headbar clearfix">
   <div class="back" style="padding-top:3px"><a href="javascript:;" onClick="history.back()"><i class="fa fa-chevron-left"></i></a></div>
   <h3>微信支付</h3>
   <div class="right_head fr">
      <a href="/3g/user/index.aspx" class="myuser"><i class="fa fa-user"></i></a>
   </div>
</div> 
<div class="clear" style="height:10px;"></div>
 <form id="form1" runat="server">
 
     <div>
          <table cellspacing="1" cellpadding="3" class="border" width="98%" align="center" border="0">
                     <tr class="tdbg">
                        <td class="splittd lefttd" style="height: 25px">订 单 号：</td>
                        <td class="splittd"><asp:Label ID="lblOrderSN" runat="server" Text=""></asp:Label></td>
                     </tr>
                      <tr class="tdbg">
                        <td class="splittd lefttd" style="height: 25px">支付金额：</td>
                        <td class="splittd"> <asp:Label ID="lblPrice" runat="server" Text=""></asp:Label>元</td>
                     </tr>
                      <tr class="tdbg">
                        <td class="splittd lefttd" style="height: 25px">商品清单：</td>
                        <td class="splittd"> <asp:Label ID="lblBody" runat="server" Text=""></asp:Label></td>
                     </tr>
                   
                     
                       <tr style="display:none">
                         <td class="splittd lefttd">自定义参数：</td>
                        <td class="splittd">  <asp:Label ID="lblAttach" runat="server" Text=""></asp:Label>    </td>
                     </tr>
                     
                      <tr class="tdbg" style="display:none">
                        <td class="splittd lefttd" style="height: 25px">OpenId：</td>
                        <td class="splittd">  <asp:Label ID="lblOpenId" runat="server" Text=""></asp:Label>    </td>
                     </tr>
                      <tr class="tdbg">
                        <td class="splittd" colspan="2"> 
                          <div class="s_btn"><input type="button" class="button" value="确认支付" id="getBrandWCPayRequest" onclick="SavePay()" /></div>
                          </td>
                     </tr>
                 </table>
        </div>
     
 
<%--    <div class="WCPay">
    <h1 class="title"  id="getBrandWCPayRequest" onclick="SavePay()" >提交</h1>
    
<a id="getBrandWCPayRequest" href="javascript:void(0);">
            <h1 class="title" onclick="">点击提交可体验微信支付</h1>
        </a>

    </div>--%>
        </form>
        <div class="footer">
   <ul>
      <li>
         <a href="/3g/index.aspx">
            <div class="fa fa-home"></div>
            <p>主页</p>
         </a>
         <a href="/3g/shop/shoppingcart.aspx">
            <div class="fa fa-shopping-cart"></div>
            <p>购物车</p>
         </a>
         <a href="/3g/user/index.aspx">
            <div class="fa fa-user"></div>
            <p>会员中心</p>
         </a>
         
         <a href="javascript:;" onClick="history.back()">
            <div class="fa fa-long-arrow-left"></div>
            <p>返回</p>
         </a>
      </li>
   </ul>
</div>

</body>
</html>


<script type="text/javascript">

function SavePay(){
    WeixinJSBridge.invoke('getBrandWCPayRequest', {
                   "appId": "<%= WeiPay.PayConfig.AppId %>", //公众号名称，由商户传入
                   "timeStamp": "<%= TimeStamp %>", //时间戳
                   "nonceStr": "<%= NonceStr %>", //随机串
                   "package": "<%= Package %>", //扩展包
                   "signType": "MD5", //微信签名方式:1.sha1
                   "paySign": "<%= PaySign %>" //微信签名
               }, 
               function(res) {
                   if (res.err_msg == "get_brand_wcpay_request:ok") {
                       alert("微信支付成功!");
                       location.href = "WxPayTips.aspx?issuccess=1&orderid=<%=OrderSN%>&from=<%=Attach%>";
                   } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                       alert("用户取消支付!");
                   } else {
                       alert(res.err_msg);
                       alert("支付失败!");
                       location.href = "WxPayTips.aspx?issuccess=0&orderid=<%=OrderSN%>&from=<%=Attach%>";
                   }
                   // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                   //因此微信团队建议，当收到ok返回时，向商户后台询问是否收到交易成功的通知，若收到通知，前端展示交易成功的界面；若此时未收到通知，商户后台主动调用查询订单接口，查询订单的当前状态，并反馈给前端展示相应的界面。
               });    
}
   


</script>