Commit a2a16aea by LiuJunYi

美行者BUG

parent f06a2356
......@@ -24,8 +24,8 @@ class Project extends AuthBase
public function _initialize()
{
$this->project_model = model("project");
$this->tag_model = model("Tags");
$this->city_model = model("Citys");
$this->tag_model = model("Tags");
$this->city_model = model("Citys");
$this->catalog_model = model("Catalogs");
$this->appoint_model = model("Reservations");
parent::_initialize();
......@@ -34,10 +34,10 @@ class Project extends AuthBase
//活动列表
public function index()
{
$title = input('get.title');
$type = input('get.type');
$title = input('get.title');
$type = input('get.type');
$catalog_id = input('get.catalog_id');
$condition = [];
$condition = [];
if ($title) {
$condition['title'] = ['like', "%" . $title . "%"];
}
......@@ -52,7 +52,7 @@ class Project extends AuthBase
$project_list =
$this->project_model
->where($condition)
->order('sort','desc')
->order('sort', 'desc')
->order('id desc')
->paginate(10, false, ['query' => ['title' => $title, 'type' => $type, 'catalog_id' => $catalog_id]]);
$this->assign('project_list', $project_list);
......@@ -67,37 +67,38 @@ class Project extends AuthBase
// 引入上传类
$upload = new Upload();
$file = input('file.');
$data = input('post.');
$poster = '';
$file = input('file.');
$data = input('post.');
$poster = '';
$kf_qrcode = '';
$banners = [];
$banners = [];
//如果是商家则保存客服二维码
if ($data['type'] == 2) {
$result = $upload->sava($file['kf_qrcode']);
if (!$result['error']) {
$kf_qrcode = $result['result']['url'];
$file = request()->file('kf_qrcode');
$info = $file->move('./upload/qrcode/');
if ($info) {
$kf_qrcode = "/upload/qrcode/" . $info->getSaveName();
$data['kf_qrcode'] = $kf_qrcode;
}
}
//保存封面
$result = $upload->sava($file['poster']);
$result = $upload->sava(input('file.poster'));
if (!$result['error']) {
$poster = $result['result']['url'];
$poster = $result['result']['url'];
$data['poster'] = $poster;
}
//遍历banner数组并保存
foreach ($file['banners'] as $name => $f) {
foreach (input('file.banners') as $name => $f) {
$result = $upload->sava($f);
if (!$result['error']) {
$banners[] = $result['result']['url'];
$banners[] = $result['result']['url'];
$data['banners'] = json_encode($banners);
}
}
//去除null
foreach($data as $k=>$v){
if($v==='null'){
foreach ($data as $k => $v) {
if ($v === 'null') {
unset($data[$k]);
}
}
......@@ -122,10 +123,11 @@ class Project extends AuthBase
}
}
//删除项目、商家
public function delete()
{
$id = input('post.id');
$id = input('post.id');
$used = model('Orders')->where('pid', $id)->count();
// if ($used > 0) {
// $this->error('该项目已有用户下单,不可删除!', '', '', 1);
......@@ -144,26 +146,26 @@ class Project extends AuthBase
{
if (request()->isPost()) {
// 引入上传类
$id = input('post.id');
$upload = new Upload();
$file = input('file.');
$data = input('post.');
$data = array_merge(array_diff($data, array('id' => $id)));
$poster = '';
$kf_qrcode = '';
$banners = [];
$id = input('post.id');
$upload = new Upload();
$file = input('file.');
$data = input('post.');
$data = array_merge(array_diff($data, array('id' => $id)));
$poster = '';
$kf_qrcode = '';
$banners = [];
$project_info = $this->project_model->find($id);
$old_banners = json_decode($project_info['banners_native']);
$old_poster = $project_info['poster'];
$old_banners = json_decode($project_info['banners_native']);
$old_poster = $project_info['poster'];
$old_kf_qrcode = $project_info['kf_qrcode'];
//如果是商家则保存客服二维码
if ($data['type'] == 2) {
if (input('file.kf_qrcode')) {
$file = request()->file('kf_qrcode');
$info = $file->move('./static/qrcode/');
$info = $file->move('./upload/qrcode/');
if ($info) {
$kf_qrcode = "/static/qrcode/".$info->getSaveName();
$kf_qrcode = "/upload/qrcode/" . $info->getSaveName();
$data['kf_qrcode'] = $kf_qrcode;
}
}
......@@ -172,7 +174,7 @@ class Project extends AuthBase
if (input('file.poster')) {
$result = $upload->sava(input('file.poster'));
if (!$result['error']) {
$poster = $result['result']['url'];
$poster = $result['result']['url'];
$data['poster'] = $poster;
}
}
......@@ -189,8 +191,8 @@ class Project extends AuthBase
}
//去除null
foreach($data as $k=>$v){
if($v==='null'){
foreach ($data as $k => $v) {
if ($v === 'null') {
unset($data[$k]);
}
}
......@@ -209,7 +211,7 @@ class Project extends AuthBase
//反显,处理项目/商品已使用标签
$value = $project_info->tags_id_str;
$value = trim($value, '|');
$tags = explode('|', $value);
$tags = explode('|', $value);
$this->assign('tags', $tags);
//反显,读取所有tags
$tag_list = $this->tag_model->order('sort', 'asc')->select();
......@@ -227,8 +229,8 @@ class Project extends AuthBase
// 标签管理
public function tags()
{
$title = input('get.name', '');
$tag_list = $this->tag_model->where('name', 'like', "%" . $title . "%")->order('sort', 'desc')->order('id','desc')->paginate(15);
$title = input('get.name', '');
$tag_list = $this->tag_model->where('name', 'like', "%" . $title . "%")->order('sort', 'desc')->order('id', 'desc')->paginate(15);
$this->assign("tag_list", $tag_list);
return $this->fetch('');
}
......@@ -236,7 +238,7 @@ class Project extends AuthBase
//添加标签
public function addTag()
{
$data = array(
$data = array(
'name' => trim(input('post.name')),
'sort' => input('post.sort', 0),
);
......@@ -264,9 +266,9 @@ class Project extends AuthBase
//修改标签
public function updateTag()
{
$id = input('post.id');
$data = array(
'id' => $id,
$id = input('post.id');
$data = array(
'id' => $id,
'name' => trim(input('post.name')),
'sort' => input('post.sort', 0)
);
......@@ -286,7 +288,7 @@ class Project extends AuthBase
//删除标签
public function deleteTag()
{
$id = input('post.id');
$id = input('post.id');
$used = $this->project_model->where('tags', 'like', "%" . '|' . $id . '|' . "%")->count();
if ($used > 0) {
$this->error('该标签已在项目中引用,不可删除!', '', '', 1);
......@@ -303,7 +305,7 @@ class Project extends AuthBase
public function appoint()
{
$title = input('get.name', '');
$items = $this->appoint_model->where('nickname', 'like', "%" . $title . "%")->order('id', 'desc')->paginate(15, false, ['query' => ['nickname' => $title]])->each(function($item){
$items = $this->appoint_model->where('nickname', 'like', "%" . $title . "%")->order('id', 'desc')->paginate(15, false, ['query' => ['nickname' => $title]])->each(function ($item) {
$project = \app\common\model\Project::withTrashed()->find($item['pid']);
$item['project_poster'] = $project['poster'];
$item['project_title'] = $project['title'];
......@@ -315,8 +317,8 @@ class Project extends AuthBase
// 城市管理
public function citys()
{
$title = input('get.name', '');
$tag_list = $this->city_model->where('name', 'like', "%" . $title . "%")->order('sort', 'desc')->order('id','desc')->paginate(15);
$title = input('get.name', '');
$tag_list = $this->city_model->where('name', 'like', "%" . $title . "%")->order('sort', 'desc')->order('id', 'desc')->paginate(15);
$this->assign("tag_list", $tag_list);
return $this->fetch('');
}
......@@ -324,7 +326,7 @@ class Project extends AuthBase
//添加城市
public function addCity()
{
$data = array(
$data = array(
'name' => trim(input('post.name')),
'sort' => input('post.sort', 0),
);
......@@ -352,9 +354,9 @@ class Project extends AuthBase
//编辑城市
public function updateCity()
{
$id = input('post.id');
$data = array(
'id' => $id,
$id = input('post.id');
$data = array(
'id' => $id,
'name' => trim(input('post.name')),
'sort' => input('post.sort', 0)
);
......@@ -374,7 +376,7 @@ class Project extends AuthBase
//删除城市
public function deleteCity()
{
$id = input('post.id');
$id = input('post.id');
$used = $this->project_model->where('city', $id)->count();
if ($used > 0) {
$this->error('该城市已在项目中引用,不可删除!', '', '', 1);
......@@ -391,7 +393,7 @@ class Project extends AuthBase
// 分类管理
public function catalogs()
{
$title = input('get.name', '');
$title = input('get.name', '');
$tag_list = $this->catalog_model->where('name', 'like', "%" . $title . "%")->order('sort', 'asc')->paginate(15, false, ['query' => ['name' => $title]]);
$this->assign("tag_list", $tag_list);
return $this->fetch('');
......@@ -401,9 +403,9 @@ class Project extends AuthBase
public function addCatalogs()
{
if (request()->isPost()) {
$data = array(
'name' => trim(input('post.name')),
'sort' => input('post.sort', 0),
$data = array(
'name' => trim(input('post.name')),
'sort' => input('post.sort', 0),
'poster' => input('file.poster')
);
$validate = validate('Project');
......@@ -417,7 +419,7 @@ class Project extends AuthBase
return view();
}
$data['poster'] = $result['result']['url'];
$res = $this->catalog_model->data($data)->save();
$res = $this->catalog_model->data($data)->save();
if (!$res) {
$this->error('添加失败', $_SERVER["HTTP_REFERER"], '', 1);
} else {
......@@ -442,9 +444,9 @@ class Project extends AuthBase
//编辑分类
public function updateCatalogs()
{
$id = input('post.id');
$data = array(
'id' => $id,
$id = input('post.id');
$data = array(
'id' => $id,
'name' => trim(input('post.name')),
'sort' => input('post.sort', 0)
);
......@@ -474,7 +476,7 @@ class Project extends AuthBase
//删除分类
public function deleteCatalog()
{
$id = input('post.id');
$id = input('post.id');
$used = $this->project_model->where('catalog_id', $id)->count();
if ($used > 0) {
$this->error('该分类下有项目,不可删除!', '', '', 1);
......@@ -491,12 +493,12 @@ class Project extends AuthBase
// 处理删除某一张bannner图
public function deleteBanners()
{
$id = input('post.id');
$address = input('post.address');
$id = input('post.id');
$address = input('post.address');
$project_info = $this->project_model->find($id);
$banners = json_decode($project_info['banners_native']);
$new_banners = array_merge(array_diff($banners, array($address)));
$up_res = 0;
$banners = json_decode($project_info['banners_native']);
$new_banners = array_merge(array_diff($banners, array($address)));
$up_res = 0;
if ($new_banners != $banners) {
$up_res = $this->project_model->save([
'banners' => json_encode($new_banners)
......@@ -504,29 +506,30 @@ class Project extends AuthBase
}
if ($up_res) {
return array(
'success' => '成功删除该图',
'data' => input('post.'),
'success' => '成功删除该图',
'data' => input('post.'),
'old_banners' => $banners,
'new_banner' => $new_banners,
'new_banner' => $new_banners,
);
} else {
return array(
'error' => '删除失败,该图片不存在或已经被删除',
'data' => input('post.'),
'error' => '删除失败,该图片不存在或已经被删除',
'data' => input('post.'),
'old_banners' => $banners,
'new_banner' => $new_banners,
'new_banner' => $new_banners,
);
}
}
//设置置顶排序
public function setHeat(){
public function setHeat()
{
$heat = input('post.heat');
$id = input('post.id');
$res = model('project')->save(['heat'=>$heat],['id'=>$id]);
if($res){
$id = input('post.id');
$res = model('project')->save(['heat' => $heat], ['id' => $id]);
if ($res) {
$this->success('开启成功');
}else{
} else {
$this->success('开启失败');
}
}
......@@ -535,7 +538,7 @@ class Project extends AuthBase
public function setSort()
{
$project = new \app\common\model\Project();
$project->allowField('id','sort')->update(input('post.'));
$project->allowField('id', 'sort')->update(input('post.'));
halt($project->getLastSql());
}
}
......@@ -421,7 +421,7 @@ $(function(){
});
} else {
showDialog("提示", data['msg'], function () {
$("#btn-save").removeAttr("disabled");
// $("#btn-save").removeAttr("disabled");
});
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment