order('type_id asc')->field('type_id,type_name,type_level')->select(); $data = array( array('grp_id'=>1,'name'=>'单词有误',), array('grp_id'=>2,'name'=>'例句有误',), ); foreach ($res as $row){ if ($row['type_level']==1){ $data['0']['options'][] = $row; }else{ $data['1']['options'][] = $row; } } $data = array('code'=>0,'msg'=>'','data'=>$data); $this->returnData($data);exit; } //添加反馈内容 public function add(){ $typeIds = I('type_ids'); $wordsId = I('words_id'); $courseId = I('course_id'); $fbSource = I('fb_source'); $fbContent = I('fb_content'); if (empty($fbSource) || !in_array($fbSource, array(1,2))){ $data = array('code'=>1,'msg'=>'反馈类型错误'); $this->returnData($data);exit; } if ($fbSource==1){ if (empty($wordsId)){ $data = array('code'=>1,'msg'=>'单词ID错误'); $this->returnData($data);exit; } if (empty($courseId) || $courseId<1000000){ $data = array('code'=>1,'msg'=>'课程ID错误'); $this->returnData($data);exit; } if (mb_strlen($fbContent,'UTF8')<2||mb_strlen($fbContent,'UTF8')>80){ $data = array('code'=>1,'msg'=>'反馈内容2到80个汉字'); $this->returnData($data);exit; } $typeIds = rtrim($typeIds, ','); if (empty($typeIds)){ $data = array('code'=>1,'msg'=>'请选择反馈类型'); $this->returnData($data);exit; } $resType = M('FeedbackType')->where(array('type_id'=>array('IN',$typeIds)))->order('type_id asc')->field('type_name')->select(); $typeName = ''; if (function_exists('array_column')){ $typeName = array_column($resType, 'type_name'); }else{ foreach ($resType as $r){ $typeName[] = $r['type_name']; } } $typeNames = '['.implode(',', $typeName).']'; $fbContent = $typeNames.$fbContent; $saveData = array('words_id'=>$wordsId,'course_id'=>$courseId,'type_ids'=>$typeIds,'fb_content'=>$fbContent); }else{ $saveData = array('fb_content'=>$fbContent); } $saveData['operate_dt'] = time(); $saveData['fb_source'] = $fbSource; $saveData['user_id'] = $this->userId; M('Feedback')->add($saveData); $data = array('code'=>0,'msg'=>'反馈成功','data'=>''); $this->returnData($data);exit; } }