SeriesController.php
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\HomeBaseController;
use think\Db;
class SeriesController extends HomeBaseController
{
//产品系列
//产品系列分类
public function seriesType(){
$language = $this->request->param('language');
if(isset($language) && !empty($language)){
//英文
$field_type = 'id,pid,thumbnail,name_en';
}else{
//中文
$field_type = 'id,pid,thumbnail,name';
}
$parent_res = CommonController::findSeriesType($field_type);
$this->assign('parent_res',$parent_res);
return $this->fetch();
}
//产品系列列表
public function seriesList(){
$language = $this->request->param('language');
$children_id = $this->request->param('children_id');//二级分类id
if(isset($language) && !empty($language)){
//英文
$field_series = 'id,thumbnail,title_en';
}else{
//中文
$field_series = 'id,thumbnail,title';
}
$res = Db::name('series')
->where(['t_id'=>$children_id])
->field($field_series)
->order('id desc')
->paginate(CommonController::limit,false,['query'=>request()->param()]);
$data = $res->toArray();
$data = $data['data'];
$page = $res->render();
$this->assign('res',$data);
$this->assign('page',$page);
return $this->fetch();
}
//产品系列详情
public function seriesDetail(){
$language = $this->request->param('language');
$children_id = $this->request->param('children_id');//二级分类id
$series_id = $this->request->param('series_id');//列表id
if(isset($language) && !empty($language)){
//英文
$field_series = 'id,thumbnail,title_en,detail_en,hotline';
$flag = 'name_en';
}else{
//中文
$field_series = 'id,thumbnail,title,detail,hotline';
$flag = 'name';
}
$res = CommonController::findData('series',['id'=>$series_id,'t_id'=>$children_id],$field_series);
$this->assign('res',$res);
//查找父类名称
$pid = CommonController::findData('type',['id'=>$children_id],'pid');
$parent_name = CommonController::findData('type',['id'=>$pid['pid']],$flag);
$this->assign('parent_name',$parent_name);
return $this->fetch();
}
}