123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 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+=
- '<div class="info"><img class="icon" src="'+already[i].user_img+'"><div class="other"><div class="tel">'+already[i].phone+'</div><div class="time">'+already[i].create_time+'</div></div><div class="status">'+already[i].type+'</div></div>'
- }
- for(var i in not_obtained) {
- obtained_html+='<div class="info"><img class="icon" src="'+not_obtained[i].user_img+'"><div class="other"><div class="tel">'+not_obtained[i].phone+'</div><div class="time">'+not_obtained[i].create_time+'</div></div><div class="status">'+not_obtained[i].type+'</div></div>'
- }
- $(".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);
- }
|