app开屏广告

最近公司有个需求需要做app开屏广告(跳转到不同的页面)--下面是app开屏广告的处理

1.管理后台效果图

(1)广告链接--商品详情

 

(2)广告链接--关联模块

(3)广告链接--消息富文本

(4)广告链接--H5页面

(5)广告链接--蜂雷头条

2.数据表的设计

 CREATE TABLE `lc_open_ad` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `second` int(11) DEFAULT NULL COMMENT '开屏广告停留时长(单位:秒)',
  `ad_effective_start` datetime DEFAULT NULL COMMENT '开屏广告有效时间--开始时间',
  `ad_effective_end` datetime DEFAULT NULL COMMENT '开屏广告有效时间--结束时间',
  `ad_url` varchar(100) DEFAULT NULL COMMENT ' 开屏广告图片地址',
  `ad_link_type` int(11) DEFAULT NULL COMMENT '广告链接类型(1商品详情页、2关联模块、3消息富文本、4H5页面、5蜂雷头条详情页)',
  `ad_link_content` text COMMENT '广告链接内容 (json格式)',
  `create_id` bigint(20) DEFAULT NULL COMMENT ' 创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_id` bigint(20) DEFAULT NULL COMMENT '修改人',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态: 1 正常 2 禁用',
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已删除 0正常  1 已删除',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=122 DEFAULT CHARSET=utf8 COMMENT='开屏广告\n{"ad_type":"一级分类(默认1)","ad_link_type":"1(商品详情页)","itemid":"商品sku_id","sno":"商品sku_no"}\n{"ad_type":"一级分类(默认1)","ad_link_type":"2(关联模块)","plate_type":"1限时蜂抢、2新品、3蜂神榜、4蜂觅、5首页"}\n{"ad_type":"一级分类(默认1)","ad_link_type":"3(消息富文本)","rich_text_id":"消息富文本id"}\n{"ad_type":"一级分类(默认1)","ad_link_type":"4(H5页面)","url":"H5页面地址"}\n{"ad_type":"一级分类(默认1)","ad_link_type":"5(蜂雷头条详情页)","id":"蜂雷头条id"}';

3.数据表值的存储

4.管理后台添加(修改)的数据接收格式

{"id":"","second":"10","ad_url":"/Public/Uploads/ad/origin/5a1a68890eda5.jpg","ad_effective_start":"2016-10-12 00:00:00","ad_effective_end":"2016-10-13 00:00:00","ad_type":"1","ad_link_type":"1","ad_link_content":{"sku_id":"111111","sku_no":"P11111-01"}}
{"id":"","second":"10","ad_url":"/Public/Uploads/ad/origin/5a1a68890eda5.jpg","ad_effective_start":"2016-10-10 00:00:00","ad_effective_end":"2016-10-15 00:00:00","ad_type":"1","ad_link_type":"2","ad_link_content":{"plate_type":"1"}}
{"id":"","second":"10","ad_url":"/Public/Uploads/ad/origin/5a1a68890eda5.jpg","ad_effective_start":"2016-10-23 00:00:00","ad_effective_end":"2016-10-24 00:00:00","ad_type":"1","ad_link_type":"3","ad_link_content":{"rich_text_id":"富文本消息id--为空添加,不为空修改","content":"ssssssssssssss"}}
{"id":"","second":"10","ad_url":"/Public/Uploads/ad/origin/5a1a68890eda5.jpg","ad_effective_start":"2016-10-10 00:00:00","ad_effective_end":"2016-10-15 00:00:00","ad_type":"1","ad_link_type":"4","ad_link_content":{"url":"goods/detail?sno=P001219-01&itemid=1002975101}}
{"id":"","second":"10","ad_url":"/Public/Uploads/ad/origin/5a1a68890eda5.jpg","ad_effective_start":"2016-10-10 00:00:00","ad_effective_end":"2016-10-15 00:00:00","ad_type":"1","ad_link_type":"5","ad_link_content":{"id":"66"}}    

 6.php代码实现

(1)控制器

    /**
     * @title App开屏广告--添加(修改)
     * @param data 是 json 接收参数,格式:{"id":"为空添加,不为空修改","second":"开屏广告停留时间(单位:秒)","ad_url":"开屏广告图片地址(相对路径)","ad_effective_start":"开屏广告有效时间--开始时间","ad_effective_end":"开屏广告有效时间--结束时间","ad_type":"广告类型(不传默认1)","ad_link_type":"广告链接类型(1商品详情页、2关联模块、3消息富文本、4H5页面、5蜂雷头条详情页)","ad_link_content":"广告链接内容"}
     * @example app/kaipin_ad_save?
     * @method POST 
     * @author 邹柯
     */
    public function kaipin_ad_saveAction(){        
        load('Common.check');
        $public=D('Public');     
        $data=trim(I('post.data'));
        $res=$public->dealJson($data);
        $id=trim($res['id']);
        //广告类型
        $ad_type=trim($res['ad_type']);
        if(empty($ad_type)){
            $ad_type=1;
        }
        //开屏广告停留时间
        $second=trim($res['second']);
        if(empty($second)){
            $data = array('msg' =>"开屏广告停留时长不能为空!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        if(!is_numeric($second) || $second <= 0){
            $data = array('msg' =>"开屏广告停留时长必须为大于等于1的整形!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }  
        //开屏广告图片地址
        $ad_url=trim($res['ad_url']);
        if(empty($ad_url)){
            $data = array('msg' =>"开屏广告图片必须上传!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        //广告有效时间
        $ad_effective_start=trim($res['ad_effective_start']);
        if(empty($ad_effective_start)){
            $data = array('msg' =>"广告有效时间--开始时间不能为空!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        if(!IsDate($ad_effective_start,'Y-m-d H:i:s')){
            $data = array('msg' =>"广告有效时间--结束时间格式错误!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        $ad_effective_end=trim($res['ad_effective_end']);
        if(empty($ad_effective_end) && !empty($ad_effective_end)){
            $data = array('msg' =>"广告有效时间--结束时间不能为空!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        if(!IsDate($ad_effective_end,'Y-m-d H:i:s')){
            $data = array('msg' =>"广告有效时间--结束时间格式错误!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        if($ad_effective_start > $ad_effective_end){
            $data = array('msg' =>"广告有效时间开始时间不能大于结束时间!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        //广告链接类型
        $ad_link_type=trim($res['ad_link_type']);
        if(empty($ad_link_type)){
            $data = array('msg' =>"广告链接类型不能为空!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        if(!is_numeric($ad_link_type) || $ad_link_type <= 0){
            $data = array('msg' =>"广告链接类型必须为大于等于1的整形!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }  
        if(!in_array($ad_link_type,array(1,2,3,4,5))){
            $data = array('msg' =>"广告链接类型值非法!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        //广告链接内容
        $ad_link_content=$res['ad_link_content'];
        if(empty($ad_link_content)){
            $data = array('msg' =>"广告链接内容不能为空!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }       
        $app=D('App');
        $list=$app->kaipin_ad_add($id,$second,$ad_url,$ad_effective_start,$ad_effective_end,$ad_type,$ad_link_type,$ad_link_content); 
        if((int)$list==100){
            $data = array('msg' =>"广告有效时间冲突!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        if($list==false){
            $data = array('msg' =>"添加失败!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        $data = array('msg' =>"添加成功!" , 'status'=>'0','result'=>$list);
        $this->ajaxReturn($data);
    }
  /**
     * @title 开屏广告图片上传
     * @example app/img_upload?
     * @param ad_url 是 file 开屏广告图片名称(上传图片的尺寸1440_2560)
     * @return_param_explain  returnPath:相对路径(存储用) preview:全路径(展示用)
     * @method POST
     * @author 邹柯
     */
    public function img_uploadAction(){
        if(!empty($_FILES["ad_url"]["name"])){
             $width="1440";
             $height="2560";
             $app = D('App');
             $data = $app->upload_file('ad_url',$width,$height);
        }else{
             $data = array(
                'msg' => "参数错误",
                'status' => '1'
             );
        }
        
        $this->ajaxReturn($data);
    }  

(2)模型

     //App开屏广告--添加(修改)
     public function kaipin_ad_add($id,$second,$ad_url,$ad_effective_start,$ad_effective_end,$ad_type,$ad_link_type,$ad_link_content){  
         $open_ad=M('open_ad');
         $create_time=date('Y-m-d H:i:s',time());
         $create_user=$_SESSION['user']['personnel_code'];
         
         //判断时间是否冲突
         $where2="status=1 and is_deleted=0";
         if(!empty($id)){
             $where2 .=" and id !='".$id."'";
         }
         $rs=$open_ad->field('ad_effective_start,ad_effective_end')->where($where2)->select();
         $r_start=array_unique(array_column($rs,'ad_effective_start'));
         $r_end=array_unique(array_column($rs,'ad_effective_end'));
         if(in_array($ad_effective_start,$r_start)){
             return 100;
         }
         if(in_array($ad_effective_end,$r_end)){
             return 100;
         }
         foreach($r_end as $k=>$v){
             if($v > $ad_effective_start && $v <= $ad_effective_end){
                  return 100;
             }
             continue;
         }       
         foreach($rs as $k=>$v){
             if($v['ad_effective_start'] <=$ad_effective_start && $ad_effective_end <=$v['ad_effective_end']){
                  return 100;
             }
         }
         switch($ad_link_type){
             case 1: //商品详情页
                 $ad_link_content_info=array(
                     'ad_type'=>$ad_type,
                     'ad_link_type'=>$ad_link_type,
                     'itemid'=>$ad_link_content['sku_id'],
                     'sno'=>$ad_link_content['sku_no']
                 );
                 break; 
             case 2://关联模块
                 $ad_link_content_info=array(
                     'ad_type'=>$ad_type,
                     'ad_link_type'=>$ad_link_type,
                     'plate_type'=>$ad_link_content['plate_type'],
                 );
                 break;
             case 3://广告富文本
                 $rich_text=M('rich_text');
                 //添加
                 if(empty($ad_link_content['rich_text_id'])){
                      $data=array(
                            'content'=>html_entity_decode($ad_link_content['content']),
                            'create_id'=>$create_user,
                            'create_time'=>$create_time,
                            'update_id'=>$create_user,
                            'update_time'=>$create_time,                          
                            'type'=>2
                      );
                      $re=$rich_text->data($data)->add();
                      //获取自增id
                      $id2=$rich_text->getLastInsID();
                 }else{
                      $data=array(
                            'content'=>html_entity_decode($ad_link_content['content']),
                            'update_id'=>$create_user,
                            'update_time'=>$create_time,
                      );
                      $re=$rich_text->where(array('id'=>$ad_link_content['rich_text_id']))->data($data)->save();
                      $id2=$ad_link_content['rich_text_id'];
                 }     
                 
                 $ad_link_content_info=array(
                     'ad_type'=>$ad_type,
                     'ad_link_type'=>$ad_link_type,
                     'rich_text_id'=>$id2
                 );
                 break;
             case 4://H5页面
                 $ad_link_content_info=array(
                     'ad_type'=>$ad_type,
                     'ad_link_type'=>$ad_link_type,
                     'url'=>$ad_link_content['url']
                 );
                 break;
             default://蜂雷头条详情页                 
                 $ad_link_content_info=array(
                     'ad_type'=>$ad_type,
                     'ad_link_type'=>$ad_link_type,
                     'id'=>$ad_link_content['id']
                 );
                 break;                 
         }  
         //转换成json       
         $ad_link_content_json = json_encode($ad_link_content_info);
         //添加
         if(empty($id)){
             //添加开屏广告
            $data2=array(
                   'second'=>$second,
                   'ad_url'=>$ad_url,
                   'ad_effective_start'=>$ad_effective_start,
                   'ad_effective_end'=>$ad_effective_end,
                   'ad_link_type'=>$ad_link_type,
                   'ad_link_content'=>$ad_link_content_json,
                   'create_id'=>$create_user,
                   'create_time'=>$create_time,
                   'update_id'=>$create_user,
                   'update_time'=>$create_time,
            );
            $res2=$open_ad->data($data2)->add();
         }else{//修改
             //添加开屏广告
            $wh = "id='".$id."'";
            $res_in=$open_ad->field('id,second,ad_effective_start,ad_effective_end,ad_url,ad_link_type,ad_link_content')->where($wh)->find();
            $data2=array(
                   'second'=>$second,
                   'ad_url'=>$ad_url,
                   'ad_effective_start'=>$ad_effective_start,
                   'ad_effective_end'=>$ad_effective_end,
                   'ad_link_type'=>$ad_link_type,
                   'ad_link_content'=>$ad_link_content_json,
                   'update_id'=>$create_user,
                   'update_time'=>$create_time,
            );
            $res2=$open_ad->data($data2)->where(array('id'=>$id))->save();
         }         
         if(!$res2){
               return false;
         }
         //写日志
         if(empty($id)){
             $type=1; //添加
             $message_before='';
             $message="添加了1条【开始时间为:".$ad_effective_start.",结束时间为:".$ad_effective_end."】的开屏广告信息";   
         }else{
             $type=2; //修改               
             $message_before=json_encode($res_in);     
             $message="修改了1条id为".$id."的app开屏广告信息";   
         }
         $message_after=json_encode($data2);
         D('public')->wLog($message,$message_before,$message_after,$type);
         return true;
     }
  /*
    *  验证图片尺寸是否合法
    *  img_tmp_width  :   上传图片宽
    *  img_tmp_height :   上传图片高
    *  width  :    规定图片宽
    *  height :    规定图片高
    */
    private function checkImgSize($width,$height,$img_tmp_width,$img_tmp_height){
        if(empty($width) || empty($height) || empty($img_tmp_width) || empty($img_tmp_height)){
            $status = '1';
            $msg = "图片宽高不能为空!";
        }elseif($width<>$img_tmp_width ||  $height<>$img_tmp_height){
            $status = '1';
            $msg = '图片尺寸错误,正确值:'.$width.'px * '.$height.'px';    
        }else{
            $status = '0';
            $msg = '验证通过';
        }
        $result = array('status'=>$status,'msg'=>$msg);    
        return $result;
    }
    public function upload_file($file_name,$width,$height) {
        //检查图片尺寸是否合法       
        $image_size = getimagesize($_FILES[$file_name]['tmp_name']);
        $img_tmp_width=$image_size['0'];
        $img_tmp_height=$image_size['1'];
        $size_result = $this->checkImgSize($width,$height,$img_tmp_width,$img_tmp_height);
        if($size_result['status'] == '1'){
             return $size_result;   //格式错误直接返回
        }
        //执行上传   
        $upload_path = C('upload_path');                      // Public/Uploads/
        $upload = new \Think\Upload();                        // 实例化上传类
        $upload->maxSize = 3145728;                           // 设置附件上传大小
        $upload->exts = array('jpg', 'gif', 'png', 'jpeg');   // 设置附件上传类型
        $upload->rootPath = './' . rtrim($upload_path, '/');  // 设置附件上传根目录
        $upload_img_url=C('upload_img_url');                  // /www/web/feelee_mall_img/public_html/
        $rootPath=$upload_img_url . rtrim($upload_path, '/'); // 设置附件上传根目录 /www/web/feelee_mall_img/public_html/Public/Uploads
        $upload->rootPath = $rootPath;
        $savepath = '/ad/';
        $path = '/' . $upload_path;
        $upload->saveName = uniqid();
        $upload->savePath = $savepath;
        $upload->replace = true;
        $upload->autoSub = true;
        $upload->subName = "origin"; //date("Ymd");
        $path1='/ad/origin/';
        if(!is_dir($path1)){
            mkdir($path1,0755);
        }
        // 上传单个文件
        $info = $upload->uploadOne($_FILES[$file_name]);
        if (!$info) {// 上传错误提示错误信息
            $upload_error = C('upload_error_msg');
            $error = $upload_error[$upload->getError()];
            if ($error == '') {
                $error = $upload->getError();
            }
            return $data = array(
                'msg' => $error,
                'status' => 1,
                'result'=>null                
            );
        } else {// 上传成功 获取上传文件信息
            $filenames = $path . $info['savepath'] . $info['savename'];
            //生成缩略图
            $info2=$this->createThumb($info,$rootPath);
            $preview=C('img_base').$filenames;
            return  $data = array(
                'msg' => '上传成功',
                'status' => '0',
                'result' =>array(
                    'returnPath'=>$filenames,//保存用
                    'preview'=>$preview      //显示用
                )       
            );
        }
    }
    //生成缩略图
    public function createThumb($info,$rootPath){
        $path2=$rootPath.'/ad/thumb/';
        if(!is_dir($path2)){
            mkdir($path2,0755);
        }
        $pic_size=C('pic_size');
        $cn=count($pic_size);
        $image=new \Think\Image();
        //打开要生成缩略图的文件
        for($i=0;$i<$cn;$i++){
            $image->open($rootPath."/ad/origin/".$info['savename']);
            $url_pic='/thumb/'.$pic_size[$i] ."_". $info['savename'];
            $in=strpos($pic_size[$i],"_");
            $width=substr($pic_size[$i],0,$in);
            $height=substr($pic_size[$i],$in+1);
            //生成ios缩略图
            $image->thumb($width,$height,1)->save($rootPath."/ad".$url_pic);
        }
    }

配置文件:

 //图片缩略图尺寸    'pic_size'=>array("640_960","640_1136","720_1280","750_1334","800_1280","1080_1920","1125_2436","1242_2208","1440_2560"),

 

(3)app--前端取值--根据android和ios不同屏幕尺寸返回不同大小的图片

控制器:

 /**
     * @title 开屏广告页
     * @example app/kai_pin_ad? 调试参数:{"type":"1"}
     * @param data 是 json 接收参数,格式:{type:"图片尺寸1(640_960)、2(640_1136)、3(720_1280)、4(750_1334)、5(800_1280)、6(1080_1920)、7(1125_2436)、8(1242_2208)、9(1440_2560)"}
     * @return_param_explain id:开屏广告id ad_effective_start:开屏广告有效时间--开始时间 ad_effective_end:开屏广告有效时间--结束时间 second:开屏广告停留时间(单位:秒) ad_url:开屏广告图片地址 ad_link_type_name:广告链接类型(1商品详情页、2关联模块、3消息富文本、4H5页面、5蜂雷头条详情页) param:根据链接类型--跳转地址或参数
     * @method POST 
     * @author 邹柯
     */
    public function kai_pin_adAction(){
        $public=new PublicModel();     
        $data=trim(I('post.data'));
        $res=$public->dealJson($data);
        $user_id=session('user.user_id');
        $type=trim($res['type']);
        if(empty($type)){
            $data = array('msg' =>"图片尺寸类型不能为空!" , 'status'=>'1','result'=>null);
            $this->ajaxReturn($data);
        }
        $app=new AppModel();
        $list=$app->kai_pin_ad($type,$user_id); 
        $data = array('msg' =>"加载成功!" , 'status'=>'0','result'=>$list);
        $this->ajaxReturn($data);
    }

模型:

   public function kai_pin_ad($type,$user_id){
        $time=date('Y-m-d H:i:s',time());
        $where="'".$time."' <=ad_effective_end and status=1";
        $open_ad=M('open_ad');
        $list=$open_ad->field('id,second,ad_effective_start,ad_effective_end,ad_url,ad_link_type,ad_link_content,is_deleted')
                ->where($where)
                ->select();
        if(empty($list)){
             return null;
        }else{
             foreach($list as $k=>$v){
                $ad_link_content_arr=json_decode($v['ad_link_content'],true);
                $ad_link_type=$v['ad_link_type'];
                switch($ad_link_type){
                   case 1: //商品详情页
                       //获取种子店
                       if(empty($user_id)){
                           $store_id=C('setting_store');
                       }else{//获取该登录用户的上级店铺id
                           $inf=M('customer')->where('user_id="'.$user_id.'" and is_deleted=0')->field('partent_user_id')->find();
                           $store_id=M('store')->where('user_id="'.$inf['partent_user_id'].'"')->getField('id');
                       }
                       $data=array(
                           'itemid'=>$ad_link_content_arr['itemid'],
                           'sno'=>$ad_link_content_arr['sno'],
                           'store_id'=>$store_id
                       );
                       break; 
                   case 2://关联模块
                       $data=array('plate_type'=>$ad_link_content_arr['plate_type']);  
                       break;
                   case 3://广告富文本
                       $rich_text=M('rich_text');
                       $where2="id='".$ad_link_content_arr['rich_text_id']."' and is_deleted=0 and status=1";
                       $res=$rich_text->field('id,content')->where($where2)->find();
                       $data=array(
                            'id'=>$ad_link_content_arr['rich_text_id'],
                            'title'=>"广告详情",
                            'content'=>$res['content'],
                            'url'=>'common/rich_text?id='.$ad_link_content_arr['rich_text_id'].'&type=2'
                       );
                       break;
                   case 4://H5页面
                       $data=array('url'=>$ad_link_content_arr['url']);
                       break;
                   default://蜂雷头条详情页
                       $headlines = M('headlines','t_',C('select_db')); 
                       $list2=$headlines->where(array('id'=>$ad_link_content_arr['id']))->field('id,title,content')->find();
                       $data=array(
                           'id'=>$ad_link_content_arr['id'],
                           'title'=>$list2['title']
                       );   
                       break;   
                }
                $or_url=C('img_base')."Public/Uploads/ad/thumb/";
                $in=strripos($v['ad_url'],"/");
                $filename=substr($v['ad_url'],$in+1);
                $pic_size=C('pic_size');
                $ct=$type-1;
                $in=strpos($pic_size[$ct],"_");
                $width=substr($pic_size[$ct],0,$in);
                $height=substr($pic_size[$ct],$in+1);
                $ad_url_pic=$or_url.$pic_size[$ct] ."_". $filename;
                $arr[$k]=array(
                    'id'=>$v['id'],
                    'ad_effective_start'=>$v['ad_effective_start'],
                    'ad_effective_end'=>$v['ad_effective_end'],
                    'ad_link_type'=>$ad_link_type,
                    'second'=>$v['second'],
                    'ad_url'=>$ad_url_pic,
                    'redirect_url'=>$data,
                    'is_deleted'=>$v['is_deleted']
                );
            }
            return $arr;
        }   
    } 

配置文件:

 //图片缩略图尺寸    'pic_size'=>array("640_960","640_1136","720_1280","750_1334","800_1280","1080_1920","1125_2436","1242_2208","1440_2560"),

 

 

返回的数据结构:

{
    "msg":"加载成功!",
    "status":"0",
    "result":[{
        "id":"7",
        "ad_effective_start":"2017-12-15 13:33:37",
        "ad_effective_end":"2017-12-15 21:22:37",
        "ad_link_type":"3",
        "second":"4",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_1002883101.jpg",
        "redirect_url":{
            "id":106,
            "title":"广告详情",
            "content":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "url":"common\/rich_text?id=106&type=2"
        },
        "is_deleted":"1"
    },
    {
        "id":"14",
        "ad_effective_start":"2017-12-10 00:00:00",
        "ad_effective_end":"2017-12-10 19:00:00",
        "ad_link_type":"4",
        "second":"10",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_1002883101.jpg",
        "redirect_url":{
            "url":"www.baidu.com"
        },
        "is_deleted":"1"
    },
    {
        "id":"15",
        "ad_effective_start":"2016-12-09 00:00:00",
        "ad_effective_end":"2017-12-09 19:00:00",
        "ad_link_type":"5",
        "second":"10",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_1002883101.jpg",
        "redirect_url":{
            "id":"63",
            "title":"诗圣杜甫"
        },
        "is_deleted":"0"
    },
    {
        "id":"99",
        "ad_effective_start":"2018-01-04 09:09:17",
        "ad_effective_end":"2018-01-06 07:07:17",
        "ad_link_type":"2",
        "second":"8",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a227452bde39.png",
        "redirect_url":{
            "plate_type":"003"
        },
        "is_deleted":"1"
    },
    {
        "id":"100",
        "ad_effective_start":"2018-01-11 06:06:34",
        "ad_effective_end":"2018-01-13 10:10:34",
        "ad_link_type":"1",
        "second":"8",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a229c940ca46.png",
        "redirect_url":{
            "itemid":1000000008,
            "sno":"P001219-10",
            "store_id":"117080350981001"
        },
        "is_deleted":"1"
    },
    {
        "id":"108",
        "ad_effective_start":"2021-03-02 00:00:46",
        "ad_effective_end":"2021-03-05 23:59:46",
        "ad_link_type":"4",
        "second":"1",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a24b794701b5.png",
        "redirect_url":{
            "url":"http:\/\/fenglei_manage.com"
        },
        "is_deleted":"1"
    },
    {
        "id":"109",
        "ad_effective_start":"2021-01-01 00:00:53",
        "ad_effective_end":"2021-01-02 23:59:53",
        "ad_link_type":"4",
        "second":"5",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a24b97b0e289.png",
        "redirect_url":{
            "url":"http:\/\/fenglei_manage.com\/"
        },
        "is_deleted":"1"
    },
    {
        "id":"110",
        "ad_effective_start":"2018-01-01 00:00:00",
        "ad_effective_end":"2018-01-03 23:59:00",
        "ad_link_type":"1",
        "second":"5",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a2536a29fa2e.png",
        "redirect_url":{
            "itemid":1000000013,
            "sno":"P001219-15",
            "store_id":"117080350981001"
        },
        "is_deleted":"1"
    },
    {
        "id":"111",
        "ad_effective_start":"2018-01-10 00:00:00",
        "ad_effective_end":"2018-01-12 23:59:00",
        "ad_link_type":"5",
        "second":"6",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a2536cc11c0f.png",
        "redirect_url":{
            "id":67,
            "title":null
        },
        "is_deleted":"1"
    },
    {
        "id":"112",
        "ad_effective_start":"2018-01-15 00:00:00",
        "ad_effective_end":"2018-01-17 23:59:00",
        "ad_link_type":"4",
        "second":"8",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a2536f978fc3.png",
        "redirect_url":{
            "url":"http:\/\/fenglei_manage.com\/"
        },
        "is_deleted":"1"
    },
    {
        "id":"115",
        "ad_effective_start":"2017-12-21 00:00:00",
        "ad_effective_end":"2017-12-30 23:59:00",
        "ad_link_type":"5",
        "second":"8",
        "ad_url":"http:\/\/img.test.feelee.cc\/Public\/Uploads\/ad\/thumb\/640_960_5a268632c171c.png",
        "redirect_url":{
            "id":66,
            "title":null
        },
        "is_deleted":"1"
    }]
}

返回的数据结构字段说明:

id:开屏广告id

ad_effective_start:开屏广告有效时间--开始时间

ad_effective_end:开屏广告有效时间--结束时间

second:开屏广告停留时间(单位:秒)

ad_url:开屏广告图片地址

ad_link_type_name:广告链接类型(1商品详情页、2关联模块、3消息富文本、4H5页面、5蜂雷头条详情页)

redirect_url:根据链接类型--跳转地址或参数
     当ad_link_type为1时redirect_url={"itemid":"商品sku_id","sno":"商品sku_no","store_id":"未登录用户(种子店)、登录用户上级店铺id"}
     当ad_link_type为2时redirect_url={"plate_type":"1限时蜂抢、2新品、3蜂神榜、4蜂觅、5首页"}
     当ad_link_type为3时redirect_url={"rich_text_id":"消息富文本id"}     
当ad_link_type为4时redirect_url={"url":"H5页面地址"} 当ad_link_type为5时redirect_url={"id":"蜂雷头条id","title":"蜂雷头条标题"}

 

posted @ 2017-12-29 11:57  邹柯  阅读(2244)  评论(0编辑  收藏  举报