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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// 加载html结构
loadHtmlJson();
// 加载广告
// ppendAdvertisement();
$(function(){
setToken();
// 获取活动标题
getActivityTitle();
btnBindClick();// 绑定点击事件
var showTime = new Date(rules.settings.szRule.votingEndTime.replace(/-/g,'/')).getTime() - new Date(currentTime.replace(/-/g,'/')).getTime();
var endTime = new Date(rules.acActivity.endTime.replace(/-/g,'/')).getTime() - new Date(currentTime.replace(/-/g,'/')).getTime();
userCountDown(showTime/1000, endTime/1000, $('#act31142119991744 span')); //倒计时
userTabInfo();
voteDialogBindFn();
// 加载机构名称
headerShowOrgName();
});
// 元素点击事件绑定
function btnBindClick() {
// 返回首页
$("#act3110143885264").off("click").on("click",function(){
var _t = getToken();
transPage('1',activityCode,_t);
});
// 拉票
$('#act31119351441050').off("click").on("click",function(){
// 设置分享参数
setWxShare({
userId: shareUserId,
userName: shareUserName
});
$('#html-template-8').fadeIn('normal', function() {
$(document).scrollTop(0);
});
});
// 排行榜
$("#act41612547506702").off('click').on("click", function(){
var _t = getToken();
var _addParam = 'toRanger=1'
transPage('1',activityCode,_t,_addParam);
});
// 选手主页
$("#act4161336684689").off("click").on("click", function(){
// 判断关注
isAttention(function(){
// 判断是否报名
isSignUp(function(){
var _t = getToken();
var urlParam = 'userId='+user.id;
transPage('3',activityCode,_t,urlParam);
},function(){
$.dialog({
contentHtml: '<p style="text-align:center;">您还未报名,请到首页报名参加后本次活动!</p>',
onClosed: function(){
var _t = getToken();
transPage('1',activityCode,_t);
}
});
});
});
});
// 活动秘籍
$("#act41613113951133").off("click").on("click", function(){
$('#html-template-8').fadeIn('normal', function() {
$(document).scrollTop(0);
});
});
// 给用户投票
$("#act31119414834381").off("click").on("click", function(){
var _userId = shareUserId;
var _userName = shareUserName;
var params = {
userId: _userId,
userName: _userName,
orgId: getQueryString('orgId') !== null ? getQueryString('orgId') : ''
}
isAttention(function(){
showLoading('处理中...');
voteClickFn(params, function(data){
$('#act3932189955 .userVoteNum span').text(data.result.voteNum);
});
});
});
}
// 倒计时
function userCountDown(times, endTime ,ids){
var $countDown = $('#act31142119991744')
if($countDown.attr('c_counttime') == 'yes') {
$countDown.removeClass('global-none')
var timer=null;
var self = this
var times = times
var endTimes = endTime
timer=setInterval(function(){
var day=0,
hour=0,
minute=0,
second=0;//时间默认值
if(times > 0){
day = Math.floor(times / (60 * 60 * 24));
hour = Math.floor(times / (60 * 60)) - (day * 24);
minute = Math.floor(times / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(times) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (day <= 9) day = '0' + day;
if (hour <= 9) hour = '0' + hour;
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
ids.html((day != 00 ? day + "天" : '')+hour+"时"+minute+"分"+second+"秒")
times--;
endTimes--;
// 判断活动时间是否结束
if(endTimes < 0) {
clearInterval(timer);
// ids.parent().addClass('global-none');
ids.parent().html('活动已结束');
}
// 判断投票时间是否结束
else if(times < 0){
clearInterval(timer);
// ids.parent().addClass('global-none');
ids.parent().html('投票已结束');
}
},1000);
}else {
$countDown.addClass('global-none')
}
}
// 个人信息展示
function userTabInfo() {
var id = getQueryString('userId')?getQueryString('userId'):user.id;
var params = {
id: id,
reviewStatus:1 // 审核状态
}
var authId = getQueryString('auth_id')
var _header = {
'x-token': getToken()
}
if(authId !== null) {
_header['auth-id'] = authId
}
$.ajax({
type: 'GET',
url: baseUrl + '/ACTIVITY/sz/search/' + activityCode,
data: params,
headers: _header,
success: function(data) {
if(data.status == 200) {
var userInfoObj = data.result && data.result.records && data.result.records[0]
$('#act3932189955 .user-info .inner-pic').attr('src',userInfoObj.wechatAvatarUrl);
var innerInfo = $('#act3932189955 .user-info .inner-info')
innerInfo.find('.userName span').text(userInfoObj.name)
innerInfo.find('.userNo span').text(userInfoObj.userNumber)
innerInfo.find('.userRank span').text(userInfoObj.ranking) // 排名
innerInfo.find('.userVoteNum span').text(userInfoObj.voteNum)
$('#act3932189955 .userState').val(userInfoObj.declaration)
$('#act3932189955 .userState').attr('readOnly','readOnly')
$('#act3932189955 .show-pic').attr('src',userInfoObj.imageUrl);
shareUserId = userInfoObj.id;
shareUserName = userInfoObj.name;
// 创建新增项
var addStr = '';
var inputStr = '<div class="form-row m-b">'+
'<div class="form-input-group">'+
'<div class="form-input-group-inner">'+
'<input type="text" c_remove="readonly" readonly="readOnly" value="{{value}}">'+
'</div>'+
'</div>'+
'</div>';
if(userInfoObj.x1 !== ''){
addStr += inputStr.replace(/{{value}}/g,userInfoObj.x1);
}
if(userInfoObj.x2 !== ''){
addStr += inputStr.replace(/{{value}}/g,userInfoObj.x2);
}
if(userInfoObj.x3 !== ''){
addStr += inputStr.replace(/{{value}}/g,userInfoObj.x3);
}
if(addStr !== ''){
$("#act3932189955 .form-row:last-child").prepend(addStr);
}
}
},
error: function() {
$.dialog({
type : 'tips',
autoClose : 3000,
infoText : '请求超时,请尝试刷新页面!'
});
}
})
}