events_vote.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <{include file="header.html"}>
  2. <!--公用标题居中显示-->
  3. <{include file="common_header.html"}>
  4. <!---->
  5. <div class="wrapper" data-total-vote-num="<{$voteInfo.total_vote_num}>">
  6. <div class="article_title center"><{$voteInfo.events_name}></div>
  7. <!--公用活动说明样式-->
  8. <div class="article_content"><{$voteInfo.events_tips}></div>
  9. <div class="v_box_w clear">
  10. <{if $eventsStatus && $eventsStatus!='STATUS_LIMITATIONS'}>
  11. <{if $voteInfo.events_hd_tips}>
  12. <div class="h3_title"><{$voteInfo.events_hd_tips}></div>
  13. <{/if}>
  14. <!--公用活动结束提示 begin-->
  15. <div class="v_end_com_box">
  16. <div class="v_end_txt_com center">活动已结束!</div>
  17. <div class="center"><a href="<{$listUrl}>" class="submit_btn_style">参与更多特权活动</a></div>
  18. </div>
  19. <{/if}>
  20. <{if $voteInfo.events_hd_tips}>
  21. <div class="h3_title"><{$voteInfo.events_hd_tips}></div>
  22. <{/if}>
  23. <{if $voteInfo.vote_type == 1}>
  24. <!--<div class="vote_show_box2" id="vote_show_box2">
  25. <{foreach from=$voteInfo.vote item=vote}>
  26. <div class="radio_cell" data-voteid="<{$vote.id}>">
  27. <label for="radio-2-<{$vote.id}>" class="lable_div" data-voteid="<{$vote.id}>" >
  28. <div class="data_cell_box vote_box" data-voteid="<{$vote.id}>" >
  29. <p class="dv_title dv_title_default"><{$vote.title}></p>
  30. <{assign var=total_num value=$vote.num+$vote.add_num}>
  31. <p class="data_show_cell"><em style="width:0px;" data-num="<{$total_num}>"></em><b><{$vote.per_num}>%</b></p>
  32. </div>
  33. </label>
  34. </div>
  35. <{/foreach}>
  36. </div>-->
  37. <div class="vote_txt_box clear">
  38. <{foreach from=$voteInfo.vote item=vote name=votebox}>
  39. <div class="radio_cell" data-voteid="<{$vote.id}>">
  40. <label for="radio-2-<{$vote.id}>" class="lable_div" data-voteid="<{$vote.id}>" >
  41. <div class="vt_cell vote_box" data-voteid="<{$vote.id}>">
  42. <div class="vt_index"><span class="vt_num"><em><{$smarty.foreach.votebox.iteration}></em></span></div>
  43. <div class="vt_title"><span><{$vote.title}></span></div>
  44. <{assign var=total_num value=$vote.num+$vote.add_num}>
  45. <p class="data_show_cell vt_total_bg"><em style="width:0px;" class="vt_total_line bg_color" data-num="<{$total_num}>"></em></p>
  46. <div class="vt_total_num font_color"><{$vote.per_num}>%</div>
  47. </div>
  48. </label>
  49. </div>
  50. <{/foreach}>
  51. </div>
  52. <{else}>
  53. <div class="vote_show_box">
  54. <div class="vote_cell_row clear">
  55. <div class="vote_item_show clear">
  56. <{foreach from=$voteInfo.vote item=vote}>
  57. <dl class="vote_item">
  58. <dt>
  59. <img src="<{$web_cfg.cdn}>/public/static/img/vote_img_bg.jpg">
  60. <div class="vote_img_thumb" style="background-image:url(<{$vote.img_url}>);"></div>
  61. <{assign var=total_num value=$vote.num+$vote.add_num}>
  62. <div class="vote_btn bg_color" data-voteid="<{$vote.id}>" data-num="<{$total_num}>"><span <{if $eventsStatus=='STATUS_LIMITATIONS' || $eventsStatus=='STATUS_HAS_END'}>class="h_selected" <{/if}>></span><p class="total_num_show"><{$total_num}></p></div>
  63. </dt>
  64. <dd>
  65. <p class="vote_name"><{$vote.title}></p>
  66. </dd>
  67. </dl>
  68. <{/foreach}>
  69. </div>
  70. </div>
  71. </div>
  72. <{/if}>
  73. <{if $voteInfo.share_button == 2}>
  74. <{include file="share_button.html"}>
  75. <{/if}>
  76. <{if $voteInfo.operationt_tips}>
  77. <div class="h3_title"><span><{$voteInfo.operationt_tips}></span></div>
  78. <{/if}>
  79. <!--公用活动规则样式-->
  80. <div class="activity_des">
  81. <{$voteInfo.events_rules}>
  82. </div>
  83. <div class="clear"></div>
  84. </div>
  85. </div>
  86. <!--公用提示背景遮罩层-->
  87. <div class="a_cover"></div>
  88. <!--vote_tips begin-->
  89. <div class="v_tips_box" id="vote_tips_box">
  90. <div class="v_close_btn" id="tips_close_btn"></div>
  91. <p class="vote_result">投票成功</p>
  92. </div>
  93. <!--vote_tips end-->
  94. <script>
  95. var seconds = 1000;
  96. var goUrl = '';
  97. function go_page(){
  98. location.href = goUrl;
  99. }
  100. function authorizeRun(data_msg_url){
  101. $(".vote_result").html('本活动需登录后才可以参与');
  102. $('.tips_close_btn').show();
  103. $('.v_tips_box, .a_cover').fadeIn();
  104. goUrl= '<{$loginUrl}>';
  105. setInterval("go_page();",seconds+100);
  106. }
  107. function Percentage(num, total) {
  108. return Math.round(num / total * 100);// 小数点后两位百分比
  109. }
  110. $("#tips_close_btn").on('click', function(){
  111. $(".v_tips_box,.a_cover").hide();
  112. if(goUrl){
  113. go_page();
  114. }
  115. });
  116. KISSY.use('node, io, json', function (S, Node, IO, JSON) {
  117. var cell_colors = JSON.parse('<{$cell_colors}>');
  118. //视频自适应
  119. var screenWidth = $(window).width();
  120. var baseWidth = 510;
  121. var video_scale = screenWidth / baseWidth;
  122. $(".video_iframe").each(function () {
  123. var new_width = $(this).width() * video_scale;
  124. $(this).width(new_width - 20);
  125. var new_height = $(this).height() * video_scale;
  126. $(this).height(new_height - 20);
  127. });
  128. <{if $voteInfo.vote_type == 1}>
  129. <{if $eventsStatus}> <{*活动结束时*}>
  130. refreshVoteBox(false);
  131. <{else}>
  132. $(".lable_div").on('click', function () {
  133. var _self = $(this);
  134. var voteid = $(this).data('voteid');
  135. var total_vote_num = $('.wrapper').attr('data-total-vote-num');
  136. if (!voteid) {
  137. return false
  138. }
  139. IO.on("send",function(){
  140. showLoading();
  141. });
  142. IO.get('<{$web_cfg.domain}>/?c=eventsVote&a=vote'
  143. , {
  144. events_id: '<{$voteInfo.id}>',
  145. voteid: voteid
  146. }
  147. , function (data) {
  148. goUrl = '';
  149. if (data.ok) {
  150. showMsg('投票成功', function () {
  151. var addNum = _self.find('em').data('num') + 1;
  152. _self.find('em').data('num', addNum);
  153. total_vote_num = Number(total_vote_num) + 1;
  154. $('.wrapper').attr('data-total-vote-num', total_vote_num);
  155. refreshVoteBox(true);
  156. });
  157. } else {
  158. if(data.msg.url){
  159. authorizeRun(data.msg.url);
  160. return false;
  161. }
  162. showMsg(data.msg, null, function () {
  163. refreshVoteBox(false);
  164. });
  165. }
  166. }
  167. , 'json'
  168. );
  169. });
  170. $(".vote_btn").click(function(){
  171. $(this).find("span").addClass("h_selected");
  172. $(".vote_btn p").each(function(){
  173. $(this).show(600);//右侧推出显示投票数,速度可控制
  174. });
  175. });
  176. <{/if}>
  177. <{else}>
  178. <{if $eventsStatus}> <{*活动结束时*}>
  179. $(".vote_btn p").each(function(){
  180. $(this).show(600);//右侧推出显示投票数,速度可控制
  181. });
  182. <{else}>
  183. $(".vote_btn").click(function () {
  184. var _self = $(this);
  185. var voteid = $(this).data('voteid');
  186. S.log(voteid);
  187. if (voteid == '') {
  188. return false
  189. }
  190. IO.on("send",function(){
  191. showLoading();
  192. });
  193. IO.get('<{$web_cfg.domain}>/?c=eventsVote&a=vote'
  194. , {
  195. events_id: '<{$voteInfo.id}>',
  196. voteid: voteid
  197. }
  198. , function (data) {
  199. goUrl = '';
  200. if (data.ok) {
  201. showMsg('投票成功', function () {
  202. _self.find("span").addClass("h_selected");
  203. var addNum = _self.data('num') + 1;
  204. _self.data('num', addNum);
  205. _self.find('p').text(addNum);
  206. $(this).find("span").addClass("h_selected");
  207. $(".vote_btn p").each(function(){
  208. $(this).show(600);//右侧推出显示投票数,速度可控制
  209. });
  210. });
  211. } else {
  212. if(data.msg.url){
  213. authorizeRun(data.msg.url);
  214. return false;
  215. }
  216. showMsg(data.msg, function () {
  217. $(this).find("span").addClass("h_selected");
  218. $(".vote_btn p").each(function(){
  219. $(this).show(600);//右侧推出显示投票数,速度可控制
  220. });
  221. });
  222. }
  223. }
  224. , 'json'
  225. );
  226. });
  227. <{/if}>
  228. <{/if}>
  229. function refreshVoteBox(isHide) {
  230. // 隐藏cell
  231. if (isHide) {
  232. $(".data_show_cell").fadeOut();
  233. $(".data_show_cell em").css({width:"0px"});
  234. }
  235. var cell_lens = {};
  236. var total = 0;
  237. $(".vt_cell .vt_num").removeClass("vt_num");
  238. $(".vt_cell").addClass("vt_result_cell");
  239. $(".dv_title").addClass("dv_title_after");//增加投票选项点击后的样式
  240. $(".data_show_cell em").each(function (i) {
  241. var num = $(this).data('num');
  242. cell_lens[i] = num;
  243. total += num;
  244. });
  245. var total_vote_num = $('.wrapper').attr('data-total-vote-num');
  246. $(".data_show_cell").fadeIn();
  247. $(".data_show_cell em").each(function (i) {
  248. var perNum = Percentage(cell_lens[i], total_vote_num);
  249. //$(this).parent().find('b').text(perNum+'%');
  250. $(this).parent().addClass(cell_colors[i-1]);
  251. var len_num = (cell_lens[i] / total) * 200;
  252. $(this).animate({width:len_num+"px"},1000);
  253. });
  254. }
  255. function showMsg($msg, $callback) {
  256. $('.tips_close_btn').show();
  257. $('.vote_result').html($msg);
  258. $('.a_cover').fadeIn().delay(seconds).fadeOut();
  259. $('.v_tips_box').fadeIn().delay(seconds).fadeOut(function () {
  260. if ($callback) $callback();
  261. });
  262. }
  263. function showLoading() {
  264. $('.tips_close_btn').hide();
  265. $('.vote_result').html('加载中..');
  266. $('.v_tips_box, .a_cover').fadeIn();
  267. }
  268. $(".tips_close_btn").on('click', function(){
  269. $(".v_tips_box, .a_cover").hide();
  270. });
  271. //判断当前页图片加载完成loading消失
  272. $(".vote_show_box dl dt img").each(function(){
  273. $(this).load(function(){
  274. $(this).parent().css("background","none");
  275. })
  276. });
  277. });
  278. </script>
  279. <{include file="bottom.html"}>