var user_id = ''; var red_id= ''; var qs = parseQueryString(window.location.href); window.onload = function () { if(qs.user_id){user_id = qs.user_id}; if(qs.red_id){red_id = qs.red_id}; redOrderBarrage(); shareWechatUrl(); } function shareWechatUrl(){ //获取分享url $.ajax({ type: 'post', url: '/api/v2/redactive/helpOpenRed', data:{ 'red_id':red_id, 'user_id':user_id }, success: function (data) { if (data && data.errno == 0) { var url=data.rst.url; console.log(url); getSignPackage(url);//过微信审核用 }else { // showMsg(res.err) } }, error:function () { // showMsg("请稍后再试") } }) } function getSignPackage (shareUrl) { //过微信审核用 var _this = this; $.ajax({ url:'/api/v2/spellgroup/getSignPackage', type:'post', data:{ url:location.href }, success: function (res) { console.log(res) wexinPay(shareUrl,res,function() { // 分享成功 showMsg("分享成功") _czc.push(["_trackEvent",'v3-红包分享','红包id--' + red_id,'']); },function() { //分享失败 showMsg("分享失败") },function() { //微信审核为通过 }) } }) } function redOrderBarrage(){ //红包详情头部弹幕 $.ajax({ type: 'get', url: '/api/v2/redactive/redOrderBarrage', dataType:'json', success: function (res) { console.log(res) if (res && res.errno == 0) { var listHtml = '',nickname; for(i=0;i<5;i++){ if(res.rst.data.coponInfo.length > i){ var coponInfoItem = res.rst.data.coponInfo[i]; nickname = '猎小豆'; if(coponInfoItem.nickname != 'null' && coponInfoItem.nickname != null && coponInfoItem.nickname != ''){ nickname = coponInfoItem.nickname; } listHtml += '
' + coponInfoItem.add_time + '前 ' + nickname + '领取了 ' + coponInfoItem.red_money + '元优惠券
' } if(res.rst.data.redOpend.length > i){ var redOpendItem = res.rst.data.redOpend[i]; nickname = '猎小豆'; if(redOpendItem.nickname != 'null' && redOpendItem.nickname != null && redOpendItem.nickname != ''){ nickname = redOpendItem.nickname; } listHtml += '
' + redOpendItem.add_time + '前 ' + nickname + '提现了 ' + redOpendItem.red_money + '元红包
' } if(res.rst.data.newUsers.length > i){ var newUsersItem = res.rst.data.newUsers[i]; nickname = '猎小豆'; if(newUsersItem.nickname != 'null' && newUsersItem.nickname != null && newUsersItem.nickname != ''){ nickname = newUsersItem.nickname; } listHtml += '
' + newUsersItem.add_time + '前 ' + nickname + '领取了 ' + newUsersItem.red_money + '元现金
' } if(res.rst.data.commissions.length > i){ var commissionsItem = res.rst.data.commissions[i]; nickname = '猎小豆'; if(commissionsItem.nickname != 'null' && commissionsItem.nickname != null && commissionsItem.nickname != ''){ nickname = commissionsItem.nickname; } listHtml += '
' + commissionsItem.add_time + '前 ' + nickname + '赚取了 ' + commissionsItem.red_money + '元佣金
' } } $(".swiper-container .swiper-wrapper").html(listHtml) swiperEvent(); }else { showMsg(res.err) } }, error:function () { showMsg("请稍后再试") } }) } function swiperEvent () { var swiper = new Swiper('.swiper-container', { direction: 'vertical', spaceBetween: 0, centeredSlides: true, loopFillGroupWithBlank:true, noSwiping:true, loop:true, autoplay: { delay: 3000, disableOnInteraction: false, }, }); } function parseQueryString(url) { //获取地址栏信息 var urlObj = {}; var reg = /([^?=&]+)=([^?=&]+)/g; url.replace(reg, function($0, $1, $2) { urlObj[$1] = decodeURIComponent($2); }) return urlObj; } function showMsg(msg) { //弹框 var msgBox = document.getElementsByClassName('alert-info')[0]; msgBox.children[0].innerText = msg; msgBox.style.display="block"; setTimeout(function() { msgBox.style.display="none"; }, 1500); }