1 line
2.5 KiB
JavaScript
1 line
2.5 KiB
JavaScript
define(["core","tpl"],function(o,t){var c={reload:function(){window.location.href=window.location.href+"&t="+ +new Date},/**www.rrsc.cn**/countDown:function(t,e){var n=parseInt(Date.now()/1e3),o=0;return t&&(o=n<t?t-n:n-t,o=parseInt(o)),0!=(o=e?parseInt(e):o)&&[n=Math.floor(o/86400),(t=Math.floor((o-24*n*60*60)/3600))<10?"0"+t:t,(e=Math.floor((o-24*n*60*60-3600*t)/60))<10?"0"+e:e,(o=Math.floor(o-24*n*60*60-3600*t-60*e))<10?"0"+o:o]}};return c.init=function(t){var e=t.id||0;$(".invitation").on("click",function(){"none"==$("#cover").css("display")&&($("#cover").show(),$("#guide").show(),$(".fui-page-current").css("overflow","hidden"))}),$("#receiveActivity").on("click",function(){o.json("friendcoupon/receive",{id:e},function(t){0===t.status?($("#tips_content").html(t.result.message),$("#tips").show()):(FoxUI.toast.show(t.result.message),setTimeout(function(){c.reload()},2e3))})}),$("#divide").on("click",function(){o.json("friendcoupon/divide",{id:e},function(t){0===t.status?(FoxUI.toast.show(t.result.message),void 0!==t.result.url&&setTimeout(function(){window.location.href=t.result.url},2e3)):(FoxUI.toast.show(t.result.message),setTimeout(function(){c.reload()},2e3))})}),$("#cover,#guide").on("click",function(){$("#cover,#guide").css({display:"none"}),$(".fui-page-current").css("overflow","scroll")});var n=null;$("#more").click(function(){clearTimeout(n),n=setTimeout(function(){!function(){$("#more");var e,n,t=$(".inner .item").length+1;location.search.split("?").pop().split("&").forEach(function(t){0===t.search(/id/)&&(e=t.split("=")[1]),0===t.search(/mid/)&&(n=t.split("=")[1])}),void 0===n&&(n=$("#header").data("id")),o.json("friendcoupon/more",{id:e,mid:n,pindex:t},function(t){if(1<=t.result.list.length)for(var e=t.result.list,n=0;n<e.length;n++){var o=$('<div class="item"><img class="adver" src="'+e[n].avatar+'"><span class="name">'+e[n].nickname+"</span><span>¥ "+e[n].deduct+"</span></div>");$("#content .item:last").after(o)}else FoxUI.toast.show("已没有更多了哦")})}()},200)}),o.json("friendcoupon/deadline",{id:e,mid:$("#mid").val()},function(t){var s,r=parseInt(t.result.deadline);parseInt(+new Date/1e3)<r&&(s=setInterval(function(){var t=c.countDown(r),e=t[0],n=t[1],o=t[2],i=t[3];$(".countDown .day").text(e),$(".countDown .hour").text(n),$(".countDown .minutes").text(o),$(".countDown .seconds").text(i),!1===t&&(clearInterval(s),$("#tips_content").text("很遗憾,没有在规定时间内完成瓜分,下次要快一点哦~"),$("#tips").show())},1e3))})},c}); |