<%@ Page Language="C#" AutoEventWireup="true" Inherits="Plus_Pay_pay" Codebehind="ToPay.aspx.cs" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Components" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>在线支付:<%=title %></title>
    <script src="/ks_Inc/jquery.js"></script>
    <script src="/ks_Inc/kesion.common.js"></script>
</head>
<style>
ul li{list-style: none;}
.paycurr img{border: 2px solid #006835}
.paybtn{line-height: 34px;font-size: 14px;color: #fff;cursor: pointer;background: #2f7dfb;border: 0;border-radius: 3px;transition: .3s;padding: 4px 20px;text-align: center;margin-top:6px;}
.paybtn2{line-height: 34px;font-size: 14px;color: #fff;cursor: pointer;background: #808080;border: 0;border-radius: 3px;transition: .3s;padding: 4px 20px;text-align: center;margin-top:6px;}
.pay-bt {text-align:center;}
.payt{padding: 10px;font-size: 18px;}
.payt a{color: #2f7dfb}
.clearfix .paycurr::before {border: 4px solid #39a2ff;}
.clearfix li::before {border: 2px solid #ccc;border-radius: 50%;box-sizing: border-box;content: "";display: inline-block;height: 13px;margin-right: 10px; margin-left: 10px;width: 13px;}
.clearfix{background: #f4f4f4;padding: 14px 0;}
.clearfix li{padding-bottom: 10px;cursor:pointer }
.paybtn:hover{background: #468af7;}
.tdbg-l{width: 40%;float: left;}
.tdbg-r{width: 60%;float: right;}
.tdbg-l img{width: 320px;height: 320px;object-fit: cover;}
table{padding-top: 35px;}
@media screen and (max-width: 760px) {
    .tdbg-l,.tdbg-r{width: 100%;}
    .tdbg-l img{width: 160px;height: 160px;object-fit: cover;padding: 0 26%;padding-bottom: 30px;}
    .payt {padding: 5px;font-size: 18px;}
     table{padding-top: 0px;}
}
</style>
<body>
    <form id="form1" runat="server">
    <div class="r_tybox t_tybox nomar">
    <table cellspacing="0" cellpadding="0" class="border" width="100%" align="center" border="0" >
     <tr class="tdbg jg-row">
         <div class="tdbg-l">
            <img style="" onerror="this.src='/sysimg/nopic.gif'" src="<%=drr["defaultPic"].ToString()%>" />
         </div>
        <div class="tdbg-r">
            <div class="payt">商品名称：<a><%=title %></a></div>
             <div class="payt">支付金额：<a>￥<%=Kesion.APPCode.Public.ReturnShopPrice(ReadPoint) %><%=MyCache.GetCurrencyUnit %> </a></div>
           <div class="payt">选择支付平台：</div>
           <div class="paylist p20">
         <ul class="clearfix">
     <%
         string payId = "0";
         StringBuilder sb = new StringBuilder();
         using (DataTable dt = CommonData.GetDataTable(4))
         {
             if (dt.Rows.Count > 0)
             {
                 foreach (DataRow dr in dt.Rows)
                 {
                     if (Utils.IsShowPayMentOnDevice(dr["showdevice"].ToString()))
                     {
                         if (dr["isdefault"].ToString() == "1")
                         {
                             payId = dr["id"].ToString();
                         }
                         sb.AppendLine(string.Format(@"<li{2} payid=""{3}"">{1}</li>", dr["logo"].ToString(), dr["platname"].ToString(), dr["isdefault"].ToString() == "1" ? @" class=""paycurr""" : string.Empty, dr["id"].ToString()));
                     }
                 }
             }
         }
         Response.Write(sb.ToString());
		 string  orderID= string.Concat("M", DateTime.Now.ToString("yy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), DateTime.Now.ToString("HH"), DateTime.Now.ToString("mm"), DateTime.Now.ToString("ss"))+"_"+infoId;
      %>
         </ul>
     </div>
     <div class="clear"> </div>

     <div class="pay-bt p20">
         <input type="button" value="立即在线支付" onclick="return(doPay())" class="paybtn" />
         <%if (__user.Money>0){ %>
         <input type="button" value="余额支付(余额：<%=__user.Money %>元)" onclick="AccessPay()" class="paybtn2" />
         <%} %>

     </div>

    </div>
     </tr>
    </table>
      <script>
          var pid=<%=payId%>;
          $(document).ready(function(){
              $(".paylist").find("li").click(function(){
                  pid=$(this).attr("payid");
                  $(".paylist").find("li").attr("style","");
                  $(".paylist").find("li").removeClass("paycurr");
                  $(this).addClass("paycurr");
              });
          });
          function doPay() {
              window.open('/plus/pay/PayConfirm.aspx?orderID=<%=orderID%>&ordertype=100&PlatID=' + pid);
              return false;
          }
          function AccessPay() {
              jQuery.ajax({
                  type: "POST",
                  url: "/plus/Ajaxs.ashx",
                  data: "modelid=<%=modelId%>&infoid=<%=infoId%>&a=setchargestatus",
                  success: function (data) {
                      top.location.reload();
                  }
              });
          }

        $(function () {
        checkInterval=setInterval("checkPayStatus();", 5000); 
        });
          function checkPayStatus() {
            $.ajax({
                type: "get", async: false, url: "/plus/pay/wx/checkstatus.aspx?orderid=<%=orderID%>&ordertype=100&anticache=" + Math.floor(Math.random() * 1000), cache: false, success: function (d) {
                    if (d != '' && d.indexOf("success|") != -1) {
                         KesionJS.Alert('恭喜，支付成功!', "top.location.href ='"+  d.split('|')[1]+"';");
                    }
                }
            });
        }
       </script>
    </form>
</body>
</html>
