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