Merge remote-tracking branch 'bb/master'
This commit is contained in:
commit
5be1a4b2c1
@ -44,7 +44,7 @@ class Article extends BaseController
|
||||
$category_id =$params['category_id'];
|
||||
|
||||
if($category_id){
|
||||
$map[] = ['category_id','=',$category_id];
|
||||
$map[] = ['category_id','in',$category_id];
|
||||
}else{
|
||||
$map = [];
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class Life extends BaseController
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$params= get_params();
|
||||
$params['category_id']=$this->category_id;
|
||||
$params['category_id'] = Db::table('fa_category')->where(['status' => 'normal', 'pid' => '360'])->column('id');
|
||||
(new Article())->index($params);
|
||||
}
|
||||
return view('nk/life/index',['url'=>$this->url]);
|
||||
@ -47,7 +47,6 @@ class Life extends BaseController
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$param= get_params();
|
||||
$param['category_id']=$this->category_id;
|
||||
|
||||
// 检验完整性
|
||||
try {
|
||||
@ -112,6 +111,9 @@ class Life extends BaseController
|
||||
->field('area_id id,area_code code,area_name name')
|
||||
->select();
|
||||
View::assign('street', $street);
|
||||
// 分类
|
||||
$category = Db::table('fa_category')->where(['status' => 'normal', 'pid' => '360'])->select();
|
||||
View::assign('category', $category);
|
||||
return view('nk/life/add');
|
||||
}
|
||||
}
|
||||
@ -175,6 +177,9 @@ class Life extends BaseController
|
||||
->field('area_id id,area_code code,area_name name')
|
||||
->select();
|
||||
View::assign('street', $street);
|
||||
// 分类
|
||||
$category = Db::table('fa_category')->where(['status' => 'normal', 'pid' => '360'])->select();
|
||||
View::assign('category', $category);
|
||||
return view('nk/life/edit',['url'=>$this->url]);
|
||||
}
|
||||
else{
|
||||
@ -205,6 +210,9 @@ class Life extends BaseController
|
||||
$detail['lat'] = $ress['lat'];
|
||||
$detail['lng'] = $ress['lng'];
|
||||
View::assign('detail', $detail);
|
||||
// 分类
|
||||
$category = Db::table('fa_category')->where(['status' => 'normal', 'pid' => '360'])->select();
|
||||
View::assign('category', $category);
|
||||
View::assign('admin_id', $this->adminInfo['id']);
|
||||
}
|
||||
else{
|
||||
|
@ -96,6 +96,20 @@
|
||||
|
||||
{/if}
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">分类<font>*</font></td>
|
||||
<td colspan="3">
|
||||
<div class="layui-col-md6">
|
||||
<select name="category_id" lay-verify="required" lay-search="">
|
||||
<option value="" >请选择</option>
|
||||
{volist name='category' id='vo'}
|
||||
<option value="{$vo.id}" >{$vo.name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">价格<font>*</font></td>
|
||||
<td colspan="3"><input type="text" name="price" lay-verify="required|number" lay-reqText="请输入价格"
|
||||
@ -115,12 +129,6 @@
|
||||
<input type="radio" name="is_tj" value="1" title="是" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">坐标</td>
|
||||
<td colspan="6">
|
||||
<div id="map"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
|
||||
@ -131,6 +139,13 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">坐标</td>
|
||||
<td colspan="6">
|
||||
<div id="map"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
<div class="pt-3">
|
||||
|
@ -106,6 +106,19 @@
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td class="layui-td-gray">分类<font>*</font></td>
|
||||
<td colspan="3">
|
||||
<div class="layui-col-md6">
|
||||
<select name="category_id" lay-verify="required" lay-search="">
|
||||
<option value="" >请选择</option>
|
||||
{volist name='category' id='vo'}
|
||||
<option value="{$vo.id}" {if $detail.category_id==$vo.id} selected {/if}>{$vo.name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">价格<font>*</font></td>
|
||||
@ -126,12 +139,6 @@
|
||||
<input type="radio" name="is_tj" value="1" title="是" {if $detail.is_tj=='1'} checked {/if}>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">坐标</td>
|
||||
<td colspan="6">
|
||||
<div id="map"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
|
||||
@ -142,6 +149,14 @@
|
||||
id="container_content">{$detail.content}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">坐标</td>
|
||||
<td colspan="6">
|
||||
<div id="map"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<div class="pt-3">
|
||||
<input type="hidden" name="id" value="{$detail.id}"/>
|
||||
|
@ -16,7 +16,7 @@ class Article extends BaseController
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => ['index','hot_list','getArticleList','details','indexs'] ]
|
||||
Auth::class => ['except' => ['index','hot_list','getArticleList','details','indexs','get_list','detail'] ]
|
||||
];
|
||||
|
||||
public function index($search = '', $category_id = 1, $page = 1, $is_time = 0, $category_type = 0)
|
||||
@ -837,5 +837,79 @@ class Article extends BaseController
|
||||
$this->apiSuccess('ok', ['list' => $select, 'cun'=>$cun_arr, 'count' => ['count' => $count, 'month_count' => $month_count]]);
|
||||
}
|
||||
|
||||
// 获取生活服务推荐文章列表
|
||||
public function get_list($search = '', $category_id = 360, $page = 1, $category_type = 0)
|
||||
{
|
||||
$param = get_params();
|
||||
|
||||
$all_category = Db::table('fa_category')->where(['status' => 'normal', 'pid' => $category_id])->column('id');
|
||||
if($all_category){
|
||||
$category_id = $all_category;
|
||||
}
|
||||
$where = [
|
||||
['status', '=', 1],
|
||||
['category_id', 'in', $category_id]
|
||||
];
|
||||
|
||||
if(isset($param['street_id']) && !empty($param['street_id'])){
|
||||
$where[] = ['township', '=', $param['street_id']];
|
||||
}
|
||||
if(isset($param['village_id']) && !empty($param['village_id'])){
|
||||
$where[] = ['village', '=', $param['village_id']];
|
||||
}
|
||||
$where[] = ['is_tj', '=', 1];
|
||||
//总条数
|
||||
$count = Db::table('fa_article')->where($where)->count();
|
||||
//当月条数
|
||||
$month_count = Db::table('fa_article')->where($where)->whereMonth('view_time')->count();
|
||||
if ($search != '') {
|
||||
$where[] = ['title', 'like', '%' . $search . '%'];
|
||||
}
|
||||
if ($category_type != 0) {
|
||||
$where[] = ['category_type', '=', $category_type];
|
||||
}
|
||||
foreach ($where as $key =>$value){
|
||||
$where[$key][0] = 'a.'.$value[0];
|
||||
}
|
||||
|
||||
//查询
|
||||
$select = Db::table('fa_article')->where($where)->page($page)->limit(20)
|
||||
->alias('a')
|
||||
->join(['fa_article_life' => 'l'],"a.id = l.article_id")
|
||||
->field('a.id,a.title,a.describe,a.user_id,a.view,a.view_time,a.image,a.end_time,a.is_solve,a.is_vote,a.is_nickname,a.video,a.category_type,l.price,l.star,l.lng,l.lat')
|
||||
->order('a.id DESC')->select()->toArray();
|
||||
|
||||
$this->apiSuccess('ok', ['count' => $count,'list' => $select]);
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
public function detail()
|
||||
{
|
||||
$param = get_params();
|
||||
if(empty($param['id'])){
|
||||
$this->apiError('缺少参数');
|
||||
}
|
||||
$where = [
|
||||
['a.id', '=', $param['id']],
|
||||
];
|
||||
|
||||
//查询
|
||||
$select = Db::table('fa_article')->where($where)
|
||||
->alias('a')
|
||||
->join(['fa_article_life' => 'l'],"a.id = l.article_id")
|
||||
->field('a.id,a.title,a.category_id,a.describe,a.user_id,a.view,a.view_time,a.image,a.end_time,a.is_solve,a.is_vote,a.is_nickname,a.video,a.category_type,l.price,l.star,l.lng,l.lat')
|
||||
->withAttr('category', function ($data, $value) {
|
||||
if ($value['category_id'] != 0) {
|
||||
$find = Db::table('fa_category')->where('id', $value['category_id'])->find();
|
||||
return $find['name'];
|
||||
}else{
|
||||
return '';
|
||||
}
|
||||
})
|
||||
->find();
|
||||
|
||||
$this->apiSuccess('获取成功', ['list' => $select]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user