Showing
1 changed file
with
45 additions
and
0 deletions
public/js/editorial/list.page.js
0 → 100644
1 | +var $ = require('yoho-jquery'), | ||
2 | + lazyLoad = require('yoho-jquery-lazyload'); | ||
3 | + | ||
4 | +require('../common/header'); | ||
5 | +require('../common/return-top'); | ||
6 | + | ||
7 | +lazyLoad($('.content-msg img.lazy')); | ||
8 | + | ||
9 | +$('.editorial-list-page').on('click', '.like-icon', function() { | ||
10 | + | ||
11 | + var $this = $(this), | ||
12 | + msgId = $this.closest('.msg-content').data('id'), | ||
13 | + url; | ||
14 | + | ||
15 | + $this.toggleClass('liked'); | ||
16 | + if ($this.hasClass('liked')) { | ||
17 | + url = '/editorial/info/cancelPraise'; | ||
18 | + } else { | ||
19 | + url = '/editorial/info/praise'; | ||
20 | + } | ||
21 | + $.ajax({ | ||
22 | + type: 'GET', | ||
23 | + url: url, | ||
24 | + data: { | ||
25 | + id: msgId, | ||
26 | + time: new Date().getTime() | ||
27 | + } | ||
28 | + }).then(function(data) { | ||
29 | + if (data.code === 200) { | ||
30 | + $this.next('b').removeClass('num-0').children('.num').html(data.data); | ||
31 | + } | ||
32 | + | ||
33 | + // if (data.code === 200) { | ||
34 | + // if (data.data * 1 === 0) { | ||
35 | + // $this.next('b').addClass('num-0').children('.num').html('0'); // 隐藏数字显示 | ||
36 | + // } else { | ||
37 | + // console.log(data.data) | ||
38 | + // $this.next('b').removeClass('num-0').children('.num').html(data.data); | ||
39 | + // } | ||
40 | + // } | ||
41 | + // prising = false; | ||
42 | + }); | ||
43 | +}).on('mouseenter mouseleave', '.like-icon', function() { | ||
44 | + $(this).closest('.like').toggleClass('hover'); | ||
45 | +}); |
-
Please register or login to post a comment