Authored by xuqi

guang info prise

@@ -51,21 +51,28 @@ function setLazyLoadAndMellipsis($infos) { @@ -51,21 +51,28 @@ function setLazyLoadAndMellipsis($infos) {
51 function initInfosEvt($container) { 51 function initInfosEvt($container) {
52 $container.delegate('.like-btn', 'touchstart', function(e) { 52 $container.delegate('.like-btn', 'touchstart', function(e) {
53 var $likeBtn = $(e.currentTarget), 53 var $likeBtn = $(e.currentTarget),
54 - $info = $likeBtn.closest('.guang-info'); 54 + $info = $likeBtn.closest('.guang-info'),
  55 + opt = 'ok';
  56 +
  57 + if ($likeBtn.hasClass('like')) {
  58 + opt = 'cancel';
  59 + }
55 60
56 $.ajax({ 61 $.ajax({
57 - type: 'GET',  
58 - url: '/guang/info/prise', //TODO:cancelPrise 62 + type: 'POST',
  63 + url: '/guang/opt/praiseArticle',
59 data: { 64 data: {
60 - id: $info.data('id') 65 + id: $info.data('id'),
  66 + opt: opt
61 }, 67 },
62 success: function(data) { 68 success: function(data) {
63 var code = data.code; 69 var code = data.code;
64 70
65 if (code === 200) { 71 if (code === 200) {
66 $likeBtn.next('.like-count').text(data.data); 72 $likeBtn.next('.like-count').text(data.data);
67 - } else if (code === 400) {  
68 - tip.show('未登录'); 73 +
  74 + //切换点赞状态
  75 + $likeBtn.toggleClass('like');
69 } 76 }
70 }, 77 },
71 error: function() { 78 error: function() {