1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
function getData (index,type, name ) {
$.ajax({
type : "POST",
url : host+"vote.php/Index/userList",
data : {
type: type,
limit:1000,
name: name || '',
open_id: localStorage.openId
},
success : function(result) {
$('#owner-box').children('.owner-item').eq(index).children('.loading').hide();
var html='';
var resultData = result.data.list;
resultData.forEach(function( val, index ) {
html+='<li>'+
'<div class="item">'+
(val.rank !==0?('<p class="rank '+(val.rank<4?'rank0_3':'rank4_10')+'">第'+val.rank+'名</p>'):'')+
'<a href="./detail.html?uflag='+val.uflag+'">'+
'<p class="thum">'+
'<img src="'+val.avatar_pic+'">'+
'</p>'+
'<div class="info">'+
'<p>'+val.uname+'</p>'+
'<p>'+val.no+'</p>'+
'</div>'+
'</a>'+
'<p class="amount">'+
'<span class="vote-amount">'+val.vote+'</span>'+
'<span class="vote '+(val.voteable==1?'':'disabled')+'" data-flag="'+val.uflag+'">投票</span>'+
'</p>'+
'</div>'+
'</li>'
})
if (html=='') {
$('#owner-box').children('.owner-item').eq(index).find('.no-data').show();
} else {
$('#owner-box').children('.owner-item').eq(index).find('.no-data').hide();
}
$('#owner-box').children('.owner-item').eq(index).children('ul').html(html);
}
});
}
getData(0,'cook');
$('.search').click(function (e) {
var inputVal = $('.inp').val();
if (liIndex === 0) {
getData(0,'cook' ,inputVal)
} else if (liIndex === 1) {
getData(1,'pop' ,inputVal)
} else if (liIndex === 2) {
getData(2,'cloth' ,inputVal)
}
$('#owner-box').children('.owner-item').eq(liIndex).show().siblings('.owner-item').hide();
})
var liIndex = 0;
$('.menu li').click(function (e) {
var index = $(this).index();
liIndex = index;
$(this).addClass('active').siblings().removeClass('active');
$('#owner-box').children('.owner-item').eq(index).show().siblings('.owner-item').hide();
$('#owner-box').children('.owner-item').eq(index).children('.loading').show();
$('.inp').val('');
if (index === 0) {
getData(0,'cook')
} else if (index === 1) {
getData(1,'pop')
} else if (index === 2) {
getData(2,'cloth')
}
});
$(document).on('click', '.check-rule', function(){
$('.rule-wrap').show();
});
$(document).on('click', '.close-rule', function(){
$('.rule-wrap').hide();
});
$(document).on('click','.vote',function (e) {
if ($(this).hasClass('disabled')) {
$('.tip').addClass('show').children('span').html('您今天已为TA投票,请明天再来给TA投吧~');
setTimeout(function () {
$('.tip').removeClass('show');
}, 2000)
return;
}
var flag = $(this).data('flag');
var _this = $(this);
$.ajax({
type : "POST",
url : host+"vote.php/Index/voteTo",
data : {
uflag: flag,
open_id: localStorage.openId
},
success : function(result) {
if (result.status === 1) {
var spanHtml = '<span class="and-one">+1</span>';
_this.parent('.amount').append(spanHtml);
_this.addClass('disabled');
setTimeout(function () {
_this.siblings('.and-one').remove();
}, 1000);
var amount = _this.parent('.amount').find('.vote-amount');
amount.html(parseInt(amount.html())+1);
} else if (result.status === -1) {
$('.tip').addClass('show').children('span').html(result.info);
setTimeout(function () {
$('.tip').removeClass('show');
window.location.href=host+"WxAuthorize?front_url="+location.href;
}, 2000)
} else {
$('.tip').addClass('show').children('span').html(result.info);
setTimeout(function () {
$('.tip').removeClass('show');
}, 2000)
}
}
});
})