作者 jinglong
1 个管道 的构建 通过 耗费 3 秒

修改更多视频点赞收藏功能

@@ -404,6 +404,9 @@ class StarController extends HomeBaseController @@ -404,6 +404,9 @@ class StarController extends HomeBaseController
404 //判断是否登录 404 //判断是否登录
405 $login = cmf_is_user_login(); 405 $login = cmf_is_user_login();
406 $article_id = $this->request->param('article_id');//文章id 406 $article_id = $this->request->param('article_id');//文章id
  407 + if(empty($article_id)){
  408 + $this->apiResponse(0,'收藏失败!');
  409 + }
407 $post_url = $this->request->param('post_url');//文章链接 410 $post_url = $this->request->param('post_url');//文章链接
408 if($login){ 411 if($login){
409 $data['uid'] = cmf_get_current_user_id(); 412 $data['uid'] = cmf_get_current_user_id();
@@ -473,6 +476,9 @@ class StarController extends HomeBaseController @@ -473,6 +476,9 @@ class StarController extends HomeBaseController
473 //判断是否登录 476 //判断是否登录
474 $login = cmf_is_user_login(); 477 $login = cmf_is_user_login();
475 $article_id = $this->request->param('article_id');//文章id 478 $article_id = $this->request->param('article_id');//文章id
  479 + if(empty($article_id)){
  480 + $this->apiResponse(0,'点赞失败!');
  481 + }
476 if($login){ 482 if($login){
477 $data['uid'] = cmf_get_current_user_id(); 483 $data['uid'] = cmf_get_current_user_id();
478 $data['post_id'] = $article_id; 484 $data['post_id'] = $article_id;
@@ -508,4 +514,47 @@ class StarController extends HomeBaseController @@ -508,4 +514,47 @@ class StarController extends HomeBaseController
508 $this->apiResponse(0,'请登录后操作!'); 514 $this->apiResponse(0,'请登录后操作!');
509 } 515 }
510 } 516 }
  517 +
  518 +
  519 +
  520 +
  521 +
  522 + //更多视频显示是否收藏与点赞
  523 + //是否收藏
  524 + public function is_collections(){
  525 + //判断是否登录
  526 + $login = cmf_is_user_login();
  527 + $article_id = $this->request->param('id');//文章id
  528 + if($login){
  529 + $uid = cmf_get_current_user_id();
  530 + $collectionModel = new CollectionModel();
  531 + $res = $collectionModel->where(['uid'=>$uid,'post_id'=>$article_id])->find();
  532 + if($res){
  533 + $this->apiResponse(1);
  534 + }else{
  535 + $this->apiResponse(0);
  536 + }
  537 + }else{
  538 + $this->apiResponse(0);
  539 + }
  540 + }
  541 +
  542 + //是否点赞
  543 + public function is_likes(){
  544 + //判断是否登录
  545 + $login = cmf_is_user_login();
  546 + $article_id = $this->request->param('id');//文章id
  547 + if($login){
  548 + $uid = cmf_get_current_user_id();
  549 + $likeModel = new LikeModel();
  550 + $res = $likeModel->where(['uid'=>$uid,'post_id'=>$article_id])->find();
  551 + if($res){
  552 + $this->apiResponse(1);
  553 + }else{
  554 + $this->apiResponse(0);
  555 + }
  556 + }else{
  557 + $this->apiResponse(0);
  558 + }
  559 + }
511 } 560 }
@@ -69,6 +69,8 @@ @@ -69,6 +69,8 @@
69 <p> 69 <p>
70 {$vo.post_title} 70 {$vo.post_title}
71 </p> 71 </p>
  72 + <!--id-->
  73 + <input type="hidden" value="{$vo.id}" class="li_id">
72 <input type="hidden" value="{:cmf_get_file_download_url($vo.video)}" class="li_video"> 74 <input type="hidden" value="{:cmf_get_file_download_url($vo.video)}" class="li_video">
73 <!--标题--> 75 <!--标题-->
74 <input type="hidden" value="{$vo.post_title}" class="li_post_title"> 76 <input type="hidden" value="{$vo.post_title}" class="li_post_title">
@@ -90,14 +92,19 @@ @@ -90,14 +92,19 @@
90 <!-- 国家 --> 92 <!-- 国家 -->
91 <div class="show_9_video_asideTxt2"> 93 <div class="show_9_video_asideTxt2">
92 <!--<p>国家:<span class="city_name"></span></p>--> 94 <!--<p>国家:<span class="city_name"></span></p>-->
  95 + <input type="hidden" value="" id="li_id">
93 <p>取景:<span class="framing"></span></p> 96 <p>取景:<span class="framing"></span></p>
94 <p>上映时间:<span class="release_time"></span></p> 97 <p>上映时间:<span class="release_time"></span></p>
95 </div> 98 </div>
96 <!-- 分享 --> 99 <!-- 分享 -->
97 <div class="show_9_video_asideTxt3 clearfix"> 100 <div class="show_9_video_asideTxt3 clearfix">
98 <p>分享:</p> 101 <p>分享:</p>
  102 + <input type="hidden" class="collection" value="">
  103 + <input type="hidden" class="like" value="">
99 <img src="__TMPL__/public/assets/starImg/aicon_89.png" alt=""> 104 <img src="__TMPL__/public/assets/starImg/aicon_89.png" alt="">
100 <img src="__TMPL__/public/assets/starImg/aicon_90.png" alt=""> 105 <img src="__TMPL__/public/assets/starImg/aicon_90.png" alt="">
  106 + <img id="collections" src="__TMPL__/public/assets/starImg/bicon_02.png" alt="">
  107 + <img id="likes" src="__TMPL__/public/assets/starImg/bicon_03.png" alt="">
101 </div> 108 </div>
102 </div> 109 </div>
103 </div> 110 </div>
@@ -215,15 +222,24 @@ @@ -215,15 +222,24 @@
215 'z-index': "11", 222 'z-index': "11",
216 "display": "block" 223 "display": "block"
217 }); 224 });
218 - //标题,国家,取景,上映时间 225 + //视频id,标题,国家,取景,上映时间
  226 + var id = li_index.children('.li_id').val();
219 var post_title = li_index.children('.li_post_title').val(); 227 var post_title = li_index.children('.li_post_title').val();
220 var city_name = li_index.children('.li_city_name').val(); 228 var city_name = li_index.children('.li_city_name').val();
221 var framing = li_index.children('.li_framing').val(); 229 var framing = li_index.children('.li_framing').val();
222 var release_time = li_index.children('.li_release_time').val(); 230 var release_time = li_index.children('.li_release_time').val();
  231 + $('#li_id').val(id);
223 $('.post_title').text(post_title); 232 $('.post_title').text(post_title);
224 $('.city_name').text(city_name); 233 $('.city_name').text(city_name);
225 $('.framing').text(framing); 234 $('.framing').text(framing);
226 $('.release_time').text(release_time); 235 $('.release_time').text(release_time);
  236 +
  237 + //是否收藏
  238 + is_collections(id);
  239 +
  240 + //是否点赞
  241 + is_likes(id);
  242 +
227 } 243 }
228 // 点击播放 244 // 点击播放
229 function bofang() { 245 function bofang() {
@@ -232,6 +248,49 @@ @@ -232,6 +248,49 @@
232 $('.play_button').hide(); 248 $('.play_button').hide();
233 $('.video_poster').css('z-index', '-1'); 249 $('.video_poster').css('z-index', '-1');
234 } 250 }
  251 +
  252 + //是否收藏
  253 + function is_collections(article_id){
  254 + var host = 'http://'+window.location.host;
  255 + $.ajax({
  256 + type: 'POST',
  257 + url: '/portal/star/is_collections',
  258 + data: {
  259 + 'id':article_id,
  260 + },
  261 + dataType: 'json',
  262 + async : false,
  263 + success: function (data) {
  264 + console.log(data);
  265 + if (data.code == 1) {
  266 + $('#collections').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_15.png')
  267 + } else {
  268 + $('#collections').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png')
  269 + }
  270 + }
  271 + });
  272 + }
  273 +
  274 + //是否点赞
  275 + function is_likes(article_id){
  276 + var host = 'http://'+window.location.host;
  277 + $.ajax({
  278 + type: 'POST',
  279 + url: '/portal/star/is_likes',
  280 + data: {
  281 + 'id':article_id,
  282 + },
  283 + dataType: 'json',
  284 + async : false,
  285 + success: function (data) {
  286 + if (data.code == 1) {
  287 + $('#likes').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_16.png')
  288 + } else {
  289 + $('#likes').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png')
  290 + }
  291 + }
  292 + });
  293 + }
235 </script> 294 </script>
236 </body> 295 </body>
237 296
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 </div> 31 </div>
32 <a href="{$res.pay_url}"> 32 <a href="{$res.pay_url}">
33 <div class="wares_right_pay"> 33 <div class="wares_right_pay">
34 - 立即前往购买 34 + 立即前往咨询
35 </div> 35 </div>
36 </a> 36 </a>
37 </div> 37 </div>
@@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
48 </div> 48 </div>
49 <div class="Travel_right_spec_pay"> 49 <div class="Travel_right_spec_pay">
50 <a href="{$res.pay_url}"> 50 <a href="{$res.pay_url}">
51 - 立即前往购买 51 + 立即前往咨询
52 </a> 52 </a>
53 </div> 53 </div>
54 </div> 54 </div>
@@ -32,6 +32,42 @@ $(function(){ @@ -32,6 +32,42 @@ $(function(){
32 $(this).children('img').attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png'); 32 $(this).children('img').attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png');
33 } 33 }
34 }); 34 });
  35 +
  36 + // 收藏更多视频
  37 + $('#collections').click(function() {
  38 + if ($(this).attr('src') == host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png') {
  39 + var login = operation('/portal/star/collection',1);
  40 + if(login == 0){
  41 + return false;
  42 + }
  43 + $(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_15.png');
  44 + } else {
  45 + var login = operation('/portal/star/cancelCollection',1);
  46 + if(login == 0){
  47 + return false;
  48 + }
  49 + $(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png');
  50 + }
  51 + });
  52 +
  53 + //点赞
  54 + $('#likes').click(function() {
  55 + if ($(this).attr('src') == host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png') {
  56 + var login = operation('/portal/star/like',1);
  57 + if(login == 0){
  58 + return false;
  59 + }
  60 + $(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_16.png');
  61 + } else {
  62 + var login = operation('/portal/star/cancelLike',1);
  63 + if(login == 0){
  64 + return false;
  65 + }
  66 + $(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png');
  67 + }
  68 + });
  69 +
  70 +
35 // 评论判断长度显示与隐藏 71 // 评论判断长度显示与隐藏
36 if ($('.show_2_pinL').length < 3) { 72 if ($('.show_2_pinL').length < 3) {
37 $('.show_main_more').hide(); 73 $('.show_main_more').hide();
@@ -157,8 +193,12 @@ $(function(){ @@ -157,8 +193,12 @@ $(function(){
157 }); 193 });
158 194
159 //点赞收藏 195 //点赞收藏
160 -function operation(url){ 196 +function operation(url,id =''){
  197 + if(id == ''){
161 var article_id = getUrlParam('id'); 198 var article_id = getUrlParam('id');
  199 + }else{
  200 + var article_id = $('#li_id').val();
  201 + }
162 var is_login = 1; 202 var is_login = 1;
163 var post_url = window.location.pathname+window.location.search; 203 var post_url = window.location.pathname+window.location.search;
164 $.ajax({ 204 $.ajax({
@@ -87,7 +87,8 @@ @@ -87,7 +87,8 @@
87 {$vo.post_title} 87 {$vo.post_title}
88 </div> 88 </div>
89 </div> 89 </div>
90 - 90 + <!--id-->
  91 + <input type="hidden" value="{$vo.id}" class="li_id">
91 <input type="hidden" value="{:cmf_get_file_download_url($vo.video)}" class="li_video"> 92 <input type="hidden" value="{:cmf_get_file_download_url($vo.video)}" class="li_video">
92 <!--标题--> 93 <!--标题-->
93 <input type="hidden" value="{$vo.post_title}" class="li_post_title"> 94 <input type="hidden" value="{$vo.post_title}" class="li_post_title">
@@ -106,6 +107,8 @@ @@ -106,6 +107,8 @@
106 <!-- 影片信息 --> 107 <!-- 影片信息 -->
107 <div class="index_seventh_bottom"> 108 <div class="index_seventh_bottom">
108 <div class="index_seventh_bottom_one"><span class="post_title"></span></div> 109 <div class="index_seventh_bottom_one"><span class="post_title"></span></div>
  110 +
  111 + <input type="hidden" value="" id="li_id">
109 <!-- <div class="index_seventh_bottom_two">国家:<span class="city_name"></span></div> --> 112 <!-- <div class="index_seventh_bottom_two">国家:<span class="city_name"></span></div> -->
110 <div class="index_seventh_bottom_three">取景:<span class="framing"></span></div> 113 <div class="index_seventh_bottom_three">取景:<span class="framing"></span></div>
111 <div class="index_seventh_bottom_four">上映时间:<span class="release_time"></span></div> 114 <div class="index_seventh_bottom_four">上映时间:<span class="release_time"></span></div>
@@ -117,6 +120,15 @@ @@ -117,6 +120,15 @@
117 <div class="index_seventh_bottom_img1"> 120 <div class="index_seventh_bottom_img1">
118 <img src="__TMPL__/public/assets/images/cicon_72@2x.png" alt="" /> 121 <img src="__TMPL__/public/assets/images/cicon_72@2x.png" alt="" />
119 </div> 122 </div>
  123 + <div class="index_seventh_bottom_img1">
  124 + <img id="collections" src="__TMPL__/public/assets/images/bicon_02.png" alt="">
  125 + </div>
  126 + <div class="index_seventh_bottom_img1">
  127 + <img id="likes" src="__TMPL__/public/assets/images/bicon_03.png" alt="">
  128 + </div>
  129 +
  130 + <input type="hidden" class="collection" value="">
  131 + <input type="hidden" class="like" value="">
120 </div> 132 </div>
121 </div> 133 </div>
122 134
@@ -269,14 +281,65 @@ @@ -269,14 +281,65 @@
269 // }); 281 // });
270 282
271 //标题,国家,取景,上映时间 283 //标题,国家,取景,上映时间
  284 + var id = li_index.children('.li_id').val();
272 var post_title = li_index.children('.li_post_title').val(); 285 var post_title = li_index.children('.li_post_title').val();
273 var city_name = li_index.children('.li_city_name').val(); 286 var city_name = li_index.children('.li_city_name').val();
274 var framing = li_index.children('.li_framing').val(); 287 var framing = li_index.children('.li_framing').val();
275 var release_time = li_index.children('.li_release_time').val(); 288 var release_time = li_index.children('.li_release_time').val();
  289 + $('#li_id').val(id);
276 $('.post_title').text(post_title); 290 $('.post_title').text(post_title);
277 $('.city_name').text(city_name); 291 $('.city_name').text(city_name);
278 $('.framing').text(framing); 292 $('.framing').text(framing);
279 $('.release_time').text(release_time); 293 $('.release_time').text(release_time);
  294 +
  295 + //是否收藏
  296 + is_collections(id);
  297 +
  298 + //是否点赞
  299 + is_likes(id);
  300 + }
  301 +
  302 + //是否收藏
  303 + function is_collections(article_id){
  304 + var host = 'http://' + window.location.host + '/themes/simpleboot3_mobile/public/assets';
  305 + $.ajax({
  306 + type: 'POST',
  307 + url: '/portal/star/is_collections',
  308 + data: {
  309 + 'id':article_id,
  310 + },
  311 + dataType: 'json',
  312 + async : false,
  313 + success: function (data) {
  314 + console.log(data);
  315 + if (data.code == 1) {
  316 + $('#collections').attr('src',host+'/images/bicon_15.png')
  317 + } else {
  318 + $('#collections').attr('src',host+'/images/bicon_02.png')
  319 + }
  320 + }
  321 + });
  322 + }
  323 +
  324 + //是否点赞
  325 + function is_likes(article_id){
  326 + var host = 'http://' + window.location.host + '/themes/simpleboot3_mobile/public/assets';
  327 + $.ajax({
  328 + type: 'POST',
  329 + url: '/portal/star/is_likes',
  330 + data: {
  331 + 'id':article_id,
  332 + },
  333 + dataType: 'json',
  334 + async : false,
  335 + success: function (data) {
  336 + if (data.code == 1) {
  337 + $('#likes').attr('src',host+'/images/bicon_16.png')
  338 + } else {
  339 + $('#likes').attr('src',host+'/images/bicon_03.png')
  340 + }
  341 + }
  342 + });
280 } 343 }
281 </script> 344 </script>
282 345
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 {$res.post_excerpt} 34 {$res.post_excerpt}
35 </div> 35 </div>
36 <a href="{$res.pay_url}"> 36 <a href="{$res.pay_url}">
37 - <div class="index_fifteenth_five">立即前往资讯</div> 37 + <div class="index_fifteenth_five">立即前往咨询</div>
38 </a> 38 </a>
39 </div> 39 </div>
40 </div> 40 </div>
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 </div> 61 </div>
62 <a href="{$res.pay_url}"> 62 <a href="{$res.pay_url}">
63 <div class="index_fifteenth_five"> 63 <div class="index_fifteenth_five">
64 - 立即前往资讯 64 + 立即前往咨询
65 </div> 65 </div>
66 </a> 66 </a>
67 </div> 67 </div>
@@ -117,7 +117,7 @@ @@ -117,7 +117,7 @@
117 </div> 117 </div>
118 <div class="first_scene_top_ch">旅游<span>地产</span></div> 118 <div class="first_scene_top_ch">旅游<span>地产</span></div>
119 <div class="first_scene_top_en"> 119 <div class="first_scene_top_en">
120 - Tourism Real Estate 120 + Overseas Investment
121 </div> 121 </div>
122 </div> 122 </div>
123 </div> 123 </div>
@@ -74,6 +74,41 @@ $(function() { @@ -74,6 +74,41 @@ $(function() {
74 } 74 }
75 }); 75 });
76 76
  77 + // 收藏更多视频
  78 + $('#collections').click(function() {
  79 + if ($(this).attr('src') == host + '/images/bicon_02.png') {
  80 + var login = operation('/portal/star/collection',1);
  81 + if(login == 0){
  82 + return false;
  83 + }
  84 + $(this).attr('src', host + '/images/bicon_15.png');
  85 + } else {
  86 + var login = operation('/portal/star/cancelCollection',1);
  87 + if(login == 0){
  88 + return false;
  89 + }
  90 + $(this).attr('src', host + '/images/bicon_02.png');
  91 + }
  92 + });
  93 +
  94 + //点赞
  95 + $('#likes').click(function() {
  96 + if ($(this).attr('src') == host + '/images/bicon_03.png') {
  97 + var login = operation('/portal/star/like',1);
  98 + if(login == 0){
  99 + return false;
  100 + }
  101 + $(this).attr('src', host + '/images/bicon_16.png');
  102 + } else {
  103 + var login = operation('/portal/star/cancelLike',1);
  104 + if(login == 0){
  105 + return false;
  106 + }
  107 + $(this).attr('src', host + '/images/bicon_03.png');
  108 + }
  109 + });
  110 +
  111 +
77 // 评论判断长度显示与隐藏 112 // 评论判断长度显示与隐藏
78 if ($('.show_2_pinL').length < 3) { 113 if ($('.show_2_pinL').length < 3) {
79 $('.show_main_more').hide(); 114 $('.show_main_more').hide();
@@ -216,8 +251,12 @@ function video_mask(msg) { @@ -216,8 +251,12 @@ function video_mask(msg) {
216 }, 6000); 251 }, 6000);
217 } 252 }
218 //点赞收藏 253 //点赞收藏
219 -function operation(url) { 254 +function operation(url,id ='') {
  255 + if(id == ''){
220 var article_id = getUrlParam('id'); 256 var article_id = getUrlParam('id');
  257 + }else{
  258 + var article_id = $('#li_id').val();
  259 + }
221 var is_login = 1; 260 var is_login = 1;
222 var post_url = window.location.pathname + window.location.search; 261 var post_url = window.location.pathname + window.location.search;
223 $.ajax({ 262 $.ajax({