From ca2d74ce5ba591887b15f49540a664ccac4cf850 Mon Sep 17 00:00:00 2001 From: tpingzhang <635929049@qq.com> Date: Wed, 13 Nov 2019 19:43:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=B8=81=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=20=20ajax=20=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Sdk/Common/function.php | 8 ++++++++ Application/Sdk/Controller/PayH5Controller.class.php | 8 ++++---- Application/Sdk/View/default/UserH/platform_pay.html | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Application/Sdk/Common/function.php b/Application/Sdk/Common/function.php index a8ebd7fc..0e2e1030 100644 --- a/Application/Sdk/Common/function.php +++ b/Application/Sdk/Common/function.php @@ -254,3 +254,11 @@ function re_msg($code=200,$msg='',$data=[]) exit(); } +function jsonOutput($status=0, $msg='', $data=[]) { + $ret['status'] = $status; + $ret['msg'] = $msg; + $ret['data'] = $data; + echo json_encode($ret); + exit(); +} + diff --git a/Application/Sdk/Controller/PayH5Controller.class.php b/Application/Sdk/Controller/PayH5Controller.class.php index ce09bfcb..857191fd 100644 --- a/Application/Sdk/Controller/PayH5Controller.class.php +++ b/Application/Sdk/Controller/PayH5Controller.class.php @@ -588,14 +588,14 @@ ADD COLUMN `pay_url` text NULL AFTER `check_sign`; */ public function platform_weixin_pay() { if (!$this->userId) { - $this->error("用户未登入"); + jsonOutput(0, "用户未登入"); } $request['user_id'] = $this->userId; // 支付验证 是否让支付 $payCheck = pay_check($this->userId); if (!$payCheck['code']) { - $this->error($payCheck['msg']); + jsonOutput(0, $payCheck['msg']); // echo json_encode(['code'=>0,'msg'=> $payCheck['msg']]);exit; } @@ -604,7 +604,7 @@ ADD COLUMN `pay_url` text NULL AFTER `check_sign`; $game_id = I('request.game_id'); $user_id = $request['user_id']; if($request['price']*1<=0 || $request['price'] > C('WX_PAY_LIMIT')) { - $this->new_set_message(0,"fail","充值金额有误", 3); + jsonOutput(0, "充值金额有误"); //redirect(U('Spend/notice',array('user_id'=>$user_id, 'is_platform' => 1, 'msg'=>'充值金额有误', 'game_id' => $game_id, 'user_token' => $this->userToken)));exit; } @@ -631,7 +631,7 @@ ADD COLUMN `pay_url` text NULL AFTER `check_sign`; redirect($json_data['url']); } */ }else{ - $this->new_set_message(0,"fail","支付失败", 3); + jsonOutput(0, "支付失败"); // redirect(U('Spend/notice',array('user_id'=>$user_id, 'is_platform' => 1,'game_id'=>$game_id,'msg'=>'支付失败', 'user_token' => $this->userToken)));exit; } }elseif(get_wx_pay_type() == 1){ diff --git a/Application/Sdk/View/default/UserH/platform_pay.html b/Application/Sdk/View/default/UserH/platform_pay.html index 3fe03f0b..17904163 100644 --- a/Application/Sdk/View/default/UserH/platform_pay.html +++ b/Application/Sdk/View/default/UserH/platform_pay.html @@ -72,10 +72,10 @@ $(function(){ }, success: function(r) { - if (r.status == 2) { + if (r.status == 1) { window.location.href = r.data; } else { - alert(r.info); + alert(r.msg); } }