authUsername),true); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data']) && $res['data']){ $result['Notice']['status']=1; $result['Notice']['data']=$res['data']; }else{ $result['Notice']['status']=0; } //读取常见问题 $res1 = json_decode(http('help/coach/familiar', 'get', $this->authUsername),true); if(isset($res1['errCode']) && $res1['errCode']=='00' && isset($res1['data']) && $res1['data']){ $result['Familiar']['status']=1; $result['Familiar']['data']=$res1['data']; }else{ $result['Familiar']['status']=0; } //热门问题 $res2 = json_decode(http('help/coach/hot', 'get', $this->authUsername),true); if(isset($res2['errCode']) && $res2['errCode']=='00' && isset($res2['data']) && $res2['data']){ $result['Hot']['data']=$res2['data']; $result['Hot']['status']=1; }else{ $result['Hot']['status']=0; } $res = json_decode(http('help/coach/config', 'get', $this->authUsername),true); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data']) && $res['data']){ $result['HelpHello']['data']=$res['data']; $result['HelpHello']['status']=1; }else{ $result['HelpHello']['status']=0; } if($result){ exit(json_encode(array('status'=>1,'data'=>$result))); }else{ exit(json_encode(array('status'=>0,'data'=>$result))); } } //提问 public function actionSearch(){ $alikeName=Req::post('keyword'); $result=array('status'=>0); $param['alikeName']=$alikeName; $res = json_decode(http('help/coach/list-es', 'post', $this->authUsername,$param),true); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data'])){ $result['data']=$res['data']; $result['status']=1; } exit(json_encode($result)); } //自助查询 public function actionList(){ //分类 $result['status']=0; $res = json_decode(http('help/coach/list/tree', 'get', $this->authUsername),true); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data'])){ $result['data']['tree']=$res['data']; } $res = json_decode(http('help/coach/list', 'post', $this->authUsername),true); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data'])){ $result['status']=1; $result['data']['list']=$res['data']; } http('help/coach-count/auto', 'put', $this->authUsername); exit(json_encode($result)); } //查看问题 public function actionView(){ $id=Req::post('id'); $isAnswer=Req::post('isAnswer'); $need_count=Req::post('needcount'); $result['status']=0; $res = json_decode(http('help/coach/'.$id, 'get', $this->authUsername),true); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data'])){ if($need_count){ if($isAnswer=='1') { http('help/coach-count/problem/1/' . $id, 'put', $this->authUsername); //查看为0,标准答案为1 }elseif($isAnswer=='2'){ http('help/coach-count/problem/2/' . $id, 'put', $this->authUsername); //查看为0,标准答案为1 }else{ http('help/coach-count/problem/0/'.$id, 'put', $this->authUsername); //查看为0,标准答案为1 } } $result['status']=1; $result['data']=$res['data']; } exit(json_encode($result)); } //有用、没有 public function actionUse(){ $id=Req::post('id'); $name=Req::post('name'); $type=Req::post('type'); $suggest=Req::post('suggest'); $result['status']=0; if($type==1){ $res = json_decode(http('help/coach-count/use/'.$id.'/'.urlencode($name), 'put', $this->authUsername),true); if(isset($res['errCode']) && $res['errCode']=='00'){ $result['status']=1; } exit(json_encode($result)); }else{ $res = json_decode(http('help/coach-count/useless/'.$id.'/'.urlencode($name), 'put', $this->authUsername),true); if(isset($res['errCode']) && $res['errCode']=='00' ){ $result['status']=1; $param['hspName']=$name; $param['hspType']=1; $param['hpId']=$id; $param['source']=0; $res1 = json_decode(http('help/coach/add', 'post', $this->authUsername,$param),true); if(isset($res1['errCode']) && $res1['errCode']=='00' && isset($res1['data'])){ $result['status']=1; } } exit(json_encode($result)); } } public function actionNoAnswer(){ $name=Req::post('name'); $param['hspName']=$name; $param['hspType']=0; $param['source']=0; $res1 = json_decode(http('help/coach/add', 'post', $this->authUsername,$param),true); if(isset($res1['errCode']) && $res1['errCode']=='00' && isset($res1['data'])){ $result['status']=1; } } //问题列表 public function actionQuestion(){ $pageNumber=Req::post('pnum'); $typeId=Req::post('typeId'); $result['status']=0; if(!$pageNumber) $pageNumber=1; $param['pageNum']=$pageNumber; if($typeId){ $param['typeId']=$typeId; } $res = json_decode(http('help/coach/list', 'post', $this->authUsername,$param),true); if(isset($res['errCode']) && $res['errCode']=='00' && isset($res['data'])){ $result['status']=1; $result['data']=$res['data']; } exit(json_encode($result)); } //问题编辑 public function actionAdd(){ $param['hspName']=Req::post('name'); $source=Req::post('source'); if(!$source){ $source=1; }else{ $source=0; } $param['hspType']=2; $param['hpId']=Req::post('id'); $param['suggest']=Req::post('suggest'); $param['source']=$source; $result['status']=0; $res = json_decode(http('help/coach/add', 'post', $this->authUsername,$param),true); if(isset($res['errCode']) && $res['errCode']=='00'){ $result['status']=1; } exit(json_encode($result)); } public function actionHelper(){ $this->render('help'); } public function actionSelfHelp(){ $this->render('selfHelp'); } }