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

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

... ... @@ -404,6 +404,9 @@ class StarController extends HomeBaseController
//判断是否登录
$login = cmf_is_user_login();
$article_id = $this->request->param('article_id');//文章id
if(empty($article_id)){
$this->apiResponse(0,'收藏失败!');
}
$post_url = $this->request->param('post_url');//文章链接
if($login){
$data['uid'] = cmf_get_current_user_id();
... ... @@ -473,6 +476,9 @@ class StarController extends HomeBaseController
//判断是否登录
$login = cmf_is_user_login();
$article_id = $this->request->param('article_id');//文章id
if(empty($article_id)){
$this->apiResponse(0,'点赞失败!');
}
if($login){
$data['uid'] = cmf_get_current_user_id();
$data['post_id'] = $article_id;
... ... @@ -508,4 +514,47 @@ class StarController extends HomeBaseController
$this->apiResponse(0,'请登录后操作!');
}
}
//更多视频显示是否收藏与点赞
//是否收藏
public function is_collections(){
//判断是否登录
$login = cmf_is_user_login();
$article_id = $this->request->param('id');//文章id
if($login){
$uid = cmf_get_current_user_id();
$collectionModel = new CollectionModel();
$res = $collectionModel->where(['uid'=>$uid,'post_id'=>$article_id])->find();
if($res){
$this->apiResponse(1);
}else{
$this->apiResponse(0);
}
}else{
$this->apiResponse(0);
}
}
//是否点赞
public function is_likes(){
//判断是否登录
$login = cmf_is_user_login();
$article_id = $this->request->param('id');//文章id
if($login){
$uid = cmf_get_current_user_id();
$likeModel = new LikeModel();
$res = $likeModel->where(['uid'=>$uid,'post_id'=>$article_id])->find();
if($res){
$this->apiResponse(1);
}else{
$this->apiResponse(0);
}
}else{
$this->apiResponse(0);
}
}
}
... ...
... ... @@ -69,6 +69,8 @@
<p>
{$vo.post_title}
</p>
<!--id-->
<input type="hidden" value="{$vo.id}" class="li_id">
<input type="hidden" value="{:cmf_get_file_download_url($vo.video)}" class="li_video">
<!--标题-->
<input type="hidden" value="{$vo.post_title}" class="li_post_title">
... ... @@ -90,14 +92,19 @@
<!-- 国家 -->
<div class="show_9_video_asideTxt2">
<!--<p>国家:<span class="city_name"></span></p>-->
<input type="hidden" value="" id="li_id">
<p>取景:<span class="framing"></span></p>
<p>上映时间:<span class="release_time"></span></p>
</div>
<!-- 分享 -->
<div class="show_9_video_asideTxt3 clearfix">
<p>分享:</p>
<input type="hidden" class="collection" value="">
<input type="hidden" class="like" value="">
<img src="__TMPL__/public/assets/starImg/aicon_89.png" alt="">
<img src="__TMPL__/public/assets/starImg/aicon_90.png" alt="">
<img id="collections" src="__TMPL__/public/assets/starImg/bicon_02.png" alt="">
<img id="likes" src="__TMPL__/public/assets/starImg/bicon_03.png" alt="">
</div>
</div>
</div>
... ... @@ -215,15 +222,24 @@
'z-index': "11",
"display": "block"
});
//标题,国家,取景,上映时间
//视频id,标题,国家,取景,上映时间
var id = li_index.children('.li_id').val();
var post_title = li_index.children('.li_post_title').val();
var city_name = li_index.children('.li_city_name').val();
var framing = li_index.children('.li_framing').val();
var release_time = li_index.children('.li_release_time').val();
$('#li_id').val(id);
$('.post_title').text(post_title);
$('.city_name').text(city_name);
$('.framing').text(framing);
$('.release_time').text(release_time);
//是否收藏
is_collections(id);
//是否点赞
is_likes(id);
}
// 点击播放
function bofang() {
... ... @@ -232,6 +248,49 @@
$('.play_button').hide();
$('.video_poster').css('z-index', '-1');
}
//是否收藏
function is_collections(article_id){
var host = 'http://'+window.location.host;
$.ajax({
type: 'POST',
url: '/portal/star/is_collections',
data: {
'id':article_id,
},
dataType: 'json',
async : false,
success: function (data) {
console.log(data);
if (data.code == 1) {
$('#collections').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_15.png')
} else {
$('#collections').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png')
}
}
});
}
//是否点赞
function is_likes(article_id){
var host = 'http://'+window.location.host;
$.ajax({
type: 'POST',
url: '/portal/star/is_likes',
data: {
'id':article_id,
},
dataType: 'json',
async : false,
success: function (data) {
if (data.code == 1) {
$('#likes').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_16.png')
} else {
$('#likes').attr('src',host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png')
}
}
});
}
</script>
</body>
... ...
... ... @@ -31,7 +31,7 @@
</div>
<a href="{$res.pay_url}">
<div class="wares_right_pay">
立即前往购买
立即前往咨询
</div>
</a>
</div>
... ...
... ... @@ -48,7 +48,7 @@
</div>
<div class="Travel_right_spec_pay">
<a href="{$res.pay_url}">
立即前往购买
立即前往咨询
</a>
</div>
</div>
... ...
... ... @@ -32,6 +32,42 @@ $(function(){
$(this).children('img').attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png');
}
});
// 收藏更多视频
$('#collections').click(function() {
if ($(this).attr('src') == host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png') {
var login = operation('/portal/star/collection',1);
if(login == 0){
return false;
}
$(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_15.png');
} else {
var login = operation('/portal/star/cancelCollection',1);
if(login == 0){
return false;
}
$(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png');
}
});
//点赞
$('#likes').click(function() {
if ($(this).attr('src') == host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png') {
var login = operation('/portal/star/like',1);
if(login == 0){
return false;
}
$(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_16.png');
} else {
var login = operation('/portal/star/cancelLike',1);
if(login == 0){
return false;
}
$(this).attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png');
}
});
// 评论判断长度显示与隐藏
if ($('.show_2_pinL').length < 3) {
$('.show_main_more').hide();
... ... @@ -157,8 +193,12 @@ $(function(){
});
//点赞收藏
function operation(url){
var article_id = getUrlParam('id');
function operation(url,id =''){
if(id == ''){
var article_id = getUrlParam('id');
}else{
var article_id = $('#li_id').val();
}
var is_login = 1;
var post_url = window.location.pathname+window.location.search;
$.ajax({
... ...
... ... @@ -87,7 +87,8 @@
{$vo.post_title}
</div>
</div>
<!--id-->
<input type="hidden" value="{$vo.id}" class="li_id">
<input type="hidden" value="{:cmf_get_file_download_url($vo.video)}" class="li_video">
<!--标题-->
<input type="hidden" value="{$vo.post_title}" class="li_post_title">
... ... @@ -106,6 +107,8 @@
<!-- 影片信息 -->
<div class="index_seventh_bottom">
<div class="index_seventh_bottom_one"><span class="post_title"></span></div>
<input type="hidden" value="" id="li_id">
<!-- <div class="index_seventh_bottom_two">国家:<span class="city_name"></span></div> -->
<div class="index_seventh_bottom_three">取景:<span class="framing"></span></div>
<div class="index_seventh_bottom_four">上映时间:<span class="release_time"></span></div>
... ... @@ -117,6 +120,15 @@
<div class="index_seventh_bottom_img1">
<img src="__TMPL__/public/assets/images/cicon_72@2x.png" alt="" />
</div>
<div class="index_seventh_bottom_img1">
<img id="collections" src="__TMPL__/public/assets/images/bicon_02.png" alt="">
</div>
<div class="index_seventh_bottom_img1">
<img id="likes" src="__TMPL__/public/assets/images/bicon_03.png" alt="">
</div>
<input type="hidden" class="collection" value="">
<input type="hidden" class="like" value="">
</div>
</div>
... ... @@ -269,14 +281,65 @@
// });
//标题,国家,取景,上映时间
var id = li_index.children('.li_id').val();
var post_title = li_index.children('.li_post_title').val();
var city_name = li_index.children('.li_city_name').val();
var framing = li_index.children('.li_framing').val();
var release_time = li_index.children('.li_release_time').val();
$('#li_id').val(id);
$('.post_title').text(post_title);
$('.city_name').text(city_name);
$('.framing').text(framing);
$('.release_time').text(release_time);
//是否收藏
is_collections(id);
//是否点赞
is_likes(id);
}
//是否收藏
function is_collections(article_id){
var host = 'http://' + window.location.host + '/themes/simpleboot3_mobile/public/assets';
$.ajax({
type: 'POST',
url: '/portal/star/is_collections',
data: {
'id':article_id,
},
dataType: 'json',
async : false,
success: function (data) {
console.log(data);
if (data.code == 1) {
$('#collections').attr('src',host+'/images/bicon_15.png')
} else {
$('#collections').attr('src',host+'/images/bicon_02.png')
}
}
});
}
//是否点赞
function is_likes(article_id){
var host = 'http://' + window.location.host + '/themes/simpleboot3_mobile/public/assets';
$.ajax({
type: 'POST',
url: '/portal/star/is_likes',
data: {
'id':article_id,
},
dataType: 'json',
async : false,
success: function (data) {
if (data.code == 1) {
$('#likes').attr('src',host+'/images/bicon_16.png')
} else {
$('#likes').attr('src',host+'/images/bicon_03.png')
}
}
});
}
</script>
... ...
... ... @@ -34,7 +34,7 @@
{$res.post_excerpt}
</div>
<a href="{$res.pay_url}">
<div class="index_fifteenth_five">立即前往资讯</div>
<div class="index_fifteenth_five">立即前往咨询</div>
</a>
</div>
</div>
... ...
... ... @@ -61,7 +61,7 @@
</div>
<a href="{$res.pay_url}">
<div class="index_fifteenth_five">
立即前往资讯
立即前往咨询
</div>
</a>
</div>
... ...
... ... @@ -117,7 +117,7 @@
</div>
<div class="first_scene_top_ch">旅游<span>地产</span></div>
<div class="first_scene_top_en">
Tourism Real Estate
Overseas Investment
</div>
</div>
</div>
... ...
... ... @@ -74,6 +74,41 @@ $(function() {
}
});
// 收藏更多视频
$('#collections').click(function() {
if ($(this).attr('src') == host + '/images/bicon_02.png') {
var login = operation('/portal/star/collection',1);
if(login == 0){
return false;
}
$(this).attr('src', host + '/images/bicon_15.png');
} else {
var login = operation('/portal/star/cancelCollection',1);
if(login == 0){
return false;
}
$(this).attr('src', host + '/images/bicon_02.png');
}
});
//点赞
$('#likes').click(function() {
if ($(this).attr('src') == host + '/images/bicon_03.png') {
var login = operation('/portal/star/like',1);
if(login == 0){
return false;
}
$(this).attr('src', host + '/images/bicon_16.png');
} else {
var login = operation('/portal/star/cancelLike',1);
if(login == 0){
return false;
}
$(this).attr('src', host + '/images/bicon_03.png');
}
});
// 评论判断长度显示与隐藏
if ($('.show_2_pinL').length < 3) {
$('.show_main_more').hide();
... ... @@ -216,8 +251,12 @@ function video_mask(msg) {
}, 6000);
}
//点赞收藏
function operation(url) {
var article_id = getUrlParam('id');
function operation(url,id ='') {
if(id == ''){
var article_id = getUrlParam('id');
}else{
var article_id = $('#li_id').val();
}
var is_login = 1;
var post_url = window.location.pathname + window.location.search;
$.ajax({
... ...