events_vote.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <{include file="header.html"}>
  2. <!--公用标题居中显示-->
  3. <{include file="common_header.html"}>
  4. <{include file="events_top.html"}>
  5. <{include file="events_infos.html"}>
  6. <!--公用提示背景遮罩层-->
  7. <div class="a_cover"></div>
  8. <!--vote_tips begin-->
  9. <div class="v_tips_box" id="vote_tips_box">
  10. <div class="v_close_btn" id="tips_close_btn"></div>
  11. <p class="vote_result">投票成功</p>
  12. </div>
  13. <!--vote_tips end-->
  14. <script>
  15. var seconds = 1000;
  16. var goUrl = '';
  17. var config_total_vote_num = '<{$voteInfo.total_vote_num}>';
  18. function go_page(){
  19. location.href = goUrl;
  20. }
  21. function authorizeRun(data_msg_url){
  22. $(".vote_result").html('本活动需登录后才可以参与');
  23. $('.tips_close_btn').show();
  24. $('.v_tips_box, .a_cover').fadeIn();
  25. goUrl= '<{$loginUrl}>';
  26. setInterval("go_page();",seconds+100);
  27. }
  28. function Percentage(num, total) {
  29. return Math.round(num / total * 100);// 小数点后两位百分比
  30. }
  31. $("#tips_close_btn").on('click', function(){
  32. $(".v_tips_box,.a_cover").hide();
  33. if(goUrl){
  34. go_page();
  35. }
  36. });
  37. KISSY.use('node, io, json', function (S, Node, IO, JSON) {
  38. var cell_colors = JSON.parse('<{$cell_colors}>');
  39. //视频自适应
  40. var screenWidth = $(window).width();
  41. var baseWidth = 510;
  42. var video_scale = screenWidth / baseWidth;
  43. $(".video_iframe").each(function () {
  44. var new_width = $(this).width() * video_scale;
  45. $(this).width(new_width - 20);
  46. var new_height = $(this).height() * video_scale;
  47. $(this).height(new_height - 20);
  48. });
  49. <{if $voteInfo.vote_type == 1}>
  50. <{if $eventsStatus}> <{*活动结束时*}>
  51. refreshVoteBox(false);
  52. <{else}>
  53. $(".lable_div").on('click', function () {
  54. var _self = $(this);
  55. var voteid = $(this).data('voteid');
  56. var total_vote_num = config_total_vote_num;
  57. if (!voteid) {
  58. return false
  59. }
  60. IO.on("send",function(){
  61. showLoading();
  62. });
  63. IO.get('<{$web_cfg.domain}>/?c=eventsVote&a=vote'
  64. , {
  65. events_id: '<{$voteInfo.id}>',
  66. voteid: voteid
  67. }
  68. , function (data) {
  69. goUrl = '';
  70. if (data.ok) {
  71. showMsg('投票成功', function () {
  72. var addNum = _self.find('em').data('num') + 1;
  73. _self.find('em').data('num', addNum);
  74. total_vote_num = Number(total_vote_num) + 1;
  75. config_total_vote_num = total_vote_num;
  76. refreshVoteBox(true);
  77. });
  78. } else {
  79. if(data.msg.url){
  80. authorizeRun(data.msg.url);
  81. return false;
  82. }
  83. showMsg(data.msg, null, function () {
  84. refreshVoteBox(false);
  85. });
  86. }
  87. }
  88. , 'json'
  89. );
  90. });
  91. $(".vote_btn").click(function(){
  92. $(this).find("span").addClass("h_selected");
  93. $(".vote_btn p").each(function(){
  94. $(this).show(600);//右侧推出显示投票数,速度可控制
  95. });
  96. });
  97. <{/if}>
  98. <{else}>
  99. <{if $eventsStatus}> <{*活动结束时*}>
  100. $(".vote_btn p").each(function(){
  101. $(this).show(600);//右侧推出显示投票数,速度可控制
  102. });
  103. <{else}>
  104. $(".vote_btn").click(function () {
  105. var _self = $(this);
  106. var voteid = $(this).data('voteid');
  107. S.log(voteid);
  108. if (voteid == '') {
  109. return false
  110. }
  111. IO.on("send",function(){
  112. showLoading();
  113. });
  114. IO.get('<{$web_cfg.domain}>/?c=eventsVote&a=vote'
  115. , {
  116. events_id: '<{$voteInfo.id}>',
  117. voteid: voteid
  118. }
  119. , function (data) {
  120. goUrl = '';
  121. if (data.ok) {
  122. showMsg('投票成功', function () {
  123. _self.find("span").addClass("h_selected");
  124. var addNum = _self.data('num') + 1;
  125. _self.data('num', addNum);
  126. _self.find('p').text(addNum);
  127. $(this).find("span").addClass("h_selected");
  128. $(".vote_btn p").each(function(){
  129. $(this).show(600);//右侧推出显示投票数,速度可控制
  130. });
  131. });
  132. } else {
  133. if(data.msg.url){
  134. authorizeRun(data.msg.url);
  135. return false;
  136. }
  137. showMsg(data.msg, function () {
  138. $(this).find("span").addClass("h_selected");
  139. $(".vote_btn p").each(function(){
  140. $(this).show(600);//右侧推出显示投票数,速度可控制
  141. });
  142. });
  143. }
  144. }
  145. , 'json'
  146. );
  147. });
  148. <{/if}>
  149. <{/if}>
  150. function refreshVoteBox(isHide) {
  151. // 隐藏cell
  152. if (isHide) {
  153. $(".data_show_cell").fadeOut();
  154. $(".data_show_cell em").css({width:"0px"});
  155. }
  156. var cell_lens = {};
  157. var total = 0;
  158. $(".vt_cell .vt_num").removeClass("vt_num");
  159. $(".vt_cell").addClass("vt_result_cell");
  160. $(".dv_title").addClass("dv_title_after");//增加投票选项点击后的样式
  161. $(".data_show_cell em").each(function (i) {
  162. var num = $(this).data('num');
  163. cell_lens[i] = num;
  164. total += num;
  165. });
  166. var total_vote_num = config_total_vote_num;
  167. $(".data_show_cell").fadeIn();
  168. $(".data_show_cell em").each(function (i) {
  169. var perNum = Percentage(cell_lens[i], total_vote_num);
  170. //$(this).parent().find('b').text(perNum+'%');
  171. $(this).parent().addClass(cell_colors[i-1]);
  172. var len_num = (cell_lens[i] / total) * 200;
  173. $(this).animate({width:len_num+"px"},1000);
  174. });
  175. }
  176. function showMsg($msg, $callback) {
  177. $('.tips_close_btn').show();
  178. $('.vote_result').html($msg);
  179. $('.a_cover').fadeIn().delay(seconds).fadeOut();
  180. $('.v_tips_box').fadeIn().delay(seconds).fadeOut(function () {
  181. if ($callback) $callback();
  182. });
  183. }
  184. function showLoading() {
  185. $('.tips_close_btn').hide();
  186. $('.vote_result').html('加载中..');
  187. $('.v_tips_box, .a_cover').fadeIn();
  188. }
  189. $(".tips_close_btn").on('click', function(){
  190. $(".v_tips_box, .a_cover").hide();
  191. });
  192. //判断当前页图片加载完成loading消失
  193. $(".vote_show_box dl dt img").each(function(){
  194. $(this).load(function(){
  195. $(this).parent().css("background","none");
  196. })
  197. });
  198. });
  199. </script>
  200. <{include file="bottom.html"}>