|
@@ -9,6 +9,8 @@ |
|
@@ -9,6 +9,8 @@ |
9
|
namespace api\home\controller;
|
9
|
namespace api\home\controller;
|
10
|
|
10
|
|
11
|
use cmf\controller\RestBaseController;
|
11
|
use cmf\controller\RestBaseController;
|
|
|
12
|
+use think\Db;
|
|
|
13
|
+use think\Validate;
|
12
|
/**
|
14
|
/**
|
13
|
* @title 首页
|
15
|
* @title 首页
|
14
|
*/
|
16
|
*/
|
|
@@ -110,4 +112,54 @@ class IndexController extends RestBaseController |
|
@@ -110,4 +112,54 @@ class IndexController extends RestBaseController |
110
|
$this->success('成功',$arr);
|
112
|
$this->success('成功',$arr);
|
111
|
}
|
113
|
}
|
112
|
|
114
|
|
|
|
115
|
+ /**
|
|
|
116
|
+ * @title 搜索产品系列(若没有数据提示:暂无数据,请联系客服)
|
|
|
117
|
+ * @description 接口说明
|
|
|
118
|
+ * @author 开发者
|
|
|
119
|
+ * @url /api/home/index/searchSeriesList
|
|
|
120
|
+ * @method GET
|
|
|
121
|
+ *
|
|
|
122
|
+ * @param name:language type:string require:0 default: other desc:语言切换(英文传递此字段(en),中文无需传递)
|
|
|
123
|
+ * @param name:keyword type:string require:1 default: other desc:关键字
|
|
|
124
|
+ * @param name:page type:inter require:1 default: other desc:分页页码
|
|
|
125
|
+ *
|
|
|
126
|
+ * @return data:产品系列列表@
|
|
|
127
|
+ * @data id:产品系列id thumbnail:图片路径 title:系列名称
|
|
|
128
|
+ *
|
|
|
129
|
+ * @return count_page:总页码
|
|
|
130
|
+ */
|
|
|
131
|
+ public function searchSeriesList(){
|
|
|
132
|
+ $language = $this->request->param('language');
|
|
|
133
|
+ $keyword = $this->request->param('keyword');
|
|
|
134
|
+ $page = $this->request->param('page');//分页
|
|
|
135
|
+ //验证
|
|
|
136
|
+ $rule = config('site.search');
|
|
|
137
|
+ $validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
138
|
+ if (!$validate->check(['keyword'=>$keyword,'page'=>$page])) {
|
|
|
139
|
+ $this->error($validate->getError());
|
|
|
140
|
+ }
|
|
|
141
|
+
|
|
|
142
|
+ if(isset($language) && !empty($language)){
|
|
|
143
|
+ //英文
|
|
|
144
|
+ $field_series = 'id,thumbnail,title_en title';
|
|
|
145
|
+ $where = ['title_en'=>['like','%'.$keyword.'%']];
|
|
|
146
|
+ }else{
|
|
|
147
|
+ //中文
|
|
|
148
|
+ $field_series = 'id,thumbnail,title';
|
|
|
149
|
+ $where = ['title'=>['like','%'.$keyword.'%']];
|
|
|
150
|
+ }
|
|
|
151
|
+ //查找二级分类
|
|
|
152
|
+ $limit = CommonController::series_limit;
|
|
|
153
|
+ $res = Db::name('series')
|
|
|
154
|
+ ->where($where);
|
|
|
155
|
+ $data = $res->field($field_series)
|
|
|
156
|
+ ->page($page,$limit)
|
|
|
157
|
+ ->order('id desc')
|
|
|
158
|
+ ->select()
|
|
|
159
|
+ ->toArray();
|
|
|
160
|
+ $count = $res->count()/$limit;
|
|
|
161
|
+ $count_page = ceil($count/$limit);
|
|
|
162
|
+ $this->success('成功',['data'=>$data,'count_page'=>$count_page]);
|
|
|
163
|
+ }
|
|
|
164
|
+
|
113
|
} |
165
|
} |