From 234151a9ce6a9d984cf067d4b5f151655b6c1139 Mon Sep 17 00:00:00 2001 From: zhengchanglong Date: Sun, 29 Sep 2019 15:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=B8=81=E7=BA=BF=E4=B8=8B?= =?UTF-8?q?=E5=85=85=E5=80=BC=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/CoinOrderController.class.php | 49 +++++++++++++++++-- .../View/default/CoinOrder/order_add.html | 15 +++--- .../View/default/CoinOrder/order_detail.html | 10 ++++ 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/Application/Home/Controller/CoinOrderController.class.php b/Application/Home/Controller/CoinOrderController.class.php index 9ec1c45d2..e193fc713 100644 --- a/Application/Home/Controller/CoinOrderController.class.php +++ b/Application/Home/Controller/CoinOrderController.class.php @@ -128,22 +128,27 @@ class CoinOrderController extends BaseController $data['order_status'] = 0; }else{ $data['pay_amount'] = $coin_num; - $collection_account = I("collection_account"); + $collection_account = I("collection_account",""); $pay_order_number = I("pay_order_number"); - if($collection_account==''){ + /*if($collection_account==''){ $this->ajaxReturn(['status'=>0,'info'=>'请选择汇入银行','time'=>1000],"JSON"); - } + }*/ if($pay_order_number==''){ $this->ajaxReturn(['status'=>0,'info'=>'请输入支付凭证','time'=>1000],"JSON"); } - $res = $this->upload(); + + //$res = $this->upload(); + $res = $this->uploadPicture(); + if($res['status']==0){ + $this->ajaxReturn(['status'=>0,'info'=>'请选择支付截图','time'=>1000],"JSON"); + } if($res['error']==1){ $this->ajaxReturn(['status'=>0,'info'=>$res['msg'],'time'=>1000],"JSON"); } $data['collection_account'] = $collection_account; $data['pay_order_number'] = $pay_order_number; $data['remark'] = I("remark"); - $data['voucher_img'] = $res['path']; + $data['voucher_img'] = $res['id']; $data['order_status'] = 2; $data['pay_way'] = 3; } @@ -366,12 +371,16 @@ class CoinOrderController extends BaseController return $ret; } + public function upload(){ header("content-type:text/html;charset=utf-8"); //设置时区 #date_default_timezone_set('PRC'); //获取文件名 $filename = $_FILES['file']['name']; + if(!$filename){ + return array("error"=>1,"msg"=>"请选择支付截图"); + } //获取文件临时路径 $temp_name = $_FILES['file']['tmp_name']; //获取大小 @@ -408,6 +417,36 @@ class CoinOrderController extends BaseController } } + /** + * 上传图片 + * @author huajie + */ + public function uploadPicture(){ + /* 返回标准数据 */ + $result = array('status' => 1, 'info' => '上传成功', 'data' => ''); + + /* 调用文件上传组件上传文件 */ + $Picture = D('Picture'); + $pic_driver = C('PICTURE_UPLOAD_DRIVER'); + + $info = $Picture->upload( + $_FILES, + C('PICTURE_UPLOAD'), + C('PICTURE_UPLOAD_DRIVER'), + C("UPLOAD_{$pic_driver}_CONFIG") + ); //TODO:上传到远程服务器 + /* 记录图片信息 */ + if($info){ + $result['status'] = 1; + $result = array_merge($info['voucher_img'], $result); + } else { + $result['status'] = 0; + $result['info'] = $Picture->getError(); + } + ob_clean(); + return $result; + } + public function echo_pay_qrcode($trade_no,$real_amont,$pay_amount,$qrcode_url,$type='1'){ if($type==1){ $tips = '请使用支付宝扫描二维码以完成支付'; diff --git a/Application/Home/View/default/CoinOrder/order_add.html b/Application/Home/View/default/CoinOrder/order_add.html index 492256617..93fe57060 100644 --- a/Application/Home/View/default/CoinOrder/order_add.html +++ b/Application/Home/View/default/CoinOrder/order_add.html @@ -65,7 +65,7 @@
@@ -165,7 +165,7 @@ function save_model() { var formElement = document.querySelector("#payform"); var formData = new FormData(formElement); - formData.append("file",$("input[name=voucher_img]")[0].files[0]) + formData.append("voucher_img",$("input[name=voucher_img]")[0].files[0]) jQuery.ajax({ type: 'POST', url:'index.php?s=/Home/CoinOrder/order_add.html', @@ -177,13 +177,14 @@ contentType: false, //必须 success: function (result) { if (result.status==1){ - location.reload(); if(result.pay_type==1){ - //op_w('index.php?s=/Home/CoinOrder/pay_center.html&trade_no='+result.trade_no) window.open('index.php?s=/Home/CoinOrder/pay_center.html&trade_no='+result.trade_no,"_blank"); - /*$.ajax().then(res=>{ - box.location = res - })*/ + location.reload(); + }else{ + layer.alert(result.info,function () { + parent.layer.closeAll(); + location.reload(); + }); } }else{ layer.alert(result.info); diff --git a/Application/Home/View/default/CoinOrder/order_detail.html b/Application/Home/View/default/CoinOrder/order_detail.html index f5d56cf42..1c490cf5a 100644 --- a/Application/Home/View/default/CoinOrder/order_detail.html +++ b/Application/Home/View/default/CoinOrder/order_detail.html @@ -159,6 +159,16 @@ + +
+
+ +
+ +
+
+
+