添加后台代理代码
This commit is contained in:
146
codes/agent/game/api/sample/offlinepay/css/style.css
Normal file
146
codes/agent/game/api/sample/offlinepay/css/style.css
Normal file
@@ -0,0 +1,146 @@
|
||||
body{
|
||||
font-size: 14px;
|
||||
font-family: "微软雅黑";
|
||||
position: relative;
|
||||
}
|
||||
body,ul,li,article{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
ul,li{
|
||||
list-style: none;
|
||||
}
|
||||
a{
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
.text-center{
|
||||
text-align: center;
|
||||
}
|
||||
.red{
|
||||
color: red;
|
||||
}
|
||||
.btn{
|
||||
display: inline-block;
|
||||
padding: 8px 14px;
|
||||
margin-bottom: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 1.42857143;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
-ms-touch-action: manipulation;
|
||||
touch-action: manipulation;
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
background-image: none;
|
||||
border: 1px solid transparent;
|
||||
/*border-radius: 4px;*/
|
||||
text-decoration: none;
|
||||
}
|
||||
.btn-blue{
|
||||
color: #fff;
|
||||
background: -moz-linear-gradient(top, #41b8ff, #0b53bb);
|
||||
background: -webkit-gradient(linear,0% 0%,0% 100%,from(#41b8ff),to(#0b53bb));
|
||||
background: -webkit-linear-gradient(top, #41b8ff, #0b53bb);
|
||||
background: -o-linear-gradient(top, #41b8ff, #0b53bb);
|
||||
background: -ms-linear-gradient(top, #41b8ff, #0b53bb);
|
||||
border-color: rgb(253, 253, 254);
|
||||
}
|
||||
.header{
|
||||
background-color: #2b2b2b;
|
||||
color: #ffffff;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
}
|
||||
.header .img{
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 7px;
|
||||
padding-left: 10px;
|
||||
height: 25px;
|
||||
}
|
||||
.neirong{
|
||||
padding-top: 40px;
|
||||
}
|
||||
.neirong ul{
|
||||
padding-top: 15px;
|
||||
}
|
||||
.neirong ul li{
|
||||
padding: 15px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.neirong ul li .name{
|
||||
text-align: right;
|
||||
width: 92px;
|
||||
display: inline-block;
|
||||
}
|
||||
.neirong ul li .input{
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
}
|
||||
.foot_btn{
|
||||
width: 250px;margin-top: 30px;height: 35px;line-height: 35px;
|
||||
}
|
||||
|
||||
.shaoma{
|
||||
z-index: 3;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
top: 35%;
|
||||
display: none;
|
||||
width: 100%;
|
||||
}
|
||||
.shaoma .xians{
|
||||
width: 18%;
|
||||
min-width: 312px;
|
||||
height: 100%;
|
||||
border: 1px solid #d8d8d8;
|
||||
position: relative;
|
||||
background-color: #ffffff;
|
||||
/* left: 41%;
|
||||
right: 41%;*/
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
.shaoma .xians .img_close{
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
.img-responsive{
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.mt_20{
|
||||
margin-top: 20px;
|
||||
}
|
||||
.shaoma .xians .qing{
|
||||
width: 70%;
|
||||
height: 80px;
|
||||
background-color: #445e84;
|
||||
color: #ffffff;
|
||||
margin: 0 auto 20px auto;
|
||||
}
|
||||
.shaoma .xians .qing .sys{
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
margin: 15px;
|
||||
}
|
||||
.shaoma .xians .qing span{
|
||||
margin: 10px;
|
||||
height: 70px;
|
||||
display: block;
|
||||
padding-top: 7%;
|
||||
}
|
||||
|
||||
BIN
codes/agent/game/api/sample/offlinepay/img/close.png
Normal file
BIN
codes/agent/game/api/sample/offlinepay/img/close.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 280 B |
BIN
codes/agent/game/api/sample/offlinepay/img/sys.jpg
Normal file
BIN
codes/agent/game/api/sample/offlinepay/img/sys.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
codes/agent/game/api/sample/offlinepay/img/timg.jpg
Normal file
BIN
codes/agent/game/api/sample/offlinepay/img/timg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
45
codes/agent/game/api/sample/offlinepay/index.html
Normal file
45
codes/agent/game/api/sample/offlinepay/index.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>支付测试</title>
|
||||
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<section>
|
||||
<header class="header"><span>支付测试</span></header>
|
||||
<div class="neirong">
|
||||
<ul>
|
||||
<li><span class="name">总金额:</span><input type="text" placeholder="单位:分 整型" class="input"> <sapn class="red">*</sapn></li>
|
||||
</ul>
|
||||
<footer class="text-center">
|
||||
<a href="javascript:;" onclick="sm();" class="btn btn-blue foot_btn">确定</a>
|
||||
</footer>
|
||||
</div>
|
||||
</section>
|
||||
<div class="shaoma">
|
||||
<div class="xians">
|
||||
<a href="javascript:;" class="close"><img src="img/close.png" class="img_close"></a>
|
||||
<div class="mt_20">
|
||||
<img src="img/timg.jpg" class="img-responsive">
|
||||
</div>
|
||||
<div class="qing">
|
||||
<img src="img/sys.jpg" width="50" height="50" class="sys">
|
||||
<span>请使用微信扫描二维码以完成支付</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
|
||||
<script>
|
||||
function sm(){
|
||||
$(".shaoma").css("display","block");
|
||||
}
|
||||
$(".shaoma .xians .close").click(function(){
|
||||
var obj = $(this);
|
||||
obj.parents(".shaoma").css("display","none");
|
||||
})
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
365
codes/agent/game/api/sample/offlinepay/index.php
Normal file
365
codes/agent/game/api/sample/offlinepay/index.php
Normal file
@@ -0,0 +1,365 @@
|
||||
<?php
|
||||
|
||||
define('USEDCHARSET', 'utf-8');
|
||||
|
||||
/// 这里定义公共变量
|
||||
//$app_id = '14936872341446'; /// appid
|
||||
//$dev_key = '14915485974028'; /// 开发者key
|
||||
$app_id = '14992192722868'; /// appid
|
||||
$dev_key = '14915485974028'; /// 开发者key
|
||||
$market_key = '0000'; /// 门店key
|
||||
$sign_key = '0000'; /// 签名key(暂时支付时不校验签名, 但是退款时将校验这个签名)
|
||||
|
||||
|
||||
|
||||
/// 接口返回用的信息类
|
||||
class ResultObject
|
||||
{
|
||||
public $error; /// 返回值: 0成功; 非0失败;
|
||||
public $error_code; /// 错误号
|
||||
public $msg; /// 错误信息
|
||||
public $data; /// 返回的数据
|
||||
|
||||
public function ResultObject($string)
|
||||
{
|
||||
$this->error = 0;
|
||||
$this->error_code = 0;
|
||||
$this->msg = null;
|
||||
$this->data = null;
|
||||
|
||||
$this->from_string($string);
|
||||
}
|
||||
|
||||
|
||||
public function to_array()
|
||||
{
|
||||
return (array)$this;
|
||||
}
|
||||
|
||||
public function to_string()
|
||||
{
|
||||
return json_encode($this, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
public function from_array($array)
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
if (property_exists($this, $key))
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function from_string($string)
|
||||
{
|
||||
return $this->from_array((array)json_decode($string));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @note 获取当前页面的完整连接
|
||||
* @return string
|
||||
*/
|
||||
function getLocaleUrl()
|
||||
{
|
||||
$is_https =
|
||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
|
||||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
|
||||
(isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] == 'https');
|
||||
|
||||
$request_scheme = $is_https ? 'https://' : 'http://';
|
||||
$hostname = $_SERVER['SERVER_NAME'];
|
||||
$hostport = (($is_https && '443' == $_SERVER['SERVER_PORT']) || (!$is_https && '80' == $_SERVER['SERVER_PORT'])) ? '' : ':' . intval($_SERVER['SERVER_PORT']);
|
||||
|
||||
return $request_scheme . $hostname . $hostport . $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @date 2017-03-04
|
||||
* @note 给参数按key的顺序排序。(支持递归)
|
||||
* @param mixed $parameter 要排序的参数
|
||||
* @return array
|
||||
* @auth 应俊
|
||||
*/
|
||||
function SortParam($parameter)
|
||||
{
|
||||
$parameter = (array)$parameter;
|
||||
foreach ($parameter as $k => $v)
|
||||
{
|
||||
if (is_array($v) || is_object($v))
|
||||
{
|
||||
$parameter[$k] = SortParam($v);
|
||||
}
|
||||
}
|
||||
|
||||
// 调用strcmp函数来排序,该函数区分大小写。
|
||||
uksort($parameter, 'strcmp');
|
||||
return $parameter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @date 2017-03-06
|
||||
* @note 转换参数成字符串形式按key=value的形式,用&分隔)。
|
||||
* @param mixed $parameter 要转换的参数
|
||||
* @return string
|
||||
* @auth 应俊
|
||||
*/
|
||||
function ConvertParam($parameter)
|
||||
{
|
||||
$parameter = (array)$parameter;
|
||||
$return = '';
|
||||
foreach ($parameter as $k => $v)
|
||||
{
|
||||
if (is_array($v) || is_object($v))
|
||||
{
|
||||
$return .= sprintf('&%s={%s}', $k, ConvertParam($v));
|
||||
}
|
||||
else
|
||||
{
|
||||
$return .= sprintf('&%s=%s', $k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
$sublen = mb_strlen('&', USEDCHARSET);
|
||||
$retlen = mb_strlen($return, USEDCHARSET);
|
||||
$return = mb_substr($return, $sublen, $retlen - $sublen, USEDCHARSET);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @date 2017-03-04
|
||||
* @note 为参数生成签名
|
||||
* @param mixed $parameter 要签名的参数
|
||||
* @param string $signkey 签名key
|
||||
* @return string
|
||||
* @auth 应俊
|
||||
*/
|
||||
function SignParameter($parameter, $signkey = '')
|
||||
{
|
||||
// 1:先把参数按参数名(key)从小到大排序
|
||||
$parameter = SortParam($parameter);
|
||||
|
||||
// 2:连接参数成一个字符串(按key=value的形式,用&分隔)。
|
||||
$return = ConvertParam($parameter);
|
||||
|
||||
// 3:结尾加上key=签名key
|
||||
$return .= '&key=' . $signkey;
|
||||
|
||||
// 4:md5加密这个字符串
|
||||
return md5($return);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
function ChangePostData($data)
|
||||
{
|
||||
switch (gettype($data))
|
||||
{
|
||||
case 'array':
|
||||
{
|
||||
foreach ($data as $key => $value)
|
||||
{
|
||||
$data[$key] = ChangePostData($value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'object':
|
||||
{
|
||||
$array = (array)$data;
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$data->$key = ChangePostData($value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
$data = preg_replace_callback('/\+/', function ($r) { return '%2B'; }, $data);
|
||||
$data = preg_replace_callback('/\&/', function ($r) { return '%26'; }, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @note 发送post请求
|
||||
* @param string $url
|
||||
* @param mixed $data
|
||||
* @return string
|
||||
*/
|
||||
function SendPost($url, $data)
|
||||
{
|
||||
$data = http_build_query(ChangePostData($data));
|
||||
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n",
|
||||
'content' => $data,
|
||||
),
|
||||
);
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
$ret = file_get_contents($url, false, $context);
|
||||
$ret = trim($ret, "\xEF\xBB\xBF");
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>支付测试</title>
|
||||
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
|
||||
<script src="js/jquery-2.1.4.min.js"></script>
|
||||
<script src="js/common.js"></script>
|
||||
</head>
|
||||
<body id="mainbody">
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_REQUEST['fee'])) /// 有fee参数表示已提交页面中输入的支付金额
|
||||
{
|
||||
/// 1: 获取该门店下支援的所有支付方式列表(线下)
|
||||
$data = array(
|
||||
'appid' => $app_id, /// appid
|
||||
'devkey' => $dev_key, /// 开发者key
|
||||
'market_key' => $market_key, /// 门店key
|
||||
'level' => 2, /// 支付类型(1: 线上, 2: 扫码, 3: app)
|
||||
'version' => 1, /// 版本号
|
||||
);
|
||||
|
||||
$data['sign'] = SignParameter($data, $sign_key);
|
||||
$result = new ResultObject(rawurldecode(SendPost('https://api2.tscce.cn/api/newpay/querylist', $data)));
|
||||
if (0 == $result->error && count($result->data) > 0) /// 调用成功, 并且有支援的支付方式
|
||||
{
|
||||
/// 这里只获取第一种支付方式
|
||||
$pay_type = $result->data[0]->type_id; /// 支付方式的id
|
||||
|
||||
|
||||
$order_id = date('YmdHis') . rand(1000, 9999); /// 随机生成一个订单号
|
||||
$notice_url = dirname(getLocaleUrl()) . '/notice.php'; /// 通知页面地址
|
||||
|
||||
$data = array(
|
||||
'appid' => $app_id, /// appid
|
||||
'devkey' => $dev_key, /// 开发者key
|
||||
'market_key' => $market_key, /// 门店key
|
||||
'orderid' => $order_id, /// 订单号
|
||||
'fee' => $_REQUEST['fee'], /// 支付金额(单位分)
|
||||
'title' => 'test', /// 支付主题
|
||||
'notice_url' => $notice_url, /// 回调地址
|
||||
'paytype' => $pay_type, /// 支付方式
|
||||
'version' => 1, /// 接口版本号
|
||||
/// 以下为附加参数,会在通知回调时返回。
|
||||
'p1' => 'p1', /// 自定义附加参数1
|
||||
'p2' => 'p2', /// 自定义附加参数2
|
||||
);
|
||||
|
||||
$data['sign'] = SignParameter($data, $sign_key); /// 生成签名
|
||||
|
||||
/// 调用接口
|
||||
$result = new ResultObject(rawurldecode(SendPost('https://api2.tscce.cn/api/newpay/pay/offline/', $data)));
|
||||
|
||||
if (0 != $result->error) /// error不为0表示有错误发生
|
||||
{
|
||||
$html = <<<EOL
|
||||
<script>
|
||||
alert('{$result->msg}');
|
||||
</script>
|
||||
EOL;
|
||||
}
|
||||
else /// 调用成功, 则把图片显示在前台中
|
||||
{
|
||||
$url = @$result->data->code_img_url;
|
||||
$html = <<<EOL
|
||||
<center>
|
||||
<div id="img" class="mt_20">
|
||||
<img src="{$url}" class="img-responsive">
|
||||
</div>
|
||||
<div class="qing">
|
||||
<img src="img/sys.jpg" width="50" height="50" class="sys">
|
||||
<span>请扫描二维码以完成支付</span>
|
||||
</div>
|
||||
</center>
|
||||
EOL;
|
||||
}
|
||||
}
|
||||
elseif (0 != $result->error) /// 有错误发生
|
||||
{
|
||||
$html = <<<EOL
|
||||
<script>
|
||||
alert('{$result->msg}');
|
||||
</script>
|
||||
EOL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$html = <<<EOL
|
||||
<script>
|
||||
alert('该门店不支援任何的支付方式!');
|
||||
</script>
|
||||
EOL;
|
||||
}
|
||||
}
|
||||
else /// 无fee参数则需要提示在页面中输入这个参数
|
||||
{
|
||||
$html = <<<EOL
|
||||
<script>
|
||||
function submit() {
|
||||
var fee = document.getElementById('fee').value;
|
||||
|
||||
if ('' == fee || undefined == fee) {
|
||||
alert('请输入要支付的金额(单位为分)');
|
||||
return;
|
||||
}
|
||||
|
||||
var script =
|
||||
"<form style='display:none;' id='frm' name='frm' method='post' action=''>" +
|
||||
" <input name='fee' type='text' value='" + fee + "' />" + /// 支付金额(单位分)
|
||||
"</form>";
|
||||
|
||||
$('#mainbody').append(script);
|
||||
$('#frm').submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
<section>
|
||||
<header class="header"><span>支付测试</span></header>
|
||||
<div class="neirong">
|
||||
<ul>
|
||||
<li><span class="name">总金额:</span><input id="fee" type="text" placeholder="单位:分 整型" class="input"> <sapn class="red">*</sapn></li>
|
||||
</ul>
|
||||
<footer class="text-center"><a href="javascript:;" onclick="submit();" class="btn btn-blue foot_btn">确定</a></footer>
|
||||
</div>
|
||||
</section>
|
||||
EOL;
|
||||
}
|
||||
|
||||
echo $html;
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
216
codes/agent/game/api/sample/offlinepay/js/common.js
Normal file
216
codes/agent/game/api/sample/offlinepay/js/common.js
Normal file
@@ -0,0 +1,216 @@
|
||||
//var g_appid = '14919772144482';
|
||||
//var g_devkey = '14915485974028';
|
||||
var g_RequestAddress = 'https://api.daoqijuyou77.cn';
|
||||
|
||||
/**
|
||||
* @note 字符串格式化
|
||||
* @param fn_objs
|
||||
* @returns object
|
||||
* @constructor
|
||||
*/
|
||||
Overload = function (fn_objs) {
|
||||
var is_match = function (x, y) {
|
||||
if (x == y) {
|
||||
return true;
|
||||
}
|
||||
if (x.indexOf("*") == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var x_arr = x.split(","), y_arr = y.split(",");
|
||||
if (x_arr.length != y_arr.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (x_arr.length) {
|
||||
var x_first = x_arr.shift(), y_first = y_arr.shift();
|
||||
if (x_first != "*" && x_first != y_first) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
var ret = function () {
|
||||
var args = arguments
|
||||
, args_len = args.length
|
||||
, args_types = []
|
||||
, args_type
|
||||
, fn_objs = args.callee._fn_objs
|
||||
, match_fn = function () {
|
||||
};
|
||||
|
||||
for (var i = 0; i < args_len; i++) {
|
||||
var type = typeof args[i];
|
||||
type == "object" && (args[i].length > -1) && (type = "array");
|
||||
args_types.push(type);
|
||||
}
|
||||
args_type = args_types.join(",");
|
||||
for (var k in fn_objs) {
|
||||
if (is_match(k, args_type)) {
|
||||
match_fn = fn_objs[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return match_fn.apply(this, args);
|
||||
};
|
||||
ret._fn_objs = fn_objs;
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* 通过对字符串进行伪重载实现对字符串对象的格式化功能
|
||||
* @type {Object}
|
||||
*/
|
||||
String.prototype.format = Overload({
|
||||
|
||||
"array": function (params) {
|
||||
var reg = /{(\d+)}/gm;
|
||||
return this.replace(reg, function (match, name) {
|
||||
return params[~~name];
|
||||
});
|
||||
},
|
||||
|
||||
"object": function (param) {
|
||||
var reg = /{([^{}]+)}/gm;
|
||||
return this.replace(reg, function (match, name) {
|
||||
return param[name];
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
function getQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if (r != null) {
|
||||
return r[2];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//------------设置Cookie参数方法------------//
|
||||
function setCookie(name, value) {
|
||||
var Days = 30; //此 cookie 将被保存 30 天
|
||||
var exp = new Date();
|
||||
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
|
||||
document.cookie = name + "=" + value + ";expires=" + exp.toGMTString();
|
||||
}
|
||||
|
||||
|
||||
//------------获取Cookie参数方法------------//
|
||||
function getCookie(name) {
|
||||
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
|
||||
if (arr != null) {
|
||||
return arr[2];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//------------删除Cookie参数方法------------//
|
||||
function delCookie(name) {
|
||||
var exp = new Date();
|
||||
exp.setTime(exp.getTime() - 1);
|
||||
var cval = getCookie(name);
|
||||
if (cval != null) {
|
||||
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取随机数
|
||||
*/
|
||||
function randomChar(length) {
|
||||
var x = "0123456789qwertyuioplkjhgfdsazxcvbnm";
|
||||
var tmp = "";
|
||||
var timestamp = new Date().getTime();
|
||||
for (var i = 0; i < length; i++) {
|
||||
tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length);
|
||||
}
|
||||
return timestamp + tmp;
|
||||
}
|
||||
|
||||
|
||||
function localeUrl() {
|
||||
var url = window.location.origin + window.location.pathname;
|
||||
var index = url.indexOf('?');
|
||||
if (-1 == index)
|
||||
return url;
|
||||
else
|
||||
return name.substr(0, index);
|
||||
}
|
||||
|
||||
|
||||
function extractPath(name) {
|
||||
var index = name.lastIndexOf('/');
|
||||
if (-1 == index)
|
||||
return name;
|
||||
else
|
||||
return name.substr(0, index + 1);
|
||||
}
|
||||
|
||||
|
||||
function HttpRequest(args) {
|
||||
var defaults =
|
||||
{
|
||||
url: g_RequestAddress,
|
||||
async: true,
|
||||
|
||||
OnBeforeSend: function (/*XMLHttpRequest*/object) { },
|
||||
OnComplete: function (/*XMLHttpRequest, textStatus*/object, status) { },
|
||||
OnSuccess: function (/*data, textStatus*/message, status) { },
|
||||
OnError: function (/*XMLHttpRequest, textStatus, errorThrown*/object, status, error) { },
|
||||
},
|
||||
|
||||
settings = $.extend({}, defaults, args);
|
||||
|
||||
var data = {};
|
||||
$.each(settings, function (name, value) {
|
||||
if (
|
||||
'async' != name &&
|
||||
'url' != name &&
|
||||
'OnBeforeSend' != name &&
|
||||
'OnComplete' != name &&
|
||||
'OnSuccess' != name &&
|
||||
'OnError' != name
|
||||
) {
|
||||
data[name] = value;
|
||||
}
|
||||
});
|
||||
|
||||
//var succ = function (/*data, textStatus*/message, status) {
|
||||
// var obj = eval("(" + decodeURIComponent(message) + ")");
|
||||
// if (!obj) {
|
||||
// //alert('pager6');
|
||||
// window.location.href = PAGENAME_LOGIN + "?manager_id=" + getCookie(g_managerid);
|
||||
// return false;
|
||||
// }
|
||||
// else if (1 == obj.error && 10008 == obj.error_code) {
|
||||
// //alert('pager7');
|
||||
// window.location.href = PAGENAME_LOGIN + "?manager_id=" + getCookie(g_managerid);
|
||||
// return false;
|
||||
// }
|
||||
// else {
|
||||
// return settings.OnSuccess(message, status);
|
||||
// }
|
||||
//};
|
||||
|
||||
$.ajax({
|
||||
url: settings.url,
|
||||
type: 'post',
|
||||
async: settings.async,
|
||||
data: data,
|
||||
datatype: 'json',
|
||||
timeout: 1000 * 7,
|
||||
beforeSend: settings.OnBeforeSend,
|
||||
success: settings.OnSuccess,
|
||||
//success: succ,
|
||||
error: settings.OnError,
|
||||
complete: settings.OnComplete,
|
||||
});
|
||||
|
||||
return settings;
|
||||
}
|
||||
4
codes/agent/game/api/sample/offlinepay/js/jquery-1.11.1.min.js
vendored
Normal file
4
codes/agent/game/api/sample/offlinepay/js/jquery-1.11.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2394
codes/agent/game/api/sample/offlinepay/js/jquery-2.1.4.min.js
vendored
Normal file
2394
codes/agent/game/api/sample/offlinepay/js/jquery-2.1.4.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
codes/agent/game/api/sample/offlinepay/notice.php
Normal file
9
codes/agent/game/api/sample/offlinepay/notice.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/// 支付的回调通知页面
|
||||
|
||||
$data = file_get_contents('php://input');
|
||||
file_put_contents('c:/1.txt', $data);
|
||||
|
||||
|
||||
/// 返回success表示成功接收到了回调通知
|
||||
die('success');
|
||||
Reference in New Issue
Block a user