ThinkAdmin/application/index/view/wap.payjs.html
2017-05-08 15:32:43 +08:00

57 lines
2.4 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSAPI支付DEMO</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body style="text-align:center">
<div class="contrainer">
<h3>JSAPI支付DEMO</h3>
<hr/>
<p class="price">金额: 0.01</p>
<hr/>
<p class="orderno"></p>
<hr/>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10" id="test">
<button type="submit" class="btn btn-success">立即支付</button>
</div>
</div>
<a href="{:url('payqrc')}" class="btn btn-link">扫码支付测试</a>
</div>
<script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
wx.error(function (e) {
console.log(e);
});
wx.config($.parseJSON('{$jsSign|json_encode}'));
wx.ready(function () {
$.get('{:url("payjs")}', {'action': 'options'}, function (ret) {
$('.orderno').html('订单号:' + ret.order_no);
if (ret.code && ret.code === 2) {
$('#test').append('<button type="button" class="btn btn-success">已支付,刷新支付号</button>');
return $('[type="submit"]').remove();
}
$('[type="submit"]').on('click', function () {
if (ret.code && ret.code === 3) {
return alert(ret.msg);
}
wx.chooseWXPay(ret);
});
});
$('body').on('click', '[type="button"]', function () {
$.get('{:url("payjs")}', {'action': 'reset'}, function () {
window.location.reload();
});
});
});
</script>
</body>
</html>