request->post("type"); //产品排行 if($type == 1){ $list = Product::field('id,name,sort')->order('sort asc')->select(); // if($list){ // foreach ($list as $key=>$value){ // $list[$key]['name'] = $value['product_name']; // unset($list[$key]['product_name']); // } // } $this->success(__('成功'),$list); } //个人保险 if($type == 2){ //$list = \app\admin\model\InsurancePersonal::field('id,name,label,sort')->order('sort asc')->select(); $list = Category::where(array('pid'=>1))->select(); $new_list = []; if($list){ foreach ($list as $key=>$value){ $new_list[$key]['id'] = $value['id']; $new_list[$key]['name'] = $value['name']; $new_list[$key]['label'] = $value['nickname']; $new_list[$key]['sort'] = 0; } } $this->success(__('成功'),$new_list); } //企业保险 if($type == 3){ //$list = InsuranceEnterprise::field('id,name,label,sort')->order('sort asc')->select(); $list = Category::where(array('pid'=>3))->select(); $new_list = []; if($list){ foreach ($list as $key=>$value){ $new_list[$key]['id'] = $value['id']; $new_list[$key]['name'] = $value['name']; $new_list[$key]['label'] = $value['nickname']; $new_list[$key]['sort'] = 0; } } $this->success(__('成功'),$new_list); } //财产保险 if($type == 4){ //$list = InsuranceProperty::field('id,name,label,sort')->order('sort asc')->select(); $list = Category::where(array('pid'=>2))->select(); $new_list = []; if($list){ foreach ($list as $key=>$value){ $new_list[$key]['id'] = $value['id']; $new_list[$key]['name'] = $value['name']; $new_list[$key]['label'] = $value['nickname']; $new_list[$key]['sort'] = 0; } } $this->success(__('成功'),$new_list); } $this->error(__('参数错误')); } /** * 查询首页二级分类 */ public function getIndexSecondaryClassification(){ $first_ids = Category::where(array('pid'=>0))->order('sort desc')->field('id')->select(); $ids = array_column($first_ids, 'id'); // foreach ($first_ids as $key=>$value){ // $ids[$key] // } $secondaryList = Category::where('pid','in',$ids)->field('id,name,sort')->order('sort asc')->select(); if($secondaryList){ foreach ($secondaryList as $key=>$value){ $subordinate = Category::where(array('pid'=>$value['id']))->field('id,name,sort')->page(1,4)->select(); if($subordinate){ $last_names = array_column($subordinate,'sort'); array_multisort($last_names,SORT_ASC,$subordinate); } $secondaryList[$key]['subordinate'] = $subordinate; } } $this->success(__('成功'),$secondaryList); } /** * 查看三级分类更多列表接口 */ public function lookSecondaryList(){ $id = $this->request->post("id",0); //二级分类的id $p = input("p",0); $list = Category::where(array('pid'=>$id))->field('id,name')->order('sort asc')->page($p,20)->select(); $this->success(__('成功'),$list); } public function lookthird(){ $p = input("p",0); $first_ids = Category::where(array('pid'=>0))->order('sort desc')->field('id')->select(); $ids = array_column($first_ids, 'id'); // foreach ($first_ids as $key=>$value){ // $ids[$key] // } $secondaryList = Category::where('pid','in',$ids)->field('id')->order('sort asc')->select(); $sids = array_column($secondaryList, 'id'); $thirdlist = Category::where('pid','in',$sids)->field('id,name,sort')->order('sort asc')->select(); $this->success(__('成功'),$thirdlist); } /** * 查询产品列表接口 */ public function getProductList(){ $id = $this->request->post("id",0); //分类的id $p = $this->request->post("p",0); $list = Product::where(array('category_id'=>$id,'status'=>0))->order('sort desc')->page($p,20)->select(); if($list){ foreach ($list as $key=>$value){ $list[$key]['p_image'] = 'http://'.$_SERVER['HTTP_HOST'].'/'.$value['p_image']; $list[$key]['content'] = json_decode($value['content'],true); } } $this->success(__('成功'),$list); } /** * 获取 个人保险 企业保险 财产保险 产品 接口 */ public function getIndexUpperList(){ $type = $this->request->post("type",0); //分类的id $id = $this->request->post("id",0); $p = $this->request->post("p",0); //个人保险 // if($type == 1){ // $model = new \app\admin\model\InsurancePersonal(); // } // //企业保险 // else if($type == 2){ // $model = new InsuranceEnterprise(); // } // //财产保险 // else if($type == 3){ // $model = new InsuranceProperty(); // } // // else{ // $this->error(__('参数错误')); // } $list = Product::where(array('category_id'=>$id)) ->order('sort asc')->page($p,20)->select(); $this->success(__('成功'),$list); } /** * 获取医疗险排行榜 */ public function getMedicalList(){ $type = $this->request->post("type",0); //1 疾病意外医疗推荐排行榜 2意外伤害险推荐排行榜 $p = $this->request->post("p",1); $more = $this->request->post("more",0); //是否查看更多 if($more == 1){ //查看更多 $rows = 20; }else{ $rows = 3; } // if($type == 1){ // $where['optionlist'] = '疾病意外医疗险推荐排行榜'; // }else{ // $where['optionlist'] = '意外伤害险推荐排行榜'; // } if($type == 1){ $where['id'] = 9; }else{ $where['id'] = 22; } $list = Category::where($where)->page($p,$rows)->select(); $this->success(__('成功'),$list); } /** * 获取疾病和伤害险 产品 */ public function getIndexBelowList(){ $p = $this->request->post("p",1); $id = $this->request->post("id",1); $list = Product::where(array('category_id'=>$id))->order('sort asc') ->page($p,20)->select(); $this->success(__('成功'),$list); } /** * 获取推荐查询 一级分类 */ public function getEcommendList(){ $p = $this->request->post("p",0); $where['pid'] = 0; $list = Category::where($where)->field('id,name')->order('sort asc')->page($p,20)->select(); $this->success(__('成功'),$list); } /** * 获取推荐查询 二级分类 */ public function getEcommendList2(){ $id = $this->request->post("id",0); if(empty($id)){ $this->error('缺少id'); } $p = $this->request->post("p",0); $where['pid'] = $id; $list = Category::where($where)->field('id,name')->order('sort asc')->page($p,20)->select(); $this->success(__('成功'),$list); } /** * 获取推荐查询 三级分类 */ public function getEcommendList3(){ $id = $this->request->post("id",0); if(empty($id)){ $this->error('缺少id'); } $p = $this->request->post("p",0); $where['pid'] = $id; $list = Category::where($where)->field('id,name')->order('sort asc')->page($p,20)->select(); $this->success(__('成功'),$list); } /** * 获取险种分类 */ public function getInsuranceClassification(){ $id = $this->request->post("id",0); $p = $this->request->post("p",0); $list = Category::where(array('pid'=>$id))->field('id,name')->order('sort desc')->page($p,50)->select(); $this->success(__('成功'),$list); } /** * 推荐查询 保险列表 */ public function getInsuranceClassList(){ $category_id = $this->request->post("id",0); $p = $this->request->post("p",0); $where['category_id'] =$category_id; $where['status'] =0; $list = Product::where($where)->order('sort asc')->page($p,50)->select(); $companyModel = new Company(); if($list){ foreach ($list as $key=>$value){ $list[$key]['p_image'] = 'http://'.$_SERVER['HTTP_HOST'].'/'.$value['p_image']; $list[$key]['content'] = json_decode($value['content'],true); $list[$key]['company_name'] = $companyModel->where(array('id'=>$value['company_id']))->value('name'); if($value['attribute'] == '新上架产品'){ $list[$key]['attribute_status'] = 1; } if($value['attribute'] == '在售产品'){ $list[$key]['attribute_status'] = 2; } if($value['attribute'] == '停售产品'){ $list[$key]['attribute_status'] = 3; } } } $this->success(__('成功'),$list); } /** * 获取关于我们接口信息 */ public function getAboutInfo(){ $info['mobile'] = Config::get('about_mobile'); $info['email'] = Config::get('about_email'); $this->success(__('成功'),$info); } }