123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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 += '<div class="swiper-slide">' + coponInfoItem.add_time + '前 <em>' + nickname + '</em>领取了 <span>' + coponInfoItem.red_money + '元优惠券</span></div>'
- }
- 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 += '<div class="swiper-slide">' + redOpendItem.add_time + '前 <em>' + nickname + '</em>提现了 <span>' + redOpendItem.red_money + '元红包</span></div>'
- }
- 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 += '<div class="swiper-slide">' + newUsersItem.add_time + '前 <em>' + nickname + '</em>领取了 <span>' + newUsersItem.red_money + '元现金</span></div>'
- }
- 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 += '<div class="swiper-slide">' + commissionsItem.add_time + '前 <em>' + nickname + '</em>赚取了 <span>' + commissionsItem.red_money + '元佣金</span></div>'
- }
- }
- $(".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);
- }
|