var user_id,token,source = '0',already_html="",obtained_html=""; var qs = parseQueryString(location.href); $().ready(function(){ $(".copyTarget").text(getLocation()+"inviteWeixin.html?user_id=" + user_id + '&source=' + source) inviteInformation(); }) $(".hasDone").on("click",function(){ $(this).addClass("active").siblings().removeClass("active"); $(".noList").hide() $(".doneList").show(); }) $(".didnot").on("click",function(){ $(this).addClass("active").siblings().removeClass("active") $(".noList").show() $(".doneList").hide(); }) function getTokenAddUserId (data) {//app token 回调 var dataes = JSON.parse(data) token = dataes.token; user_id = dataes.user_id; if(dataes.source){source = dataes.source} inviteInformation();//获得的金币数量 } function inviteInformation () { //获取邀请好友数量以及获得的金币数量 $.ajax({ url:'/user/inviteInformation', type:'get', dataType:'json', headers:{ token:qs.token, source:qs.source?qs.source:"", version:qs.version?qs.version:"" }, success: function (res){ if(res && res.errno == 0){ $(".total").html(res.rst.invite_gold?res.rst.invite_gold:0); $(".register .num").html(res.rst.invite_num?res.rst.invite_num:0); $(".besure .num").html(res.rst.auth_num?res.rst.auth_num:0); $(".recharge .num").html(res.rst.recharge_num?res.rst.recharge_num:0) var already=res.rst.already_obtained;//获得奖励 var not_obtained=res.rst.not_obtained;//未获得奖励 for(var i in already) { already_html+= '
'+already[i].phone+'
'+already[i].create_time+'
'+already[i].type+'
' } for(var i in not_obtained) { obtained_html+='
'+not_obtained[i].phone+'
'+not_obtained[i].create_time+'
'+not_obtained[i].type+'
' } $(".doneList").html(already_html) $(".noList").html(obtained_html) } }, error: function (err){ showMsg(res.err) } }) } // 获取上级地址 function getLocation() { var upper=window.location.href.split("/")[window.location.href.split("/").length-1] return window.location.href.replace(upper,""); } //获取地址栏参数 function parseQueryString(url) { var urlObj = {}; var reg = /([^?=&]+)=([^?=&]+)/g; url.replace(reg, function($0, $1, $2) { urlObj[$1] = decodeURIComponent($2); }) return urlObj; } // 展示错误提示信息 function showMsg(msg) { $(".alert-info").show(); $(".alert-info p").text(msg); setTimeout(function() { $(".alert-info").hide(); }, 1000); }