作者 景龙
1 个管道 的构建 通过 耗费 0 秒

增加后台视频的首页封面图字段,解决封面图片变形问题

@@ -92,7 +92,7 @@ class IndexController extends HomeBaseController @@ -92,7 +92,7 @@ class IndexController extends HomeBaseController
92 // cache('res_xqyy', $res_xqyy,86400);//有效期一天 92 // cache('res_xqyy', $res_xqyy,86400);//有效期一天
93 // } 93 // }
94 $position = CityCategoryModel::xqyy; 94 $position = CityCategoryModel::xqyy;
95 - $field = 'id,more,thumbnail'; 95 + $field = 'id,more,index_thumbnail';
96 $res_xqyy = $this->getVideoIndex($position,$field,1); 96 $res_xqyy = $this->getVideoIndex($position,$field,1);
97 foreach($res_xqyy as &$value){ 97 foreach($res_xqyy as &$value){
98 $video = json_decode($value['more'],true); 98 $video = json_decode($value['more'],true);
@@ -149,7 +149,7 @@ class RegionController extends HomeBaseController @@ -149,7 +149,7 @@ class RegionController extends HomeBaseController
149 $position['city_id'] = $city_id; 149 $position['city_id'] = $city_id;
150 $position['category_id'] = CityCategoryModel::xqyy; 150 $position['category_id'] = CityCategoryModel::xqyy;
151 $field = 'id,post_title,framing,release_time,city_id,more,thumbnail'; 151 $field = 'id,post_title,framing,release_time,city_id,more,thumbnail';
152 - $res = $this->getVideoArticlePage($position,$field); 152 + $res = $star->getChildArticlePage($position,$field);
153 foreach($res['data']['data'] as &$value){ 153 foreach($res['data']['data'] as &$value){
154 $more = json_decode($value['more'],true); 154 $more = json_decode($value['more'],true);
155 $value['video'] = isset($more['video']) && !empty($more['video'])?$more['video']:''; 155 $value['video'] = isset($more['video']) && !empty($more['video'])?$more['video']:'';
@@ -166,34 +166,6 @@ class RegionController extends HomeBaseController @@ -166,34 +166,6 @@ class RegionController extends HomeBaseController
166 return $this->fetch(); 166 return $this->fetch();
167 } 167 }
168 168
169 - //获取更多视频  
170 - public function getVideoArticlePage($position,$field,$limit = ''){  
171 - $pre = CityCategoryModel::pre;  
172 - $limit = empty($limit)?$this->more_limit:$limit;  
173 - $post_id = Db::table($pre.'portal_category_post')  
174 - ->whereIn('category_id',$position['category_id'])  
175 - ->field('post_id')  
176 - ->select()  
177 - ->toArray();  
178 - $post_id = array_column($post_id,'post_id');  
179 - //查询文章  
180 - if($position['city_id'] == 0){  
181 - //所有  
182 - $where = ['delete_time'=>0,'is_show'=>0];  
183 - }else{  
184 - $where = ['city_id'=>$position['city_id'],'delete_time'=>0,'is_show'=>0];  
185 - }  
186 - $res = Db::table($pre.'portal_post')  
187 - ->whereIn('id',$post_id)  
188 - ->where($where)  
189 - ->field($field)  
190 - ->order('weigh desc')  
191 - ->paginate($limit,false,['query'=>request()->param()]);  
192 - $arr['data'] = $res->toArray();  
193 - $arr['page'] = $res->render();  
194 - return $arr;  
195 - }  
196 -  
197 //获取城市名称 169 //获取城市名称
198 public function getVideoCityName(){ 170 public function getVideoCityName(){
199 $res = Db::name('city_category') 171 $res = Db::name('city_category')
@@ -113,7 +113,26 @@ @@ -113,7 +113,26 @@
113 <div class="col-md-3"> 113 <div class="col-md-3">
114 <table class="table table-bordered"> 114 <table class="table table-bordered">
115 <tr> 115 <tr>
116 - <th><b>视频封面图<span class="form-required">*</span></b></th> 116 + <th><b>视频首页封面图</b></th>
  117 + </tr>
  118 + <tr>
  119 + <td>
  120 + <div style="text-align: center;">
  121 + <input type="hidden" name="post[index_thumbnail]" id="index_thumbnail" value="">
  122 + <a href="javascript:uploadOneImage('图片上传','#index_thumbnail');">
  123 + <img src="__TMPL__/public/assets/images/default-thumbnail.png"
  124 + id="index_thumbnail-preview"
  125 + width="135" style="cursor: pointer"/>
  126 + </a>
  127 + <input type="button" class="btn btn-sm btn-cancel-index_thumbnail" value="取消图片">
  128 + </div>
  129 + <div style="margin-top:30px;">
  130 + <span class="form-required">图片参考尺寸:1200*675</span>
  131 + </div>
  132 + </td>
  133 + </tr>
  134 + <tr>
  135 + <th><b>视频更多封面图<span class="form-required">*</span></b></th>
117 </tr> 136 </tr>
118 <tr> 137 <tr>
119 <td> 138 <td>
@@ -126,6 +145,9 @@ @@ -126,6 +145,9 @@
126 </a> 145 </a>
127 <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片"> 146 <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
128 </div> 147 </div>
  148 + <div style="margin-top:30px;">
  149 + <span class="form-required">图片参考尺寸:955*426</span>
  150 + </div>
129 </td> 151 </td>
130 </tr> 152 </tr>
131 <tr> 153 <tr>
@@ -160,7 +182,11 @@ @@ -160,7 +182,11 @@
160 editorcontent.sync(); 182 editorcontent.sync();
161 } catch (err) { 183 } catch (err) {
162 } 184 }
163 - 185 + //首页缩略图
  186 + $('.btn-cancel-index_thumbnail').click(function () {
  187 + $('#index_thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  188 + $('#index_thumbnail').val('');
  189 + });
164 $('.btn-cancel-thumbnail').click(function () { 190 $('.btn-cancel-thumbnail').click(function () {
165 $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png'); 191 $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
166 $('#thumbnail').val(''); 192 $('#thumbnail').val('');
@@ -112,7 +112,33 @@ @@ -112,7 +112,33 @@
112 <div class="col-md-3"> 112 <div class="col-md-3">
113 <table class="table table-bordered"> 113 <table class="table table-bordered">
114 <tr> 114 <tr>
115 - <th>视频封面图<span class="form-required">*</span></th> 115 + <th>首页视频封面图</th>
  116 + </tr>
  117 + <tr>
  118 + <td>
  119 + <div style="text-align: center;">
  120 + <input type="hidden" name="post[index_thumbnail]" id="index_thumbnail"
  121 + value="{$post.index_thumbnail|default=''}">
  122 + <a href="javascript:uploadOneImage('图片上传','#index_thumbnail');">
  123 + <if condition="empty($post.index_thumbnail)">
  124 + <img src="__TMPL__/public/assets/images/default-thumbnail.png"
  125 + id="index_thumbnail-preview"
  126 + width="135" style="cursor: pointer"/>
  127 + <else/>
  128 + <img src="{:cmf_get_image_preview_url($post.index_thumbnail)}"
  129 + id="index_thumbnail-preview"
  130 + width="135" style="cursor: pointer"/>
  131 + </if>
  132 + </a>
  133 + <input type="button" class="btn btn-sm btn-cancel-index_thumbnail" value="取消图片">
  134 + </div>
  135 + <div style="margin-top:30px;">
  136 + <span class="form-required">图片参考尺寸:1200*675</span>
  137 + </div>
  138 + </td>
  139 + </tr>
  140 + <tr>
  141 + <th>视频更多封面图<span class="form-required">*</span></th>
116 </tr> 142 </tr>
117 <tr> 143 <tr>
118 <td> 144 <td>
@@ -132,6 +158,9 @@ @@ -132,6 +158,9 @@
132 </a> 158 </a>
133 <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片"> 159 <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
134 </div> 160 </div>
  161 + <div style="margin-top:30px;">
  162 + <span class="form-required">图片参考尺寸:955*426</span>
  163 + </div>
135 </td> 164 </td>
136 </tr> 165 </tr>
137 <tr> 166 <tr>
@@ -173,6 +202,11 @@ @@ -173,6 +202,11 @@
173 } catch (err) { 202 } catch (err) {
174 } 203 }
175 204
  205 + //首页缩略图
  206 + $('.btn-cancel-index_thumbnail').click(function () {
  207 + $('#index_thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  208 + $('#index_thumbnail').val('');
  209 + });
176 $('.btn-cancel-thumbnail').click(function () { 210 $('.btn-cancel-thumbnail').click(function () {
177 $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png'); 211 $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
178 $('#thumbnail').val(''); 212 $('#thumbnail').val('');
@@ -688,7 +688,7 @@ @@ -688,7 +688,7 @@
688 <div class="star_video"> 688 <div class="star_video">
689 <notempty name="res_xqyy"> 689 <notempty name="res_xqyy">
690 <video id="video" width="100%" height="675" src="{:cmf_get_file_download_url($res_xqyy.video)}" controlsList="nodownload"></video> 690 <video id="video" width="100%" height="675" src="{:cmf_get_file_download_url($res_xqyy.video)}" controlsList="nodownload"></video>
691 - <img class="show_in_poster" src="{:cmf_get_image_url($res_xqyy.thumbnail)}" alt=""> 691 + <img class="show_in_poster" src="{:cmf_get_image_url($res_xqyy.index_thumbnail)}" alt="">
692 <else/> 692 <else/>
693 <video id="video" width="100%" height="675" src="__TMPL__//public/assets/starImg/video.mp4" controlsList="nodownload"></video> 693 <video id="video" width="100%" height="675" src="__TMPL__//public/assets/starImg/video.mp4" controlsList="nodownload"></video>
694 <img class="show_in_poster" src="__TMPL__/public/assets/starImg/bicon_34.png" alt=""> 694 <img class="show_in_poster" src="__TMPL__/public/assets/starImg/bicon_34.png" alt="">