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

修改接口

@@ -91,7 +91,62 @@ class Index extends Frontend @@ -91,7 +91,62 @@ class Index extends Frontend
91 $user_id = $this->request->param('user_id'); 91 $user_id = $this->request->param('user_id');
92 $file_id = $this->request->param('file_id'); 92 $file_id = $this->request->param('file_id');
93 93
  94 + //文件夹
  95 + $folder = Db::name('folder')
  96 + ->where('pid',$file_id)
  97 + ->where('is_up',1)
  98 + ->select();
  99 +
  100 + foreach ($folder as &$v){
  101 + $v['createtime'] = date('Y-m-d',$v['createtime']);
  102 + }
  103 + $times = array_values(array_unique(array_column($folder,'createtime')));
  104 + //将数据放到对应的时间分段
  105 + $arrs = [];
  106 + foreach ($times as $t_k=> $t_v){
  107 + $arrs[$t_k]['times'] = $t_v;
  108 + $k = 0;
  109 + foreach ($folder as $value){
  110 + $k+=0;
  111 + if($t_v == $value['createtime']){
  112 + $arrs[$t_k]['info'][$k] = $value;
  113 + $k++;
  114 + }
  115 + }
  116 + }
  117 + $data['folder'] = $arrs;
  118 +
  119 +
  120 + //笔记
  121 + $note['folder_id'] = ['eq',$file_id];
  122 + $note['is_up'] = ['eq',1];
  123 + $z_tiao['a.folder_id'] = ['eq',$file_id];
  124 + $z_tiao['b.is_up'] = ['eq',1];
  125 + $note = $this->myfile(1,$note);
  126 + $zhuan_note = $this->zhuan(1,$z_tiao);
  127 + $gong = $this->gong(1,$note,$zhuan_note);
  128 + $data['note'] = $this->sundry($gong);
  129 +
  130 + //图片
  131 + $pic['folder_id'] = ['eq',$file_id];
  132 + $pic_tiao['a.folder_id'] = ['eq',$file_id];
  133 + $pic = $this->myfile(2,$pic);
  134 + $zhuan_pic = $this->zhuan(2,$pic_tiao);
  135 + $gong1 = $this->gong(2,$pic,$zhuan_pic);
  136 + $data['pic'] = $this->sundry($gong1);
  137 +
  138 + //视频
  139 + $video['folder_id'] = ['eq',$file_id];
  140 + $video_tiao['a.folder_id'] = ['eq',$file_id];
  141 + $video = $this->myfile(3,$video);
  142 + $zhuan_video = $this->zhuan(3,$video_tiao);
  143 + $gong2 = $this->gong(3,$video,$zhuan_video);
  144 + $data['video'] = $this->sundry($gong2);
94 145
  146 +
  147 + $text = Db::name('official')->where('id',1)->find();
  148 + $data['introduce'] = $text['introduce'];
  149 + $this->assign('data',$data);
95 return $this->fetch(); 150 return $this->fetch();
96 } 151 }
97 152
@@ -105,4 +160,99 @@ class Index extends Frontend @@ -105,4 +160,99 @@ class Index extends Frontend
105 } 160 }
106 return $video_url.'?vframe/jpg/offset/1/w/'.$width.'/h/'.$height; 161 return $video_url.'?vframe/jpg/offset/1/w/'.$width.'/h/'.$height;
107 } 162 }
  163 +
  164 +
  165 +
  166 +
  167 + //通过传入类型获取我自己的不同文件
  168 + public function myfile($type,$where){
  169 + $data = Db::name('savemes')
  170 + ->where($where)
  171 + ->where('type',$type)
  172 + ->field('id,user_id,type,name,share_url,images,video,content,is_open,is_up,createtime')
  173 + ->order('createtime desc')
  174 + ->select();
  175 + return $data;
  176 + }
  177 + //通过传入类型获取转存的不同文件
  178 + public function zhuan($type,$tiao){
  179 + $rotor = Db::name('rotor')
  180 + ->alias('a')
  181 + ->join('savemes b','a.savemes_id = b.id')
  182 + ->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')
  183 + ->where('b.type',$type)
  184 + ->where($tiao)
  185 + ->order('a.createtime desc')
  186 + ->select();
  187 + return $rotor;
  188 + }
  189 +
  190 + //各种类型的文件 转存以及自己的文件
  191 + public function gong($type,$arr1,$arr2){
  192 + $qiniu = get_addon_config('qiniu')['cdnurl'];
  193 + if(!empty($arr2)){
  194 + foreach ($arr2 as &$v_1){
  195 + $v_1['is_zhuan'] = 1;
  196 + $v_1['is_real'] = 2;
  197 + }
  198 + $arr = array_merge($arr1,$arr2);
  199 + }else{
  200 + $arr = $arr1;
  201 + }
  202 +
  203 + //笔记类型
  204 + if($type == 1){
  205 + foreach ($arr as &$v){
  206 + $v['nowtime'] = date('Y-m-d',$v['createtime']);
  207 + $v['createtime'] = date('m-d',$v['createtime']);
  208 + $v['images'] = '';
  209 + $v['video'] = '';
  210 + $v['video_image'] = '';
  211 + }
  212 + } elseif ($type == 2){
  213 + //图片类型
  214 + foreach ($arr as &$v){
  215 + $v['nowtime'] = date('Y-m-d',$v['createtime']);
  216 + $v['createtime'] = date('m-d',$v['createtime']);
  217 + $v['images'] = $qiniu.$v['images'];
  218 + $v['video'] = '';
  219 + $v['video_image'] = '';
  220 + $v['content'] = '';
  221 + }
  222 + }elseif ($type == 3){
  223 + //视频类型
  224 + foreach ($arr as &$v){
  225 + $v['nowtime'] = date('Y-m-d',$v['createtime']);
  226 + $v['createtime'] = date('m-d',$v['createtime']);
  227 + $v['video'] = $qiniu.$v['video'];
  228 + // 获取视频第一帧图片
  229 + $video_info = json_decode(file_get_contents($v['video'] . '?avinfo'), true);
  230 + $v['video_image'] = $this->get_video_first_image($v['video'], $video_info);
  231 + $v['images'] = '';
  232 + $v['content'] = '';
  233 + }
  234 + }
  235 + return $arr;
  236 + }
  237 +
  238 +
  239 + //合并完数据按时间分段
  240 + public function sundry($arr){
  241 + $times = array_values(array_unique(array_column($arr,'createtime')));
  242 + //将数据放到对应的时间分段
  243 + $arrs = [];
  244 + foreach ($times as $t_k=> $t_v){
  245 + $arrs[$t_k]['times'] = $t_v;
  246 + $k = 0;
  247 + foreach ($arr as $value){
  248 + $k+=0;
  249 + if($t_v == $value['createtime']){
  250 + $arrs[$t_k]['info'][$k] = $value;
  251 + $k++;
  252 + }
  253 + }
  254 + }
  255 + return $arrs;
  256 +
  257 + }
108 } 258 }
@@ -5,30 +5,104 @@ @@ -5,30 +5,104 @@
5 <meta charset="UTF-8"> 5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Document</title> 7 <title>Document</title>
8 - <link rel="stylesheet" href="/assets/cai/css/fileDetail.css">  
9 <link rel="stylesheet" href="/assets/cai/css/common.css"> 8 <link rel="stylesheet" href="/assets/cai/css/common.css">
  9 + <link rel="stylesheet" href="/assets/cai/css/file.css">
10 </head> 10 </head>
11 11
12 <body> 12 <body>
13 <div class="top"> 13 <div class="top">
14 彩云盘 14 彩云盘
15 </div> 15 </div>
16 -<div class="head">  
17 - <img class="head-pic" src="/assets/cai/image/zuo_icon@2x.png" alt="" onclick="fileSkip()">  
18 - <div class="detail">文件详情</div> 16 +<div class="search">
  17 + <img src="/assets/cai/image/zuo_icon@2x.png" alt="" class="search-left">
  18 + <div class="search-middle"><img src="/assets/cai/image/sousuo_icon@2x.png" alt=""> <input type="text" placeholder="搜索您需要的文件">
  19 + </div>
  20 + <div class="search-right">搜索</div>
19 </div> 21 </div>
20 -<div class="article">  
21 22
22 -</div>  
23 23
  24 +<div class="file-box">
  25 + <!--文件夹-->
  26 + {if condition="$data.folder eq ''"}
  27 +
  28 + {else /}
  29 + {foreach $data.folder as $vo}
  30 + <div class="file-item">
  31 + <div class="time">{$vo.times}</div>
  32 + {foreach $vo.info as $val}
  33 + <div class="file-item-bottom"><img src="/assets/cai/image/wenjain_icon@2x.png" alt="">{$val.folder_name}</div>
  34 + {/foreach}
  35 + </div>
  36 + {/foreach}
  37 + {/if}
  38 +
  39 +
  40 + <!--笔记-->
  41 + {if condition="$data.note eq ''"}
  42 + {else /}
  43 + {foreach $data.note as $vo}
  44 + <div class="file-item" onclick="pageSkip()">
  45 + <div class="time">{$vo.times}</div>
  46 + {foreach $vo.info as $val}
  47 + <div class="file-item-bottom"><img src="/assets/cai/image/biji_icon@2x.png" alt="">{$val.name}</div>
  48 + {/foreach}
  49 + </div>
  50 + {/foreach}
  51 + {/if}
  52 +
  53 +
  54 + <!--图片-->
  55 + {if condition="$data.pic eq ''"}
  56 + {else /}
  57 + {foreach $data.pic as $vo}
  58 + <div class="file-item pic-item">
  59 + <div class="time">{$vo.times}</div>
  60 + {foreach $vo.info as $val}
  61 + <div class="file-item-bottom pic">
  62 + <img src="{$val.images}" alt="" onclick="picSkip()">
  63 + </div>
  64 + {/foreach}
  65 + </div>
  66 + {/foreach}
  67 + {/if}
  68 +
  69 +
  70 + <!--视频-->
  71 + {if condition="$data.video eq ''"}
  72 + {else /}
  73 + {foreach $data.video as $vo}
  74 + <div class="file-item pic-item">
  75 + <div class="time">{$vo.times}</div>
  76 + {foreach $vo.info as $val}
  77 + <div class="file-item-bottom">
  78 + <div class="video" onclick="vedioSkip()">
  79 + <img src="/assets/cai/image/图像 171.png" alt="" class="videoImg">
  80 + <div class="blackPop"><img src="/assets/cai/image/bofang_icon@2x.png" alt=""></div>
  81 + <div class="video" onclick="vedioSkip()">
  82 + <img src="/assets/cai/image/图像 171.png" alt="" class="videoImg">
  83 + <div class="blackPop"><img src="/assets/cai/image/bofang_icon@2x.png" alt=""></div>
  84 + <div class="video" onclick="vedioSkip()">
  85 + <img src="/assets/cai/image/图像 171.png" alt="" class="videoImg">
  86 + <div class="blackPop"><img src="/assets/cai/image/bofang_icon@2x.png" alt=""></div>
  87 + </div>
  88 + </div>
  89 + </div>
  90 + </div>
  91 + {/foreach}
  92 + </div>
  93 + {/foreach}
  94 + {/if}
  95 +
  96 +</div>
24 <div class="end-btn" onclick="appTapOpen()">APP内打开</div> 97 <div class="end-btn" onclick="appTapOpen()">APP内打开</div>
  98 +
25 <div class="appPop"> 99 <div class="appPop">
26 <div class="appPop-main"> 100 <div class="appPop-main">
27 <div class="appPop-main-top"> 101 <div class="appPop-main-top">
28 <img src="/assets/cai/image/logo_icon@2x.png" alt="" class="appPop-main-top-pic"> 102 <img src="/assets/cai/image/logo_icon@2x.png" alt="" class="appPop-main-top-pic">
29 <div class="appPop-main-top-text"> 103 <div class="appPop-main-top-text">
30 <div class="appPop-main-top-text-title">彩云盘</div> 104 <div class="appPop-main-top-text-title">彩云盘</div>
31 - <div class="appPop-main-top-text-des">此处是APP简介,写活,此处是APP简介,写活此处是APP简介,写活,两行打点…</div> 105 + <div class="appPop-main-top-text-des">{$data.introduce}</div>
32 </div> 106 </div>
33 </div> 107 </div>
34 108