// 1.判断是否失效或者过期 // 2.红包不可帮拆时,显示提现列表 // 3.帮好友助力成功,显示好友助力团 var qs = parseQueryString(window.location.href); var loadingFlag = true; var isLoadingFlag = true; var loadingFlag02 = false; var user_id = ''; var red_id = '';//red_id----红包id var presentHtml = ''; //presentHtml---提现列表内容 var helperHtml = '';//helperHtml---好友列表内容 var helperHtml02 = [];//helperHtml02---好友列表内容 var descri="";//descri----针对第一条的特殊描述 var red_money='';//red_money----红包金额 var red_mission=""//red_mission----新手红包金额 var attr_type = 'app'; var token = ''; var surplus_money = ''; var page=1;//新手红包列表分页信息 var mySwiper = ''; $().ready(function(){ _czc.push(["_trackEvent",'v3-发起者红包详情页','页面进入量','']); if(qs.user_id){user_id = qs.user_id}; if(qs.red_id){red_id = qs.red_id}; if(window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger"){ // 微信端 attr_type = 'wechat' getInfo();//在微信需要user_id app中需要token shareWechatUrl();//获得分享url }else{ attr_type = 'app' getToken();//获取token } $(window).scroll(function(){ if($(window).scrollTop()>= $(document).height()-$(window).height()){ //到达底部加载数据 if(loadingFlag && isLoadingFlag && loadingFlag02){ page ++ ; friendHelp(page); } } }); }) // 获取token function getToken() { var param = '{"js_callback" : "callBackMethodName"}'; try { if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { window.webkit.messageHandlers.app_h5_login.postMessage(param); } if (navigator.userAgent.match(/android/i)) { obj4H5.app_h5_login(param); } } catch (e) { // token='6ca4d1d79f0a74b1341eeed7819e3c4c324723' // getInfo() // redOldHelpers() //TODO handle the exception } } function callBackMethodName(data) {//app token 回调 var data = JSON.parse(data); token=data.token; // 如果不存在token时,在body中传递user_id getInfo() redOldHelpers(); } function shareWechatButton () { _czc.push(["_trackEvent",'v3-发起者红包详情页','【发起助力】按钮点击次数','']); //app分享到微信 if(attr_type == 'app'){ $(".shareMask").show(); }else if(attr_type == 'wechat'){ //在微信端引导用户右上角转发分享 $(".share_wechat_mask").show(); $(".share_wechat_mask .share_wechat_con .price").text(surplus_money) } } function closeMask () { //关闭弹框 $(".share_wechat_mask").hide(); $(".shareMask").hide(); } function shareWechatUrl(cb){ //获取分享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; shareUrl = url; cb?cb():""; if(attr_type == 'wechat'){ getSignPackage();//过微信审核用 } }else { // showMsg(res.err) } }, error:function () { // showMsg("请稍后再试") } }) } function getSignPackage () { //过微信审核用 var _this = this; $.ajax({ url:'/api/v2/spellgroup/getSignPackage', type:'post', data:{ url:location.href }, success: function (res) { wexinPay(shareUrl,res,function() { // 分享成功 showMsg("分享成功") _czc.push(["_trackEvent",'v3-红包分享','红包id--' + red_id,'']); },function() { //分享失败 showMsg("分享失败") },function() { //微信审核为通过 }) } }) } function shareWeixin(type){ //app分享到微信或者朋友圈 shareWechatUrl(function(){ appShareWechat(type);//调用app的方法 }) } function appShareWechat (type) { console.log(type) //app分享到微信 var param = { "shareImageUrl": "https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/H5-liedou/redEnvelopes/shareWechat.png", "shareTitle": "@帮我提现,送你22元现金!", "shareDescirpt": "领优惠券还送红包,赚钱提现超简单~", "shareUrl": shareUrl,//详情链接 "shareType": type //1:微信好友 2:朋友圈 } param = JSON.stringify(param); try { if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { window.webkit.messageHandlers.app_h5_wx_share_url.postMessage(param); } if (navigator.userAgent.match(/android/i)) { obj4H5.app_h5_wx_share_url(param); } _czc.push(["_trackEvent",'v3-红包分享','红包id--' + red_id,'']); } catch (error) { } closeMask(); } // 红包详情 function getInfo() { $(".loading").show(); $.ajax({ type: 'post', url: '/api/v2/redactive/getRedOrderDataV2', headers: { 'token':token }, data:{ 'red_id': red_id, 'user_id': user_id, 'is_new': 1//新版,本人不能给本人拆 }, success: function (res) { $(".loading").hide(); if (res && res.errno == 0) { console.log(res) user_id = res.rst.data.user_id; red_id = res.rst.data.red_id; red_mission = res.rst.red_mission; red_money = res.rst.data.red_money; surplus_money = (Number(res.rst.data.red_money) - Number(res.rst.data.red_open_money)).toFixed(2); // 如果红包没有拆开,显示新人助力 if(res.rst.data.red_open_money==0) { redPlant() }else { loadingFlag02 = true; friendHelp() } $(".userImg").attr("src",res.rst.data.headimgurl) $(".cashWithdrawalPrice span span").text(res.rst.data.red_money) // 红包进度 var precent=parseFloat(res.rst.data.red_open_money/res.rst.data.red_money*100); // $(".hint span").html(res.rst.note) if(precent<=80) { $(".progress_bar").css("width",precent+"%") }else if (precent > 80 && precent < 100){ $(".progress_bar").css("width","90%") $(".redEnvelopes .progress .progress_bar .progress_con").css('right','-0.4rem') }else{ $(".progress_bar").css("width","100%") $(".redEnvelopes .progress .progress_bar .progress_con").css('right','0rem') } // 红包状态 $(".progress_bar .progress_con").text("¥"+res.rst.data.red_open_money) var order_type = res.rst.data.type; if(order_type == 1){ //失效 $(".share").attr("disabled","disabled"); $(".share").css("background","#CBCBCB"); $(".share").html("红包已失效"); $(".progress").css('background','#CFCFCF'); $(".progress_bar").css('background','#CBCBCB'); $(".progress_con").css("background",'#CBCBCB'); }else if(order_type == 2){ //已拆完 $(".progress_bar").css("background","#CBCBCB"); $(".progress").css("background","rgb(207, 207, 207,.33)"); $(".progress_con").css("background","#CBCBCB"); $(".share").attr("disabled","disabled"); $(".share").css("background","#CBCBCB"); $(".share").html("红包已拆完") }else if(order_type == 3){ //过期 $(".time").hide(); $(".share").attr("disabled","disabled"); $(".share").css("background","#CBCBCB"); $(".progress_bar").css("background","#CBCBCB"); $(".progress").css("background","rgb(207, 207, 207,.33)"); $(".progress_con").css("background","#CBCBCB"); $(".share").html("红包已过期") }else{ //红包在拆 console.log('正在拆') count_down(res.rst.data.red_ending_time) } $(".notice").text(res.rst.note) }else{ showMsg(res.err) } }, error: function () { showMsg('请稍后再试!') $(".loading").hide(); } }) } function count_down(o){ //倒计时封装; var time = setTimeout(function(){count_down(o)},1000); var datatime=/^[\d]{4}-[\d]{1,2}-[\d]{1,2}( [\d]{1,2}:[\d]{1,2}(:[\d]{1,2})?)?$/ig,str='',conn,s; if(!o.match(datatime)){ // alert('参数格式为2020-01-01[ 01:01[:01]].\r其中[]内的内容可省略'); return false; } var sec=(new Date(o.replace(/-/ig,'/')).getTime() - new Date().getTime())/1000; if(sec == 0 || sec < 0){ //倒计时结束时----都为0 clearInterval(time); }else{ // s={'时':Math.floor(sec/3600%24),'分':Math.floor(sec/60%60),'秒':Math.floor(sec%60),'ms':parseInt((ms=ms-1)/10)}; s={'时':Math.floor(sec/3600%24),'分':Math.floor(sec/60%60),'秒':Math.floor(sec%60)}; for(i in s){ if(s[i]<10){s[i]='0'+s[i]} if(i != '秒'){ str += '' + s[i] + '' + ':'; }else { str += '' + s[i] + '' ; } } $("#count").html('