1, ]; $banner = Db::name('banner')->field('id,title,type,image,video_file,url')->where($where)->order('weigh', 'desc')->select(); $banner = list_domain_image($banner, ['image','video_file']); if(!empty($banner)){ foreach($banner as $key => $val){ $banner[$key]['thumb_image'] = ''; if(!empty($val['video_file'])){ $banner[$key]['thumb_image'] = $val['video_file'].'?x-oss-process=video/snapshot,t_100,f_png,m_fast'; } } } //第一条公告 $message = Db::name('message_sys')->where('is_show',1)->where('is_index',1)->order('weigh','desc')->find(); $message = $this->info_lang($message,['title','info']); $message = info_domain_image($message,['avatar']); if($message){ $message['createtime'] = $this->date_lang($message['sendtime']); } //留个好评 $haoping = Db::name('appplat')->field('image,url,biglogo')->where('type',1)->order('weigh', 'desc')->select(); $haoping = list_domain_image($haoping, ['image']); //关注我们 $followus = Db::name('appplat')->field('image,url,biglogo')->where('type',2)->order('weigh', 'desc')->select(); $followus = list_domain_image($followus, ['image']); $result = [ 'banner' => $banner, 'message' => $message, 'haoping' => $haoping, 'followus' => $followus, 'contact_mobile' => config('site.contact_mobile'), 'contact_email' => config('site.contact_email'), 'index_middle_image' => localpath_to_netpath(config('site.index_middle_image')), 'index_bottom_image' => localpath_to_netpath(config('site.index_bottom_image')), 'map_longitude' => config('site.map_longitude'), 'map_latitude' => config('site.map_latitude'), ]; $this->success(1,$result); } //搜索 public function search(){ $keyword = input('keyword','','trim'); //搜课时表 $where = [ 'slot.status' => 0,//报名中 'slot.is_show' => 1, 'slot.starttime' => ['gt',time()], ]; //模糊搜索 $wherelike = ''; if(!empty($keyword)){ //搜课程名 $wherelike .= "(lesson.name like '%".$keyword."%') or (lesson.name_en like '%".$keyword."%')"; //搜教练ids $coach_where = []; $coach_where['nickname'] = ['LIKE','%'.$keyword.'%']; $coach_ids = Db::name('coach')->where($coach_where)->column('id'); if(!empty($coach_ids)) { $wherelike .= ' or '; foreach($coach_ids as $ck => $cv){ $wherelike .= "(FIND_IN_SET('".$cv."',slot.coach_ids))"; if($ck+1 < count($coach_ids)){ $wherelike .= " or "; } } } } $list = Db::name('lesson_slot')->alias('slot') ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price') ->join('lesson','slot.lesson_id = lesson.id','LEFT') ->where($where)->where($wherelike)->autopage() //->select(false);echo $list;exit; ->select(); $list = list_domain_image($list,['image']); $list = $this->list_lang($list,['name']); //准备教练数据 $coach_list = Db::name('coach')->column('id,nickname'); foreach($list as $key => &$slot){ //hours转换 $slot['hours'] = floatval($slot['hours']); //放入教练 $coach_text = ''; $coach_ids = explode(',',$slot['coach_ids']); foreach($coach_ids as $coach_id){ if(isset($coach_list[$coach_id])){ $coach_text .= $coach_list[$coach_id].','; } } $slot['coach_text'] = substr($coach_text,0,-1); //组织时间 if($this->lang == 'en'){ $slot['slot_time'] = date('M d',$slot['starttime']).'('.date('D',$slot['starttime']).')'.','.date('H:i',$slot['starttime']).'-'.date('H:i',$slot['endtime']); }else{ $slot['slot_time'] = date('n月d',$slot['starttime']).'(周'.date('N',$slot['starttime']).')'.','.date('H:i',$slot['starttime']).'-'.date('H:i',$slot['endtime']); } } $this->success(1,$list); } }