events_vote.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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.operationt_tips}>
  74. <div class="h3_title"><span><{$voteInfo.operationt_tips}></span></div>
  75. <{/if}>
  76. <!--公用活动规则样式-->
  77. <div class="activity_des">
  78. <{$voteInfo.events_rules}>
  79. </div>
  80. <div class="clear"></div>
  81. </div>
  82. </div>
  83. <!--公用提示背景遮罩层-->
  84. <div class="a_cover"></div>
  85. <!--vote_tips begin-->
  86. <div class="v_tips_box" id="vote_tips_box">
  87. <div class="v_close_btn" id="tips_close_btn"></div>
  88. <p class="vote_result">投票成功</p>
  89. </div>
  90. <!--vote_tips end-->
  91. <script>
  92. var seconds = 1000;
  93. var goUrl = '';
  94. function go_page(){
  95. location.href = goUrl;
  96. }
  97. function authorizeRun(data_msg_url){
  98. $(".vote_result").html('本活动需登录后才可以参与');
  99. $('.tips_close_btn').show();
  100. $('.v_tips_box, .a_cover').fadeIn();
  101. goUrl= '<{$loginUrl}>';
  102. setInterval("go_page();",seconds+100);
  103. }
  104. function Percentage(num, total) {
  105. return Math.round(num / total * 100);// 小数点后两位百分比
  106. }
  107. $("#tips_close_btn").on('click', function(){
  108. $(".v_tips_box,.a_cover").hide();
  109. if(goUrl){
  110. go_page();
  111. }
  112. });
  113. KISSY.use('node, io, json', function (S, Node, IO, JSON) {
  114. var cell_colors = JSON.parse('<{$cell_colors}>');
  115. //视频自适应
  116. var screenWidth = $(window).width();
  117. var baseWidth = 510;
  118. var video_scale = screenWidth / baseWidth;
  119. $(".video_iframe").each(function () {
  120. var new_width = $(this).width() * video_scale;
  121. $(this).width(new_width - 20);
  122. var new_height = $(this).height() * video_scale;
  123. $(this).height(new_height - 20);
  124. });
  125. <{if $voteInfo.vote_type == 1}>
  126. <{if $eventsStatus}> <{*活动结束时*}>
  127. refreshVoteBox(false);
  128. <{else}>
  129. $(".lable_div").on('click', function () {
  130. var _self = $(this);
  131. var voteid = $(this).data('voteid');
  132. var total_vote_num = $('.wrapper').attr('data-total-vote-num');
  133. if (!voteid) {
  134. return false
  135. }
  136. IO.on("send",function(){
  137. showLoading();
  138. });
  139. IO.get('<{$web_cfg.domain}>/?c=eventsVote&a=vote'
  140. , {
  141. events_id: '<{$voteInfo.id}>',
  142. voteid: voteid
  143. }
  144. , function (data) {
  145. goUrl = '';
  146. if (data.ok) {
  147. showMsg('投票成功', function () {
  148. var addNum = _self.find('em').data('num') + 1;
  149. _self.find('em').data('num', addNum);
  150. total_vote_num = Number(total_vote_num) + 1;
  151. $('.wrapper').attr('data-total-vote-num', total_vote_num);
  152. refreshVoteBox(true);
  153. });
  154. } else {
  155. if(data.msg.url){
  156. authorizeRun(data.msg.url);
  157. return false;
  158. }
  159. showMsg(data.msg, null, function () {
  160. refreshVoteBox(false);
  161. });
  162. }
  163. }
  164. , 'json'
  165. );
  166. });
  167. $(".vote_btn").click(function(){
  168. $(this).find("span").addClass("h_selected");
  169. $(".vote_btn p").each(function(){
  170. $(this).show(600);//右侧推出显示投票数,速度可控制
  171. });
  172. });
  173. <{/if}>
  174. <{else}>
  175. <{if $eventsStatus}> <{*活动结束时*}>
  176. $(".vote_btn p").each(function(){
  177. $(this).show(600);//右侧推出显示投票数,速度可控制
  178. });
  179. <{else}>
  180. $(".vote_btn").click(function () {
  181. var _self = $(this);
  182. var voteid = $(this).data('voteid');
  183. S.log(voteid);
  184. if (voteid == '') {
  185. return false
  186. }
  187. IO.on("send",function(){
  188. showLoading();
  189. });
  190. IO.get('<{$web_cfg.domain}>/?c=eventsVote&a=vote'
  191. , {
  192. events_id: '<{$voteInfo.id}>',
  193. voteid: voteid
  194. }
  195. , function (data) {
  196. goUrl = '';
  197. if (data.ok) {
  198. showMsg('投票成功', function () {
  199. _self.find("span").addClass("h_selected");
  200. var addNum = _self.data('num') + 1;
  201. _self.data('num', addNum);
  202. _self.find('p').text(addNum);
  203. $(this).find("span").addClass("h_selected");
  204. $(".vote_btn p").each(function(){
  205. $(this).show(600);//右侧推出显示投票数,速度可控制
  206. });
  207. });
  208. } else {
  209. if(data.msg.url){
  210. authorizeRun(data.msg.url);
  211. return false;
  212. }
  213. showMsg(data.msg, function () {
  214. $(this).find("span").addClass("h_selected");
  215. $(".vote_btn p").each(function(){
  216. $(this).show(600);//右侧推出显示投票数,速度可控制
  217. });
  218. });
  219. }
  220. }
  221. , 'json'
  222. );
  223. });
  224. <{/if}>
  225. <{/if}>
  226. function refreshVoteBox(isHide) {
  227. // 隐藏cell
  228. if (isHide) {
  229. $(".data_show_cell").fadeOut();
  230. $(".data_show_cell em").css({width:"0px"});
  231. }
  232. var cell_lens = {};
  233. var total = 0;
  234. $(".vt_cell .vt_num").removeClass("vt_num");
  235. $(".vt_cell").addClass("vt_result_cell");
  236. $(".dv_title").addClass("dv_title_after");//增加投票选项点击后的样式
  237. $(".data_show_cell em").each(function (i) {
  238. var num = $(this).data('num');
  239. cell_lens[i] = num;
  240. total += num;
  241. });
  242. var total_vote_num = $('.wrapper').attr('data-total-vote-num');
  243. $(".data_show_cell").fadeIn();
  244. $(".data_show_cell em").each(function (i) {
  245. var perNum = Percentage(cell_lens[i], total_vote_num);
  246. //$(this).parent().find('b').text(perNum+'%');
  247. $(this).parent().addClass(cell_colors[i-1]);
  248. var len_num = (cell_lens[i] / total) * 200;
  249. $(this).animate({width:len_num+"px"},1000);
  250. });
  251. }
  252. function showMsg($msg, $callback) {
  253. $('.tips_close_btn').show();
  254. $('.vote_result').html($msg);
  255. $('.a_cover').fadeIn().delay(seconds).fadeOut();
  256. $('.v_tips_box').fadeIn().delay(seconds).fadeOut(function () {
  257. if ($callback) $callback();
  258. });
  259. }
  260. function showLoading() {
  261. $('.tips_close_btn').hide();
  262. $('.vote_result').html('加载中..');
  263. $('.v_tips_box, .a_cover').fadeIn();
  264. }
  265. $(".tips_close_btn").on('click', function(){
  266. $(".v_tips_box, .a_cover").hide();
  267. });
  268. //判断当前页图片加载完成loading消失
  269. $(".vote_show_box dl dt img").each(function(){
  270. $(this).load(function(){
  271. $(this).parent().css("background","none");
  272. })
  273. });
  274. });
  275. </script>
  276. <{include file="bottom.html"}>