No Description

oldUsers.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. var user_id = '';
  2. var red_id= '';
  3. var qs = parseQueryString(window.location.href);
  4. window.onload = function () {
  5. if(qs.user_id){user_id = qs.user_id};
  6. if(qs.red_id){red_id = qs.red_id};
  7. redOrderBarrage();
  8. shareWechatUrl();
  9. }
  10. function shareWechatUrl(){
  11. //获取分享url
  12. $.ajax({
  13. type: 'post',
  14. url: '/api/v2/redactive/helpOpenRed',
  15. data:{
  16. 'red_id':red_id,
  17. 'user_id':user_id
  18. },
  19. success: function (data) {
  20. if (data && data.errno == 0) {
  21. var url=data.rst.url;
  22. console.log(url);
  23. getSignPackage(url);//过微信审核用
  24. }else {
  25. // showMsg(res.err)
  26. }
  27. },
  28. error:function () {
  29. // showMsg("请稍后再试")
  30. }
  31. })
  32. }
  33. function getSignPackage (shareUrl) {
  34. //过微信审核用
  35. var _this = this;
  36. $.ajax({
  37. url:'/api/v2/spellgroup/getSignPackage',
  38. type:'post',
  39. data:{
  40. url:location.href
  41. },
  42. success: function (res) {
  43. console.log(res)
  44. wexinPay(shareUrl,res,function() {
  45. // 分享成功
  46. showMsg("分享成功")
  47. _czc.push(["_trackEvent",'v3-红包分享','红包id--' + red_id,'']);
  48. },function() {
  49. //分享失败
  50. showMsg("分享失败")
  51. },function() {
  52. //微信审核为通过
  53. })
  54. }
  55. })
  56. }
  57. function redOrderBarrage(){
  58. //红包详情头部弹幕
  59. $.ajax({
  60. type: 'get',
  61. url: '/api/v2/redactive/redOrderBarrage',
  62. dataType:'json',
  63. success: function (res) {
  64. console.log(res)
  65. if (res && res.errno == 0) {
  66. var listHtml = '',nickname;
  67. for(i=0;i<5;i++){
  68. if(res.rst.data.coponInfo.length > i){
  69. var coponInfoItem = res.rst.data.coponInfo[i];
  70. nickname = '猎小豆';
  71. if(coponInfoItem.nickname != 'null' && coponInfoItem.nickname != null && coponInfoItem.nickname != ''){
  72. nickname = coponInfoItem.nickname;
  73. }
  74. listHtml += '<div class="swiper-slide">' + coponInfoItem.add_time + '前 <em>' + nickname + '</em>领取了 <span>' + coponInfoItem.red_money + '元优惠券</span></div>'
  75. }
  76. if(res.rst.data.redOpend.length > i){
  77. var redOpendItem = res.rst.data.redOpend[i];
  78. nickname = '猎小豆';
  79. if(redOpendItem.nickname != 'null' && redOpendItem.nickname != null && redOpendItem.nickname != ''){
  80. nickname = redOpendItem.nickname;
  81. }
  82. listHtml += '<div class="swiper-slide">' + redOpendItem.add_time + '前 <em>' + nickname + '</em>提现了 <span>' + redOpendItem.red_money + '元红包</span></div>'
  83. }
  84. if(res.rst.data.newUsers.length > i){
  85. var newUsersItem = res.rst.data.newUsers[i];
  86. nickname = '猎小豆';
  87. if(newUsersItem.nickname != 'null' && newUsersItem.nickname != null && newUsersItem.nickname != ''){
  88. nickname = newUsersItem.nickname;
  89. }
  90. listHtml += '<div class="swiper-slide">' + newUsersItem.add_time + '前 <em>' + nickname + '</em>领取了 <span>' + newUsersItem.red_money + '元现金</span></div>'
  91. }
  92. if(res.rst.data.commissions.length > i){
  93. var commissionsItem = res.rst.data.commissions[i];
  94. nickname = '猎小豆';
  95. if(commissionsItem.nickname != 'null' && commissionsItem.nickname != null && commissionsItem.nickname != ''){
  96. nickname = commissionsItem.nickname;
  97. }
  98. listHtml += '<div class="swiper-slide">' + commissionsItem.add_time + '前 <em>' + nickname + '</em>赚取了 <span>' + commissionsItem.red_money + '元佣金</span></div>'
  99. }
  100. }
  101. $(".swiper-container .swiper-wrapper").html(listHtml)
  102. swiperEvent();
  103. }else {
  104. showMsg(res.err)
  105. }
  106. },
  107. error:function () {
  108. showMsg("请稍后再试")
  109. }
  110. })
  111. }
  112. function swiperEvent () {
  113. var swiper = new Swiper('.swiper-container', {
  114. direction: 'vertical',
  115. spaceBetween: 0,
  116. centeredSlides: true,
  117. loopFillGroupWithBlank:true,
  118. noSwiping:true,
  119. loop:true,
  120. autoplay: {
  121. delay: 3000,
  122. disableOnInteraction: false,
  123. },
  124. });
  125. }
  126. function parseQueryString(url) {
  127. //获取地址栏信息
  128. var urlObj = {};
  129. var reg = /([^?=&]+)=([^?=&]+)/g;
  130. url.replace(reg, function($0, $1, $2) {
  131. urlObj[$1] = decodeURIComponent($2);
  132. })
  133. return urlObj;
  134. }
  135. function showMsg(msg) {
  136. //弹框
  137. var msgBox = document.getElementsByClassName('alert-info')[0];
  138. msgBox.children[0].innerText = msg;
  139. msgBox.style.display="block";
  140. setTimeout(function() {
  141. msgBox.style.display="none";
  142. }, 1500);
  143. }