field('good_show as is_show')->find(); $data = array('code'=>0,'msg'=>'','data'=>array()); $data['pop_up'] = $this->showPop(); $data['show_tag'] = isset($showTag['is_show'])?$showTag['is_show']:'0'; if ($data['show_tag']){ $res = M('GoodCourse')->join($join)->field($field)->order(array('good_sort'=>'asc','good_id'=>'desc'))->select(); if ($res!=NULL){ $userWordsRes = $this->square(); foreach ($res as $key=>$row){ if (in_array($row['course_id'], $userWordsRes) || $row['user_id']==$this->userId){ $res[$key]['is_add'] = 1; }else{ $res[$key]['is_add'] = 0; } } } if ($data['pop_up']){ $data['data'] = $res; }else{ if (empty($isPopUp)){ $data['data'] = $res; }else { $data['data'] = array(); } } }else{ $data['data'] = array(); } $this->returnData($data);exit; } //是否展示精品课程标签 public function showTag(){ $res = M('GoodCourseShow')->field('good_show as show_tag')->find(); //$res['pop_up'] = $this->showPop(); $data = array('code'=>0,'msg'=>'','data'=>$res); $this->returnData($data);exit; } //是否弹窗 private function showPop(){ $resShow = M('GoodCourseShow')->field('good_show')->find(); if ($resShow['good_show']==0){ return 0; } $ym = strtotime(date('Y-m')); $res = M('UserPop')->where(array('user_id'=>$this->userId,'operate_dt'=>$ym))->find(); $isShow = 1; if ($res==NULL){ M('UserPop')->add(array('user_id'=>$this->userId,'operate_dt'=>$ym)); }else if($res['pop_num']<=6){ M('UserPop')->where(array('pop_id'=>$res['pop_id']))->setInc('pop_num'); }else{ $isShow = 0; M('UserPop')->where(array('pop_id'=>$res['pop_id']))->setInc('pop_num'); } return $isShow; } //获取已经添加的课程或者自由记 private function square($uwType=0){ $condition = array('user_id'=>$this->userId,'is_show'=>1); if (!empty($uwType)){ $condition['uw_type'] = $uwType; } $res = M('UserWords')->where($condition)->field('course_id')->select(); if ($res==NULL){ return array(); } $arr = array(); foreach ($res as $r){ $arr[] = $r['course_id']; } return $arr; } }