Няма описание

newinviteDetail.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var user_id,token,source = '0',already_html="",obtained_html="";
  2. var qs = parseQueryString(location.href);
  3. $().ready(function(){
  4. $(".copyTarget").text(getLocation()+"inviteWeixin.html?user_id=" + user_id + '&source=' + source)
  5. inviteInformation();
  6. })
  7. $(".hasDone").on("click",function(){
  8. $(this).addClass("active").siblings().removeClass("active");
  9. $(".noList").hide()
  10. $(".doneList").show();
  11. })
  12. $(".didnot").on("click",function(){
  13. $(this).addClass("active").siblings().removeClass("active")
  14. $(".noList").show()
  15. $(".doneList").hide();
  16. })
  17. function getTokenAddUserId (data) {//app token 回调
  18. var dataes = JSON.parse(data)
  19. token = dataes.token;
  20. user_id = dataes.user_id;
  21. if(dataes.source){source = dataes.source}
  22. inviteInformation();//获得的金币数量
  23. }
  24. function inviteInformation () {
  25. //获取邀请好友数量以及获得的金币数量
  26. $.ajax({
  27. url:'/user/inviteInformation',
  28. type:'get',
  29. dataType:'json',
  30. headers:{
  31. token:qs.token,
  32. source:qs.source?qs.source:"",
  33. version:qs.version?qs.version:""
  34. },
  35. success: function (res){
  36. if(res && res.errno == 0){
  37. $(".total").html(res.rst.invite_gold?res.rst.invite_gold:0);
  38. $(".register .num").html(res.rst.invite_num?res.rst.invite_num:0);
  39. $(".besure .num").html(res.rst.auth_num?res.rst.auth_num:0);
  40. $(".recharge .num").html(res.rst.recharge_num?res.rst.recharge_num:0)
  41. var already=res.rst.already_obtained;//获得奖励
  42. var not_obtained=res.rst.not_obtained;//未获得奖励
  43. for(var i in already) {
  44. already_html+=
  45. '<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>'
  46. }
  47. for(var i in not_obtained) {
  48. 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>'
  49. }
  50. $(".doneList").html(already_html)
  51. $(".noList").html(obtained_html)
  52. }
  53. },
  54. error: function (err){
  55. showMsg(res.err)
  56. }
  57. })
  58. }
  59. // 获取上级地址
  60. function getLocation() {
  61. var upper=window.location.href.split("/")[window.location.href.split("/").length-1]
  62. return window.location.href.replace(upper,"");
  63. }
  64. //获取地址栏参数
  65. function parseQueryString(url) {
  66. var urlObj = {};
  67. var reg = /([^?=&]+)=([^?=&]+)/g;
  68. url.replace(reg, function($0, $1, $2) {
  69. urlObj[$1] = decodeURIComponent($2);
  70. })
  71. return urlObj;
  72. }
  73. // 展示错误提示信息
  74. function showMsg(msg) {
  75. $(".alert-info").show();
  76. $(".alert-info p").text(msg);
  77. setTimeout(function() {
  78. $(".alert-info").hide();
  79. }, 1000);
  80. }