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

修改接口

... ... @@ -91,7 +91,62 @@ class Index extends Frontend
$user_id = $this->request->param('user_id');
$file_id = $this->request->param('file_id');
//文件夹
$folder = Db::name('folder')
->where('pid',$file_id)
->where('is_up',1)
->select();
foreach ($folder as &$v){
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
$times = array_values(array_unique(array_column($folder,'createtime')));
//将数据放到对应的时间分段
$arrs = [];
foreach ($times as $t_k=> $t_v){
$arrs[$t_k]['times'] = $t_v;
$k = 0;
foreach ($folder as $value){
$k+=0;
if($t_v == $value['createtime']){
$arrs[$t_k]['info'][$k] = $value;
$k++;
}
}
}
$data['folder'] = $arrs;
//笔记
$note['folder_id'] = ['eq',$file_id];
$note['is_up'] = ['eq',1];
$z_tiao['a.folder_id'] = ['eq',$file_id];
$z_tiao['b.is_up'] = ['eq',1];
$note = $this->myfile(1,$note);
$zhuan_note = $this->zhuan(1,$z_tiao);
$gong = $this->gong(1,$note,$zhuan_note);
$data['note'] = $this->sundry($gong);
//图片
$pic['folder_id'] = ['eq',$file_id];
$pic_tiao['a.folder_id'] = ['eq',$file_id];
$pic = $this->myfile(2,$pic);
$zhuan_pic = $this->zhuan(2,$pic_tiao);
$gong1 = $this->gong(2,$pic,$zhuan_pic);
$data['pic'] = $this->sundry($gong1);
//视频
$video['folder_id'] = ['eq',$file_id];
$video_tiao['a.folder_id'] = ['eq',$file_id];
$video = $this->myfile(3,$video);
$zhuan_video = $this->zhuan(3,$video_tiao);
$gong2 = $this->gong(3,$video,$zhuan_video);
$data['video'] = $this->sundry($gong2);
$text = Db::name('official')->where('id',1)->find();
$data['introduce'] = $text['introduce'];
$this->assign('data',$data);
return $this->fetch();
}
... ... @@ -105,4 +160,99 @@ class Index extends Frontend
}
return $video_url.'?vframe/jpg/offset/1/w/'.$width.'/h/'.$height;
}
//通过传入类型获取我自己的不同文件
public function myfile($type,$where){
$data = Db::name('savemes')
->where($where)
->where('type',$type)
->field('id,user_id,type,name,share_url,images,video,content,is_open,is_up,createtime')
->order('createtime desc')
->select();
return $data;
}
//通过传入类型获取转存的不同文件
public function zhuan($type,$tiao){
$rotor = Db::name('rotor')
->alias('a')
->join('savemes b','a.savemes_id = b.id')
->field('a.id,a.user_id as unloading_user_id,a.savemes_id,a.folder_id,b.user_id,b.share_url,b.name,b.type,b.images,b.video,b.content,b.is_open,b.is_up,a.createtime')
->where('b.type',$type)
->where($tiao)
->order('a.createtime desc')
->select();
return $rotor;
}
//各种类型的文件 转存以及自己的文件
public function gong($type,$arr1,$arr2){
$qiniu = get_addon_config('qiniu')['cdnurl'];
if(!empty($arr2)){
foreach ($arr2 as &$v_1){
$v_1['is_zhuan'] = 1;
$v_1['is_real'] = 2;
}
$arr = array_merge($arr1,$arr2);
}else{
$arr = $arr1;
}
//笔记类型
if($type == 1){
foreach ($arr as &$v){
$v['nowtime'] = date('Y-m-d',$v['createtime']);
$v['createtime'] = date('m-d',$v['createtime']);
$v['images'] = '';
$v['video'] = '';
$v['video_image'] = '';
}
} elseif ($type == 2){
//图片类型
foreach ($arr as &$v){
$v['nowtime'] = date('Y-m-d',$v['createtime']);
$v['createtime'] = date('m-d',$v['createtime']);
$v['images'] = $qiniu.$v['images'];
$v['video'] = '';
$v['video_image'] = '';
$v['content'] = '';
}
}elseif ($type == 3){
//视频类型
foreach ($arr as &$v){
$v['nowtime'] = date('Y-m-d',$v['createtime']);
$v['createtime'] = date('m-d',$v['createtime']);
$v['video'] = $qiniu.$v['video'];
// 获取视频第一帧图片
$video_info = json_decode(file_get_contents($v['video'] . '?avinfo'), true);
$v['video_image'] = $this->get_video_first_image($v['video'], $video_info);
$v['images'] = '';
$v['content'] = '';
}
}
return $arr;
}
//合并完数据按时间分段
public function sundry($arr){
$times = array_values(array_unique(array_column($arr,'createtime')));
//将数据放到对应的时间分段
$arrs = [];
foreach ($times as $t_k=> $t_v){
$arrs[$t_k]['times'] = $t_v;
$k = 0;
foreach ($arr as $value){
$k+=0;
if($t_v == $value['createtime']){
$arrs[$t_k]['info'][$k] = $value;
$k++;
}
}
}
return $arrs;
}
}
... ...
... ... @@ -5,30 +5,104 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="/assets/cai/css/fileDetail.css">
<link rel="stylesheet" href="/assets/cai/css/common.css">
<link rel="stylesheet" href="/assets/cai/css/file.css">
</head>
<body>
<div class="top">
彩云盘
</div>
<div class="head">
<img class="head-pic" src="/assets/cai/image/zuo_icon@2x.png" alt="" onclick="fileSkip()">
<div class="detail">文件详情</div>
<div class="search">
<img src="/assets/cai/image/zuo_icon@2x.png" alt="" class="search-left">
<div class="search-middle"><img src="/assets/cai/image/sousuo_icon@2x.png" alt=""> <input type="text" placeholder="搜索您需要的文件">
</div>
<div class="search-right">搜索</div>
</div>
<div class="article">
</div>
<div class="file-box">
<!--文件夹-->
{if condition="$data.folder eq ''"}
{else /}
{foreach $data.folder as $vo}
<div class="file-item">
<div class="time">{$vo.times}</div>
{foreach $vo.info as $val}
<div class="file-item-bottom"><img src="/assets/cai/image/wenjain_icon@2x.png" alt="">{$val.folder_name}</div>
{/foreach}
</div>
{/foreach}
{/if}
<!--笔记-->
{if condition="$data.note eq ''"}
{else /}
{foreach $data.note as $vo}
<div class="file-item" onclick="pageSkip()">
<div class="time">{$vo.times}</div>
{foreach $vo.info as $val}
<div class="file-item-bottom"><img src="/assets/cai/image/biji_icon@2x.png" alt="">{$val.name}</div>
{/foreach}
</div>
{/foreach}
{/if}
<!--图片-->
{if condition="$data.pic eq ''"}
{else /}
{foreach $data.pic as $vo}
<div class="file-item pic-item">
<div class="time">{$vo.times}</div>
{foreach $vo.info as $val}
<div class="file-item-bottom pic">
<img src="{$val.images}" alt="" onclick="picSkip()">
</div>
{/foreach}
</div>
{/foreach}
{/if}
<!--视频-->
{if condition="$data.video eq ''"}
{else /}
{foreach $data.video as $vo}
<div class="file-item pic-item">
<div class="time">{$vo.times}</div>
{foreach $vo.info as $val}
<div class="file-item-bottom">
<div class="video" onclick="vedioSkip()">
<img src="/assets/cai/image/图像 171.png" alt="" class="videoImg">
<div class="blackPop"><img src="/assets/cai/image/bofang_icon@2x.png" alt=""></div>
<div class="video" onclick="vedioSkip()">
<img src="/assets/cai/image/图像 171.png" alt="" class="videoImg">
<div class="blackPop"><img src="/assets/cai/image/bofang_icon@2x.png" alt=""></div>
<div class="video" onclick="vedioSkip()">
<img src="/assets/cai/image/图像 171.png" alt="" class="videoImg">
<div class="blackPop"><img src="/assets/cai/image/bofang_icon@2x.png" alt=""></div>
</div>
</div>
</div>
</div>
{/foreach}
</div>
{/foreach}
{/if}
</div>
<div class="end-btn" onclick="appTapOpen()">APP内打开</div>
<div class="appPop">
<div class="appPop-main">
<div class="appPop-main-top">
<img src="/assets/cai/image/logo_icon@2x.png" alt="" class="appPop-main-top-pic">
<div class="appPop-main-top-text">
<div class="appPop-main-top-text-title">彩云盘</div>
<div class="appPop-main-top-text-des">此处是APP简介,写活,此处是APP简介,写活此处是APP简介,写活,两行打点…</div>
<div class="appPop-main-top-text-des">{$data.introduce}</div>
</div>
</div>
... ...