Merge branch 'dev' of wmtx/sdk into master

es5兼容问题
1.let
2,ajax  error()
master
张谷诚 5 years ago committed by Gogs
commit 2f0b6de3be

@ -249,8 +249,8 @@
$(".payment_rest_way").on("click",function(){
$(this).children("img").attr("src","__IMG__/pay_way/dagou2.png");
$(this).siblings(".payment_rest_way").children("img").attr("src","__IMG__/pay_way/dagou1.png");
let img=$(this).children("div").children("img").attr("src");
let text = $(this).children("div").children("span").text();
var img=$(this).children("div").children("img").attr("src");
var text = $(this).children("div").children("span").text();
//获取支付参数
payway = $(this).data("type");
payurl = $(this).data("url");
@ -316,7 +316,7 @@
$(".msgdialog").show();
}
},
error(){
error: function(){
flag=false;
$(".tipmsg").html("接口请求错误");
$(".msgdialog").show();
@ -342,7 +342,7 @@
$(".msgdialog").show();
}
},
error(){
error:function(){
flag=false;
$(".tipmsg").html("接口请求错误");
$(".msgdialog").show();
@ -361,6 +361,7 @@
</script>
<script type="text/javascript">
var evt = "onorientationchange" in window ? "orientationchange" : "resize";
window.addEventListener(evt,resize,false);
function resize(fals) {

@ -261,6 +261,22 @@ function small_program(status) {
return true;
}
function defaultInit(){
try {
var pay_price = '{$pay_price}';
if (pay_price == 0) {
payway="platform_pay";
payurl = "{:U('PayH5/platform_coin_deduction',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'), 'api_ver' => 2))}";
$(".select_pay").hide();
} else {
payway="alipay";
payurl="{:U('PayH5/ali_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}";
}
} catch (error) {
alert("初始化错误");
}
}
$(function() {
var flag = false;

@ -0,0 +1,376 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="__JS__/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="__CSS__/reset.css" />
<link rel="stylesheet" type="text/css" href="__CSS__/payment.css" />
<title>支付中心</title>
</head>
<body>
<div class="payment">
<!-- <div class="heard">
<div class="heard_box">
<a href="" style="background-image: url('__IMG__/pay_way/close.png');"></a>
支付中心
</div>
</div> -->
<div class="containner">
<div class="indent">
<div class="indent_box">
<div>订单金额: <span>¥{$data['price']}元</span> </div>
<div>您的账户余额: <span>{$balance+$bind_balance}平台币</span> </div>
</div>
</div>
<div class="documents">
<div class="documents_box">
<div><span>适用平台金额:</span> <span>-¥{$apply_money}</span> </div>
<div><span>还需支付:</span><span>¥{$pay_price}</span> </div>
</div>
</div>
<div class="select_pay">
<div class="select_pay_box">
<div>请选择支付方式:</div>
<div class="select_pay_info">
<img src="__IMG__/pay_way/zhifubao.png" alt="" class="slide">
<div>支付宝</div>
<img src="__IMG__/pay_way/blue_black.png" alt="" class="boult">
</div>
</div>
</div>
<div class="payment_btn" >
<div>
支付金额 <span>¥{$pay_price}</span>
</div>
<div class="confirm_pay">确认支付</div>
</div>
<div class="payment_rest" style="display: none;">
<div class="payment_rest_box">
<div class="title">
<div>请选择支付方式</div>
<img src="__IMG__/pay_way/dacha.png" alt="">
</div>
<if condition="C('alipay.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.zfb') eq 1) or (C('sqpay.status') eq 1 and C('sqpay.zfb') eq 1)">
<div class="payment_rest_way way_btn" data-type="alipay" data-url="{:U('PayH5/ali_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}">
<div>
<img src="__IMG__/pay_way/zhifubao.png" alt="">
<span>支付宝</span>
</div>
<img src="__IMG__/pay_way/dagou2.png" alt="">
</div>
</if>
<if condition="C('wei_xin.status') eq 1 or C('weixin_gf.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.wx') eq 1) or (C('heepay.status') eq 1) or (C('sqpay.status') eq 1 and C('sqpay.wx_small') eq 1)">
<div class="payment_rest_way way_btn" data-type="wxpay" data-url="{:U('PayH5/weixin_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}">
<div>
<img src="__IMG__/pay_way/weixin.png" alt="">
<span>微信</span>
</div>
<img src="__IMG__/pay_way/dagou1.png" alt="">
</div>
</if>
<if condition="C('sqpay.status') eq 1 and C('sqpay.shortcut') eq 1">
<div class="payment_rest_way way_btn" data-type="shorcut" data-url="{:U('Shortcut/wap_shortcut_pay', array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'code'=>1,'extend'=>I('extend'),'api_ver'=>2))}">
<div>
<img src="__IMG__/pay_way/xianshang.png" alt="">
<span>快捷支付</span>
</div>
<img src="__IMG__/pay_way/dagou1.png" alt="">
</div>
</if>
</div>
</div>
<!-- <div class="payment_rest_btn">其他支付方式</div> -->
</div>
<!-- 未成年不许支付弹窗 -->
<div class="msgdialog" style="display: none">
<div class="forbid_model"></div>
<div class="forbid_window">
<div class="forbid_pay">
<img src="__IMG__/pay_way/forbid.png" alt="" style="margin-top: .5rem;">
<div class="tipmsg">未成年禁止支付哟</div>
</div>
<div class="forbid_confirm" style="margin: 0.45rem auto;">确认</div>
<div class="forbid_close"><img src="__IMG__/pay_way/close2.png" alt=""></div>
</div>
</div>
</div>
<!-- 横屏 -->
<div class="payment_heng">
<!-- <div class="heard">
<div class="heard_box">
<a href="" style="background-image: url('__IMG__/pay_way/close.png');"></a>
支付中心
</div>
</div> -->
<div class="containner">
<div class="indent">
<div class="indent_box">
<div>订单金额: <span>¥{$data['price']}元</span> </div>
<div>您的账户余额: <span>{$balance+$bind_balance}平台币</span> </div>
</div>
</div>
<div class="documents">
<div class="documents_box">
<div><span>适用平台金额:</span> <span>-¥{$apply_money}</span> </div>
<div><span>还需支付:</span><span>¥{$pay_price}</span> </div>
</div>
</div>
<div class="select_pay">
<div class="select_pay_box">
<div>请选择支付方式:</div>
<div class="select_pay_info">
<img src="__IMG__/pay_way/zhifubao.png" alt="" class="slide">
<div>支付宝</div>
<img src="__IMG__/pay_way/blue_black.png" alt="" class="boult">
</div>
</div>
</div>
<div class="payment_btn" >
<div>
支付金额 <span>¥{$pay_price}</span>
</div>
<div class="confirm_pay">确认支付</div>
</div>
<div class="payment_rest" style="display: none;">
<div class="payment_rest_box">
<div class="title">
<div>请选择支付方式</div>
<img src="__IMG__/pay_way/dacha.png" alt="">
</div>
<if condition="C('alipay.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.zfb') eq 1) or (C('sqpay.status') eq 1 and C('sqpay.zfb') eq 1)">
<div class="payment_rest_way way_btn" data-type="alipay" data-url="{:U('PayH5/ali_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}">
<div>
<img src="__IMG__/pay_way/zhifubao.png" alt="">
<span>支付宝</span>
</div>
<img src="__IMG__/pay_way/dagou2.png" alt="">
</div>
</if>
<if condition="C('wei_xin.status') eq 1 or C('weixin_gf.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.wx') eq 1) or (C('heepay.status') eq 1) or (C('sqpay.status') eq 1 and C('sqpay.wx_small') eq 1)">
<div class="payment_rest_way way_btn" data-type="wxpay" data-url="{:U('PayH5/weixin_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}">
<div>
<img src="__IMG__/pay_way/weixin.png" alt="">
<span>微信</span>
</div>
<img src="__IMG__/pay_way/dagou1.png" alt="">
</div>
</if>
<if condition="C('sqpay.status') eq 1 and C('sqpay.shortcut') eq 1">
<div class="payment_rest_way way_btn" data-type="shorcut" data-url="{:U('Shortcut/wap_shortcut_pay', array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'code'=>1,'extend'=>I('extend'),'api_ver'=>2))}">
<div>
<img src="__IMG__/pay_way/xianshang.png" alt="">
<span>快捷支付</span>
</div>
<img src="__IMG__/pay_way/dagou1.png" alt="">
</div>
</if>
</div>
</div>
<!-- 供上下滑动延长 -->
<div style="width: 100%;height: 3rem;"></div>
<!-- 未成年不许支付弹窗 -->
<div class="msgdialog" style="display: none">
<div class="forbid_model"></div>
<div class="forbid_window">
<div class="forbid_pay">
<img src="__IMG__/pay_way/forbid.png" alt="" style="margin-top: .25rem;">
<div class="tipmsg">未成年禁止支付哟</div>
</div>
<div class="forbid_confirm" style="margin: 0.2rem auto;">确认</div>
<div class="forbid_close"><img src="__IMG__/pay_way/close2.png" alt=""></div>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
// 业务逻辑js
var payway='';
var payurl='';
function small_program(status) {
if (status == "1") { // 小程序
if ($('#sdk_version').val() == 1) { // android
window.txyxsdk.getSmallRoutine($('#small_json').val());
} else {
window.webkit.messageHandlers.miniprogramPay.postMessage($('#small_json').val());
}
return false;
}
$(this).removeAttr("onclick", "");
return true;
}
//初始化选择
function defaultInit(){
try {
var pay_price = '{$pay_price}';
if (pay_price == 0) {
payway="platform_pay";
payurl = "{:U('PayH5/platform_coin_deduction',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'), 'api_ver' => 2))}";
$(".select_pay").hide();
} else {
payway="alipay";
payurl="{:U('PayH5/ali_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}";
}
} catch (error) {
alert("初始化错误");
}
}
var timefun;
$(function() {
defaultInit();
$(".select_pay_info").click(function(){
timefun = setTimeout(function(){
$(".tipmsg").html("切换支付失败");
$(".msgdialog").show();
},1000);
$(".payment_rest").show();
clearTimeout(timefun);
});
$(".payment_rest .title>img").click(function(){
$(".payment_rest").hide();
});
$(".payment_rest_way").on("click",function(){
$(this).children("img").attr("src","__IMG__/pay_way/dagou2.png");
$(this).siblings(".payment_rest_way").children("img").attr("src","__IMG__/pay_way/dagou1.png");
let img=$(this).children("div").children("img").attr("src");
let text = $(this).children("div").children("span").text();
//获取支付参数
payway = $(this).data("type");
payurl = $(this).data("url");
$(".select_pay_info").children(".slide").attr("src",img);
$(".select_pay_info").children("div").text(text);
$(".payment_rest").hide();
});
//拉起支付
var flag = false;
$(".confirm_pay").on("click",function(){
if (flag){
$(".tipmsg").html("支付请求中,请勿重复提交");
$(".msgdialog").show();
return false;
};
flag = true;
if(payway == "wxpay"){
wxpay();
}
if(payway == "alipay"){
alipay();
}
if(payway == "shorcut"){
shorcut();
}
if(payway == "platform_pay"){
platform_pay();
}
});
$(".payment_rest_btn").click(function(){
$(".payment_rest_btn").hide();
$(".weixin").show();
});
$(".forbid_confirm,.forbid_close").click(function(){
$(".msgdialog").hide();
});
});
//微信支付
function wxpay(){
$r = small_program("{:C('sqpay.wx_small')}");
if ($r) {
var url = payurl;
$.ajax({
type:'post',
dataType:'json',
data:{},
url:url,
success:function(result) {
if(result.code==200) {
window.location.href = result.url;
} else {
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
}
},
error(){
flag=false;
$(".tipmsg").html("接口请求错误");
$(".msgdialog").show();
}
});
}
}
//支付宝支付
function alipay(){
var url = payurl;
$.ajax({
type:'post',
dataType:'json',
data:{},
url:url,
success:function(result) {
if(result.code==200) {
window.location.href = result.url;
} else {
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
}
},
error(){
flag=false;
$(".tipmsg").html("接口请求错误");
$(".msgdialog").show();
}
});
return false;
}
//快捷支付
function shorcut(){
window.location.href =payurl;
}
//平台币支付
function platform_pay(){
window.location.href = payurl;
}
</script>
<script type="text/javascript">
var evt = "onorientationchange" in window ? "orientationchange" : "resize";
window.addEventListener(evt,resize,false);
function resize(fals) {
if(window.orientation == 0 || window.orientation == 180) {
$(".payment").show();
$(".payment_heng").hide();
}else {
$(".payment").hide();
$(".payment_heng").show();
}
}
resize(true);
</script>

@ -201,8 +201,8 @@
$(".payment_rest_way").click(function(){
$(this).children("img").attr("src","__IMG__/pay_way/dagou2.png");
$(this).siblings(".payment_rest_way").children("img").attr("src","__IMG__/pay_way/dagou1.png");
let img=$(this).children("div").children("img").attr("src");
let text = $(this).children("div").children("span").text();
var img=$(this).children("div").children("img").attr("src");
var text = $(this).children("div").children("span").text();
//获取支付参数
payway = $(this).data("type");
payurl = $(this).data("url");

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save