From 1f1e75e73696c44e840105ed3d06ef8ebb370cfe Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 13 Feb 2020 13:00:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A8=E5=B9=BF=E5=85=AC?= =?UTF-8?q?=E5=8F=B8=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PromoteCompanyController.class.php | 76 ++++------------- .../Admin/View/PromoteCompany/add.html | 83 ++++++++++++++++++- Public/static/czinputcheck.js | 80 ++++++++++++++++++ 3 files changed, 177 insertions(+), 62 deletions(-) create mode 100644 Public/static/czinputcheck.js diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 1038af82a..066eeff44 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -80,77 +80,35 @@ class PromoteCompanyController extends ThinkController { if ($_POST) { $company_name = I('post.company_name', ''); - $status = intval(I('post.status', 1)); - - if (empty($company_name)) { - $this->error('请输入推广公司名称'); - } - if (empty(I('post.settlement_contact'))) { - $this->error('请输入结算联系人'); - } - if (empty(I('post.contact_phone'))) { - $this->error('请输入联系人电话'); - } - $pattern = "/^1[3|4|5|6|7|8|9]\\d{9}$/i"; - if(!preg_match($pattern, I('post.contact_phone'))) { - $this->error("手机号码格式不合法"); - return false; - } - if (empty(I('post.address'))) { - $this->error('请输入所在地址'); - } - if (empty(I('post.bank_card'))) { - $this->error('请输入银行卡号'); - } - $bank_card_pattern = "/^\d{10,19}$/u"; - if (!preg_match($bank_card_pattern, I('post.bank_card'))) { - $this->error('卡号格式错误'); - return false; - } - if (empty(I('post.bank_cardname'))) { - $this->error('请输入银行卡名'); - } - if (empty(I('post.bank_name'))) { - $this->error('请输入收款银行'); - } - if (empty(I('post.bank_address'))) { - $this->error('请输入开户网点'); - } - if (!in_array($status, [0, 1])) { - $this->error('参数异常'); - } - - if (!empty(I('post.content'))) { - $save['content'] = I('post.content'); - } - $model = M($this->modelName, 'tab_'); $map['company_name'] = $company_name; $res = $model->where($map)->getField('id'); if ($res) { - $this->error('推广公司已存在'); + $this->ajaxReturn(array( + 'status' => 0, + 'info' => "推广公司已经存在" + )); } - $time = time(); - $save['company_name'] = $company_name; - $save['status'] = $status; - $save['uid'] = UID; + $save = I('post.');//前端已经验证 $save['create_time'] = $time; $save['last_up_time'] = $time; - $save['settlement_contact'] = I('post.settlement_contact'); - $save['contact_phone'] = I('post.contact_phone'); - $save['address'] = I('post.address'); - $save['bank_card'] = I('post.bank_card'); - $save['bank_cardname'] = I('post.bank_cardname'); - $save['bank_name'] = I('post.bank_name'); - $save['bank_address'] = I('post.bank_address'); - + if(isset($save['resources'])){ + $save['resources'] = json_encode($save['resources'],JSON_UNESCAPED_UNICODE); + } $res = $model->add($save); if ($res) { \Think\Log::actionLog('PromoteCompany/add', 'partner', $res); - $this->success('保存成功', U('lists')); + $array=array( + "info"=>"添加成功", + "status"=>1 + ); + $this->ajaxReturn($array); } else { - $this->error('保存失败'); + $this->ajaxReturn(array( + 'status' => 0, + 'info' => "保存失败" + )); } } else { $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'PromoteCompany/add'])->find()); diff --git a/Application/Admin/View/PromoteCompany/add.html b/Application/Admin/View/PromoteCompany/add.html index ee183364c..87220142b 100644 --- a/Application/Admin/View/PromoteCompany/add.html +++ b/Application/Admin/View/PromoteCompany/add.html @@ -2,6 +2,8 @@ + +