78 行
2.7 KiB
PHP
可执行文件
78 行
2.7 KiB
PHP
可执行文件
<?php
|
|
namespace Admin\Controller;
|
|
use Think\Controller;
|
|
use Think\Verify;
|
|
//[1.1.96]
|
|
class OfficialController extends BaseController {
|
|
/* 加载模板 */
|
|
public function index()
|
|
{
|
|
$user = I('session.admin_userinfo');
|
|
if(!$user){
|
|
$this->error('你无权操作');
|
|
exit;
|
|
}
|
|
$find = M('partner_wxconfig')->where(array('partner_id'=>$user['id']))->find();
|
|
$this->assign('data',$find);
|
|
$arr = array(
|
|
'update' => '/index.php/Admin/Official/update', //修改
|
|
);
|
|
$authArr = checkFunction($arr);
|
|
$this->assign('authArr', $authArr);
|
|
$this->display();
|
|
}
|
|
|
|
/* 更新 */
|
|
public function update()
|
|
{
|
|
$user = I('session.admin_userinfo');
|
|
$official_name = I('post.official_name');
|
|
$appid = I('post.appid');
|
|
$appsecret = I('post.appsecret');
|
|
$id = I('post.id');
|
|
if(!$official_name || !$appid || !$appsecret || $id == ''){
|
|
$res['status'] = 0;
|
|
$res['msg'] = '参数缺失';
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if($id == 0){ // 新添加一条
|
|
$data['official_name'] = $official_name;
|
|
$data['appid'] = $appid;
|
|
$data['appsecret'] = $appsecret;
|
|
$data['partner_id'] = $user['id'];
|
|
$data['addtime'] = time();
|
|
$add = M('partner_wxconfig')->add($data);
|
|
if($add){
|
|
$res['status'] = 1;
|
|
$res['msg'] = '添加成功';
|
|
}else{
|
|
$res['status'] = 0;
|
|
$res['msg'] = '添加失败';
|
|
}
|
|
}else{
|
|
$find = M('partner_wxconfig')->where(array('id'=>$id,'partner_id'=>$user['id']))->find();
|
|
if(!$find){
|
|
$res['status'] = 0;
|
|
$res['msg'] = '查询失败';
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if($official_name != $find['official_name']){ $up['official_name'] = $official_name; }
|
|
if($appid != $find['appid']){ $up['appid'] = $appid; }
|
|
if($appsecret != $find['appsecret']){ $up['appsecret'] = $appsecret; }
|
|
if(!$up){
|
|
$res['status'] = 0;
|
|
$res['msg'] = '请先修改数据';
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$save = M('partner_wxconfig')->where(array('id'=>$id))->save($up);
|
|
if($save){
|
|
$res['status'] = 1;
|
|
$res['msg'] = '修改成功';
|
|
}else{
|
|
$res['status'] = 0;
|
|
$res['msg'] = '修改成功';
|
|
}
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
} |