diff --git a/app/admin/controller/nk/Life.php b/app/admin/controller/nk/Life.php new file mode 100644 index 0000000..282772a --- /dev/null +++ b/app/admin/controller/nk/Life.php @@ -0,0 +1,224 @@ +adminInfo = get_login_admin(); + $this->category_id=360; + $this->url=[ + '/admin/nk.life/index?category_id='.$this->category_id, + '/admin/nk.life/add', + '/admin/nk.life/edit', + '/admin/nk.life/del', + '/admin/nk.life/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/life/index',['url'=>$this->url]); + } + /** + * 添加 + */ + public function add() + { + if (request()->isAjax()) { + $param= get_params(); + $param['category_id']=$this->category_id; + + // 检验完整性 + try { + validate(\app\admin\validate\nk\ArticleValidate::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find(); + if($this->adminInfo['position_id'] != 1) { //不是超级管理员 + $param['county']=$adds['area_id']; + $param['township']=$adds['street_id']; + $param['village']=$adds['village_id']; + $param['user_id']=$adds['user_id']; + }else{ + if(empty($param['county'])){ + $param['county']=$adds['area_id']; + } + if(empty($param['township'])){ + $param['township']=$adds['street_id']; + } + if(empty($param['village'])){ + $param['village']=$adds['village_id']; + } + if(empty($param['user_id'])){ + $param['user_id']=$adds['user_id']; + } + } + + $param['view_time']=date('Y-m-d H:i:s'); + if(empty($param['category_type'])){ + $param['category_type'] = 0; + } + if(empty($param['end_time'])){ + $param['end_time'] = date('Y-m-d H:i:s'); + } + + $res=Db::table('fa_article')->strict(false)->field(true)->insertGetId($param); + if ($res){ + if(!empty($param['is_vote']) && $param['is_vote']==1){ + $data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$res,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']]; + Db::table('fa_article_vote_side_tables')->insert($data); + } +// 写入关联表 + $life_data['article_id'] = $res; + $life_data['price'] = $param['price']; + $life_data['star'] = rtrim($param['star'],'星'); + $life_data['lat'] = $param['lat']; + $life_data['lng'] = $param['lng']; + Db::table('fa_article_life')->strict(false)->field(true)->insert($life_data); + return to_assign(0,'操作成功',['aid'=>$res]); + } + return to_assign(1, '操作失败,原因:'.$res); +// (new Article())->add($params); + }else{ + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + // 获取用户信息 + $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select(); + View::assign('users', $this->users); + $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500']) + ->field('area_id id,area_code code,area_name name') + ->select(); + View::assign('street', $street); + return view('nk/life/add'); + } + } + /** + * 修改 + */ + public function edit(){ + $param= get_params(); + if (request()->isAjax()) { + try { + validate(\app\admin\validate\nk\ArticleValidate::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + + $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find(); + if($this->adminInfo['position_id'] == 1) { //是超级管理员 + if(empty($param['county'])){ + $param['county']=$adds['area_id']; + } + if(empty($param['township'])){ + $param['township']=$adds['street_id']; + } + if(empty($param['village'])){ + $param['village']=$adds['village_id']; + } + if(empty($param['user_id'])){ + $param['user_id']=$adds['user_id']; + } + } + + $res=Db::table('fa_article')->where('id',$param['id'])->strict(false)->field(true)->update($param); + + if(!empty($param['is_vote']) && $param['is_vote']==1){ + Db::table('fa_article_vote_side_tables')->where('article_id',$param['id'])->update(['end_time'=>$param['end_time']]); + } + // 写入关联表 + $life_data['price'] = $param['price']; + $life_data['star'] = rtrim($param['star'],'星'); + $life_data['lat'] = $param['lat']; + $life_data['lng'] = $param['lng']; + Db::table('fa_article_life')->where('article_id',$param['id'])->update($life_data); + return to_assign(); + + }else{ + $id = isset($param['id']) ? $param['id'] : 0; + $detail = Db::table('fa_article')->where('id',$id)->find(); + View::assign('editor', get_system_config('other','editor')); + if (!empty($detail)) { + $ress = Db::table('fa_article_life')->where('article_id',$param['id'])->find(); + $detail['price'] = $ress['price']; + $detail['star'] = $ress['star']; + $detail['lat'] = $ress['lat']; + $detail['lng'] = $ress['lng']; + View::assign('detail', $detail); + // 获取用户信息 + $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select(); + View::assign('users', $this->users); + $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500']) + ->field('area_id id,area_code code,area_name name') + ->select(); + View::assign('street', $street); + return view('nk/life/edit',['url'=>$this->url]); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + } + + + /** + * 查看信息 + */ + public function read() + { + $param = get_params(); + $id = isset($param['id']) ? $param['id'] : 0; + $detail = Db::table('fa_article')->where('id',$id)->find(); + if (!empty($detail)) { + $detail['comment'] = Db::table('fa_article_comment') + ->where('vote_id',$id) + ->withAttr('user_info',function ($value,$data){ + return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name'); + }) + ->select(); + $ress = Db::table('fa_article_life')->where('article_id',$param['id'])->find(); + $detail['price'] = $ress['price']; + $detail['star'] = $ress['star']; + $detail['lat'] = $ress['lat']; + $detail['lng'] = $ress['lng']; + View::assign('detail', $detail); + View::assign('admin_id', $this->adminInfo['id']); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + return view('nk/life/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/view/nk/life/add.html b/app/admin/view/nk/life/add.html new file mode 100644 index 0000000..b5c8623 --- /dev/null +++ b/app/admin/view/nk/life/add.html @@ -0,0 +1,295 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

新建文章

+ + + + + + {notempty name="is_vote"} + + + + + {/notempty} + + + + + + + + {if {:session('gougu_admin')['group_access']==1} + + + + + + + + + + + + + + + + + + + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + +
文章标题*
结束时间* + +
文章摘要 + + 缩略图 +
+ +
+ + +
+
+
区县 +
+
+ +
+
+
街道/镇 +
+
+
+
+
+
村/社区 +
+
+
+
+
+
用户* +
+ +
+
价格*
星级* +
+
是否推荐* + + +
坐标 +
+
文章内容
+ +
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/life/edit.html b/app/admin/view/nk/life/edit.html new file mode 100644 index 0000000..b553246 --- /dev/null +++ b/app/admin/view/nk/life/edit.html @@ -0,0 +1,318 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

编辑文章表

+ + + + + + {notempty name="is_vote"} + + + + + {/notempty} + + + + + + + + {if {:session('gougu_admin')['group_access']==1} + + + + + + + + + + + + + + + + + + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + +
文章标题*
结束时间* + +
摘要 + + 缩略图 +
+ +
+ + +
+
+
区县 +
+
+ +
+
+
街道/镇 +
+
+
+
+
+
村/社区 +
+
+
+
+
+
用户* +
+ +
+
价格*
星级* +
+
是否推荐* + + +
坐标 +
+
文章内容
+ +
+
+ + + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/life/index.html b/app/admin/view/nk/life/index.html new file mode 100644 index 0000000..9af757a --- /dev/null +++ b/app/admin/view/nk/life/index.html @@ -0,0 +1,144 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/life/read.html b/app/admin/view/nk/life/read.html new file mode 100644 index 0000000..a538693 --- /dev/null +++ b/app/admin/view/nk/life/read.html @@ -0,0 +1,113 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

文章详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {if in_array($detail.category_id,[149,157,158,148,147,165]) } + + + + + {/if} + + {if in_array($detail.category_id,[149,157,158,148,147,165]) } + + + + + {/if} + + +
文章标题{$detail.title}
创建时间{$detail.view_time}状态 + {eq name="$detail.status" value="1"}正常{/eq} + {eq name="$detail.status" value="0"}下架{/eq} +
文章摘要{$detail.describe}
价格{$detail.price}"
星级 +
{$detail.star} 星
+
坐标 +

经度:{$detail.lng}

+

纬度:{$detail.lat}

+
文章内容 + {$detail.content|raw} +
回复内容: + {volist name="$detail.comment" id="vo"} + {$vo.user_info}的回复:{$vo.content}
+ {/volist} +
回复: + +
+ {if in_array($detail.category_id,[149,157,158,148,147,165]) } +
+ + + + +
+ {/if} +
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/slideinfo/add.html b/app/admin/view/nk/slideinfo/add.html index 739ed3b..237a79d 100644 --- a/app/admin/view/nk/slideinfo/add.html +++ b/app/admin/view/nk/slideinfo/add.html @@ -58,8 +58,8 @@ - 跳转路径* - 跳转路径 + diff --git a/app/admin/view/nk/slideinfo/edit.html b/app/admin/view/nk/slideinfo/edit.html index c41e4b4..018900b 100644 --- a/app/admin/view/nk/slideinfo/edit.html +++ b/app/admin/view/nk/slideinfo/edit.html @@ -58,7 +58,7 @@ - 跳转路径* + 跳转路径 diff --git a/app/api/controller/Slide.php b/app/api/controller/Slide.php index 5204a59..4912f2f 100644 --- a/app/api/controller/Slide.php +++ b/app/api/controller/Slide.php @@ -18,7 +18,7 @@ class Slide extends BaseController * @var array */ protected $middleware = [ - Auth::class => ['except' => ['get_slide'] ] + Auth::class => ['except' => ['get_slide','get_slide_two'] ] ]; /** * 获取轮播 @@ -52,4 +52,28 @@ class Slide extends BaseController } } + //获取轮播,不管区域 + public function get_slide_two() + { + $township = get_params('township'); // 乡镇 + if($township){ + $where['township'] = $township; + } + $slide_id = get_params('slide_id'); // 位置 + if($slide_id){ + $where['slide_id'] = $slide_id; + } + $where['status'] = 1; + $list = Db::table('fa_slide_info')->where($where) + ->order('sort desc') + ->select(); + $is_arr = $list->toarray(); + if($is_arr){ + $this->apiSuccess('获取成功',$list); + }else{ + $this->apiError('暂无数据',[]); + } + } + + }