作者 郭盛
1 个管道 的构建 通过 耗费 8 秒

修改分享接口

... ... @@ -53,14 +53,42 @@ class Index extends Frontend
//文件详情
public function detail()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->request->param('user_id');
$file_id = $this->request->param('file_id');
$data = Db::name('savemes')
->where('id',$file_id)
->find();
if($data['type'] == 2){
$data['video'] = '';
$data['video_image'] = '';
$data['content'] = '';
$data['images'] = $qiniu.$data['images'];
}elseif ($data['type'] == 3){
$data['images'] = '';
$data['content'] = '';
$data['video'] = $qiniu.$data['video'];
// 获取视频第一帧图片
$video_info = json_decode(file_get_contents($data['video'] . '?avinfo'), true);
$data['video_image'] = $this->get_video_first_image($data['video'], $video_info);
}elseif ($data['type'] == 1){
$data['images'] = '';
$data['video'] = '';
$data['video_image'] = '';
}
$this->assign('data',$data);
return $this->fetch();
}
public function get_video_first_image($video_url,$video_info){
if(empty($video_info['streams'][0]['width'])) {
$width = $video_info['streams'][1]['width'];
$height = $video_info['streams'][1]['height'];
} else {
$width = $video_info['streams'][0]['width'];
$height = $video_info['streams'][0]['height'];
}
return $video_url.'?vframe/jpg/offset/1/w/'.$width.'/h/'.$height;
}
}
... ...
... ... @@ -16,16 +16,16 @@
<div class="detail">文件详情</div>
</div>
{if condition="$type eq 2"}
{if condition="$data.type eq 2"}
<!--图片-->
<div class="pic">
<img src="/assets/cai/image/text-img.png" alt="">
<img src="{$data.images}" alt="">
</div>
{elseif condition="$type eq 3"/}
{elseif condition="$data.type eq 3"/}
<!--视频-->
<div class="vedio-box">
<div class="vedio">
<video src=""></video>
<video src="{$data.video}"></video>
<!--<img src="image/video (3).png" alt="" class="vedio-img">-->
<!--<div class="blackShade">-->
<!--<img src="image/video (4).png" alt="" class="vedio-play">-->
... ... @@ -34,7 +34,7 @@
</div>
{else /}
<div class="article">
{$data.content}
</div>
{/if}
... ...