좋아요 기능 질문입니다

좋아요 기능 질문입니다

QA

좋아요 기능 질문입니다

본문

백단기능은 만들어져 있는상태라 제가 프론트로 진행을 하는중 입니다.

다만 문제가 새로고침을 하고 나서 좋아요가 풀린다는 점인데 백단 type값에 값을 넣어서 반환하면 된다고 하는데

제가 이해를 잘 못했는지 잘 안되어서 최후로 여쭤봅니다... 고수님들 보시고 조언좀 부탁드립니다ㅜㅜ


function subsCribe(){
let mb_id = "<?php echo $member["mb_id"]; ?>";
let if_id = "<?php echo $if_id; ?>";
let type = $('.profile_bell').data('subscribe');
 
//console.log(subscribeData);
 
$.ajax({
url: "url",
data: {
"mb_id" : mb_id,
"influencer_id" : influencer_id
},
type: "GET",
success : function(data){
console.log(data);
if(type == 1){
$('#pr_bell').attr("src", "/img/icons/profile_orange_bell.svg");
data.result.is_subscribe = true;
}else {
$('#pr_bell').attr("src", "/img/icons/profile_bell.svg");
data.result.is_subscribe = false;
}
console.log(type,'::::::type')
},
error : function(xhr, status, error){
window.alert(data['msg']);
}
});
}

 
function getSubscribeClick(){
let type = $('.profile_bell').data('subscribe');
let mb_id = "<?php echo $member["mb_id"]; ?>";
let if_id = "<?php echo $if_id; ?>";
 
if(type == 0){
type = "following";
}else {
type = "unfollowing";
}
 
console.log(type);

 
$.ajax({
url : "url",
type: "POST",
data : {
"if_id": if_id,
"mb_id": mb_id,
"type": type
},
success : function(data){
console.log(data);
console.log(type);
if(mb_id){
if(type == 'following'){
$('#pr_bell').attr("src", "/img/icons/profile_orange_bell.svg");
//$('.profile_bell').removeData();
$('.profile_bell').data('subscribe', 1);
}else {
$('#pr_bell').attr("src", "/img/icons/profile_bell.svg");
//$('.profile_bell').removeData();
$('.profile_bell').data('subscribe', 0);
}
subsCribe();
}else {
 
}
},
error : function(xhr, status, error){
window.alert(data['msg']);
}
 
});
 
}
 

이 질문에 댓글 쓰기 :

답변 2

if(type == 1){

$('#pr_bell').attr("src", "/img/icons/profile_orange_bell.svg");

data.result.is_subscribe = true;

}else {

좋아요"가 이 부분인 듯한데

view.skin.php에서 

해당 회원이 좋아요를 클릭했는지 확인해서

이 이미지를 보여주면 되지 않을까요

위 소스는 그냥 단순 스크립트로 처리되어지는 부분만 보여지는 부분이고요
좋아요 기능이 이미 반영된건지
현재 회원으로 좋아요한 mb_id와 if_id 값과 type값이 following (좋아요) 값이 존재한다면 반영된 아이콘으로 변경하여 처리된걸로 처리해 주셔야 할듯 합니다.

좋아요 반영된 데이터를 db에서 가져와서 처리해 주셔야 하는 부분입니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 66
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT