From 74c420f2f3aec9e73acd53811fbbfb8c562beda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 14 Apr 2017 17:56:39 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=94=AF=E4=BB=98demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/controller/Wap.php | 3 +++ application/index/view/wap.payjs.html | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/application/index/controller/Wap.php b/application/index/controller/Wap.php index 7f42da31e..51fffa192 100644 --- a/application/index/controller/Wap.php +++ b/application/index/controller/Wap.php @@ -67,6 +67,9 @@ class Wap extends BasicWechat { } $pay = &load_wechat('pay'); $options = PayService::createWechatPayJsPicker($pay, $this->openid, $order_no, 1, 'JSAPI支付测试'); + if ($options === false) { + $options = ['code' => 3, 'msg' => "创建支付失败,{$pay->errMsg}[$pay->errCode]"]; + } return json($options); case 'reset': session('pay-test-order-no', null); diff --git a/application/index/view/wap.payjs.html b/application/index/view/wap.payjs.html index 9afa31a38..ebc83f36d 100644 --- a/application/index/view/wap.payjs.html +++ b/application/index/view/wap.payjs.html @@ -17,7 +17,7 @@

订单号:13412341234


-
+
@@ -35,9 +35,21 @@ wx.ready(function () { $('[type="submit"]').on('click', function () { $.get('{:url("payjs")}', {'action': 'options'}, function (ret) { + if (ret.code && ret.code === 2) { + $('#test').append(''); + return $('[type="submit"]').remove(); + } + if (ret.code && ret.code === 3) { + return alert(ret.msg); + } wx.chooseWXPay(ret); }); }); + $('body').on('click', '[type="button"]', function () { + $.get('{:url("payqrc")}', {'action': 'reset'}, function () { + window.location.reload(); + }); + }); }); \ No newline at end of file