<?php
error_reporting(0); 
include("../../../config/ht.php");
include_once("WxPayPubHelper.php");
$ttq = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ttq, 'MicroMessenger') === false) {
}else{
$ttw = new JsApi_pub();
$ddh=$_GET[ddh]; 
$money= $_GET[money];
$openid= $_GET[pid];
$ddmulu="../../../".date("Y-m-d")."ddh";
$ddmuluu=$ddmulu.'/'.$ddh.'.txt'; 
$enidtts = file_get_contents($ddmuluu); 
if (strpos($enidtts, '|ubo|') !== false) {
$openidttd = explode('|ubo|',$enidtts); 
$tzurl=$openidttd[4];
}
$tto="http://".$tzurl."/check-".$ddh.".html";//这是同步跳转地址
$ttp=$money/100;
$tta =time();
$tte_trade_no = WxPayConf_pub::APPID."$tta";
$tts=$ddh;
$unifiedOrder = new UnifiedOrder_pub();
$unifiedOrder->setParameter("openid","$openid");
$unifiedOrder->setParameter("body","$ddh");
//$unifiedOrder->setParameter("out_trade_no","$tte_trade_no");
$unifiedOrder->setParameter("out_trade_no","$ddh");

$unifiedOrder->setParameter("total_fee","$money");
$unifiedOrder->setParameter("notify_url",WxPayConf_pub::NOTIFY_URL);
$unifiedOrder->setParameter("trade_type","JSAPI");
$unifiedOrder->setParameter("attach","$ddh");
$ttd = $unifiedOrder->getPrepayId();
$ttw->setPrepayId($ttd);
$ttwParameters = $ttw->getParameters();
}
?>
<?php if (strpos($ttq, 'MicroMessenger') === false) { ?>
<!DOCTYPE html>
<html>
<head>
<title>抱歉，出错了</title>
<meta charset="gb2312">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">
</head>
<body>
<div class="weui_msg">
<div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div>
<div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>
</body>
</html>
<?php }else{?>
<!DOCTYPE html>
<html>
<head>
<title>微信安全支付</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<style type="text/css">
body {padding: 0;margin: 0;background-color: #eeeeee;font-family: '黑体';}
.pay-main {background-color: #4cb131;padding-top: 20px;padding-left: 20px;padding-bottom: 20px;}
.pay-main img {margin: 0 auto;display: block;}
.pay-main .lines {margin: 0 auto;text-align: center;color: #cae8c2;font-size: 12pt;margin-top: 10px;}
.tips .img {margin: 20px;}
.tips .img img {width: 20px;}
.tips span {vertical-align: top;color: #ababab;line-height: 18px;padding-left: 10px;padding-top: 0px;}
.action {background: #4cb131;padding: 10px 0;color: #ffffff;text-align: center;font-size: 14pt;border-radius: 10px 10px;margin: 15px;}
.action:focus {background: #4cb131;}
.action.disabled {background-color: #aeaeae;}
.footer {position: absolute;bottom: 0;left: 0;right: 0;text-align: center;padding-bottom: 20px;font-size: 10pt;color: #aeaeae;}
.footer .ct-if {margin-top: 6px;font-size: 8pt;}
</style>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
$(document).ready(function () {  
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
WeixinJSBridge.call('hideOptionMenu');
});	
});
</script>
<script>
$(document).ready(function () {  
$('body').on('touchmove', function (event) {
event.preventDefault();
});
});
</script>
</head>
<body>
<script type="text/javascript">
function jsApiCall(){
WeixinJSBridge.invoke(
'getBrandWCPayRequest',
<?php echo $ttwParameters; ?>,
function(res){
WeixinJSBridge.log(res.err_msg);
if(res.err_msg == "get_brand_wcpay_request:ok" ) {
location.href = "<?php echo $tto?>";  
} else {
}
}
);
}
function callpay(){
if (typeof WeixinJSBridge == "undefined"){
if( document.addEventListener ){
document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
}else if (document.attachEvent){
document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
}
}else{
jsApiCall();
}
}
</script>
<script type="text/javascript">
setTimeout("callpay()", 1000 );
</script>
<script src="/2019newui/js/jquery.min.js"></script> 
<script type="text/javascript">
$(".pay-button").click(function(){	
callpay();
});
</script>    
</body>
</html>
<?php }?>