|
@@ -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
|
} |