/*create by2016-01-22! The author:118154194@qq.com! */
define(["jquery","base","kkpager"],function(){function a(a,b){var c=new Date(1e3*a),d=c.getFullYear(),e=c.getMonth()+1<10?"0"+(c.getMonth()+1):c.getMonth()+1,f=c.getDate()<10?"0"+c.getDate():c.getDate(),g=c.getHours()<10?"0"+c.getHours():c.getHours(),h=c.getMinutes()<10?"0"+c.getMinutes():c.getMinutes();return"y-m-dd h:i"==b?d+"-"+e+"-"+f+" "+g+":"+h:"m-d"==b?e+"-"+f:"h:i"==b?g+":"+h:void 0}var b={u:window.location.href,api:"http://api.65.com/"},c={seagift:"#seagift",btnsergift:"#btn-sergift",getgifts:".get-gifts",seagift:"#seagift",btnsergift:"#btn-sergift"},d={giftlist:function(c){$.getJSON(b.api+"65api/mplantform_info.php?callback=?",{action:"card_list",page:c,end:12},function(b){if(1==b.code){for(var e="",f=b.card_list.length,g=0;f>g;g++)0==b.card_list[g].card_isuse?e+='
'+b.card_list[g].game_name+""+b.card_list[g].type_name+'
礼包内容使用说明
'+b.card_list[g].gift_content+'
'+b.card_list[g].gift_direction+'
(兑换截止:'+a(b.card_list[g].type_die_time,"y-m-dd h:i")+')
请先 [登录] 或 [注册]
领取礼包':1==b.card_list[g].card_isuse&&(e+=''+b.card_list[g].game_name+""+b.card_list[g].type_name+'
礼包内容使用说明
'+b.card_list[g].gift_content+'
'+b.card_list[g].gift_direction+'
(兑换截止:'+a(b.card_list[g].type_die_time,"y-m-dd h:i")+')
激活码:'+b.card_list[g].card_num+"
");$("#gift-list").html(e);var h=b.total,i=Math.ceil(h/12);kkpager.generPageHtml({pno:c,total:i,totalRecords:h,isShowTotalPage:!1,isShowCurrPage:!1,isGoPage:!1,mode:"click",click:function(a){return d.giftlist(a),this.selectPage(a),!1}})}})},sergiftlist:function(e,f){var g=$(c.seagift).val(),h=""==g||null==g?e:g;$.getJSON(b.api+"65api/mplantform_info.php?callback=?",{action:"card_list",page:f,end:12,keyword:h},function(e){if(1==e.code){var g="",h=e.card_list.length;if(0==h||""==h)return alert("您搜索的内容不存在,请重新输入"),!1;for(var i=0;h>i;i++)0==e.card_list[i].card_isuse?g+=''+e.card_list[i].game_name+""+e.card_list[i].type_name+'
礼包内容使用说明
'+e.card_list[i].gift_content+'
'+e.card_list[i].gift_direction+'
(兑换截止:'+a(e.card_list[i].type_die_time,"y-m-dd h:i")+')
请先 [登录] 或 [注册]
领取礼包':1==e.card_list[i].card_isuse&&(g+=''+e.card_list[i].game_name+""+e.card_list[i].type_name+'
礼包内容使用说明
'+e.card_list[i].gift_content+'
'+e.card_list[i].gift_direction+'
(兑换截止:'+a(e.card_list[i].type_die_time,"y-m-dd h:i")+')
激活码:'+e.card_list[i].card_num+"
");$("#gift-list").html(g);var j=e.total,k=Math.ceil(j/12);kkpager.generPageHtml({pno:f,total:k,totalRecords:j,isShowTotalPage:!1,isShowCurrPage:!1,isGoPage:!1,mode:"click",click:function(a){var e=$(c.seagift).val();if(""!=e)d.sergiftlist(e,a);else if(location.href.indexOf("gift/?word")>=0){var f=b.u,g=decodeURI(f.split("?")[1].split("=")[1]);""!=g&&d.sergiftlist(g,"1")}else location.href.indexOf("gift")>=0&&d.giftlist(1);return this.selectPage(a),!1}})}})},getgiftnum:function(a){var c=$(a).attr("data-type-id");$.getJSON(b.api+"65api/mplantform_info.php?callback=?",{action:"get_card",tid:c},function(b){1==b.code||-3==b.code?($(a).hide(),$(a).siblings("p.get-gifts-show").show().html("激活码:"+b.card_num)):-2==b.code?$(a).siblings("p.login-tip").show():($(a).hide(),$(a).siblings("p.get-gifts-show").show().html(b.msg))})}};if($(c.getgifts).live("click",function(){d.getgiftnum(this)}),$(c.seagift).focus(function(){$(this).parent().addClass("on")}).blur(function(){$(this).parent().removeClass("on")}),$(c.btnsergift).click(function(){d.sergiftlist("",1)}),$(".gift-tab a").live("mouseenter",function(){var a=$(this).index();$(this).siblings("a").removeClass("on"),$(this).addClass("on"),$(this).parent().siblings("p.gift-tab-cont").hide(),$(this).parent().siblings("p.gift-tab-cont:eq("+a+")").fadeIn(200)}),location.href.indexOf("gift/?word")>=0){var e=b.u,f=decodeURI(e.split("?")[1].split("=")[1]);""!=f&&d.sergiftlist(f,"1")}else location.href.indexOf("gift")>=0&&d.giftlist(1)});