|
@@ -134,6 +134,26 @@ class Index extends Api
|
|
|
$this->success(1,$list);
|
|
|
}
|
|
|
|
|
|
+ //首页搜索
|
|
|
+ public function search_user(){
|
|
|
+ $keyword = input('keyword','');
|
|
|
+ if(empty($keyword)){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+
|
|
|
+ $where = [];
|
|
|
+ if(is_numeric($keyword)){
|
|
|
+ $where['username'] = intval($keyword);
|
|
|
+ }else{
|
|
|
+ $where['nickname'] = ['LIKE','%'.trim($keyword).'%'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = Db::name('user')->field('id,username,nickname,gender,avatar')->where($where)->limit(100)->select();
|
|
|
+ $list = list_domain_image($list,['avatar']);
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|