isAjax()) { $page = input('page', 1); $limit = input('page_size', PAGE_LIST_ROWS); $condition = []; $goods_name = input('goods_name',''); if($goods_name){ $condition[] = ['goods_name','like','%'.$goods_name.'%']; } $notice = new RecommendModel(); $list = $notice->getRecommendPageList($condition, $page, $limit); return $list; } return $this->fetch('recommend/index'); } public function add(){ $goods_model = new Goods(); if (request()->isAjax()) { $data = [ 'goods_id' => input('goods_id', ''), 'create_time' => time(), ]; if(!empty($data['goods_id'])){ $goods = $goods_model->getGoodsInfo([['goods_id','=',$data['goods_id']]],'goods_name,goods_image'); $goods_image = explode(',',$goods['data']['goods_image']); $data['goods_name']=$goods['data']['goods_name']; $data['goods_image']=$goods_image[0]; } $notice = new RecommendModel(); $res = $notice->add_recommend($data); return $res; } else { $goods_arr = $goods_model->getGoodsList(['goods_state'=>1,'verify_state'=>1,'is_delete'=>0],'goods_id,goods_name'); $this->assign('goods_arr',$goods_arr['data']); return $this->fetch('recommend/add'); } } /** * 公告删除 * @return string[]|mixed[] */ public function deleteRecommend() { if (request()->isAjax()) { $id = input('id', ''); $notice = new RecommendModel(); $res = $notice->delete_recommend([ [ 'id', 'in', $id ] ]); return $res; } } }