var token = ''; var lunboList = '' var content = '' var level = '' var nextUrl = '' var html = null;//页面 var time = null; var ua = ""; $().ready(function () { getToken() // callBackMethodName() // userInfo()//测试 if(!token){ $("#other").hide() $("#newUser").show() getList() } // 判断是否是微信 ua = navigator.userAgent.toLowerCase();//获取判断用的对象 if (ua.match(/MicroMessenger/i) == "micromessenger") { //在微信中打开 writeLogH5({action:'enter-upload',channel:'H5',url:window.location.href});//埋点 $("#bottom").html(`
下载猎豆,赚取佣金
`) } else { if(!token) { writeLogH5({action:'enter-double',channel:'H5',url:window.location.href});//进入翻倍埋点 } $("#bottom").html(`
分享给好友
分享到朋友圈
`) } }) 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) { //TODO handle the exception } } function callBackMethodName(data) {//app token 回调 var data = JSON.parse(data); //上线时添加 token=data.token; //上线时添加 // token='4d0abd9cfaed33c77bcaf11bbb61378c257552' if(token){ getLevel();// 判断用户等级(上线时在token中调) }else { $("#other").hide() $("#newUser").show() getList() } } function getLevel() { $.ajax({ type: 'post', url: '/api/v2/pullTheNewUser/oldOrNewUser', headers: { 'token': token }, data: { 'token': token }, success: function (res) { if (res && res.errno == 0) { if (res.rst.level >= 3) { $("#newUser").hide() $("#other").show() userInfo() count_down('2019-1-1 00:00:00') writeLogH5({action:'enter-specail',channel:'H5',url:window.location.href});//进入瓜分埋点 } else { $("#other").hide() $("#newUser").show() getList() writeLogH5({action:'enter-double',channel:'H5',url:window.location.href});//进入翻倍埋点 } } }, fail: function () { console.log("fail") } }) } function getList() { $.ajax({ type: 'post', url: '/api/v2/pullTheNewUser/newUserInfo', success: function (res) { if (res && res.errno == 0) { lunboList = res.rst.orderInfo content='' for (var i in lunboList) { if(lunboList[i].nickname.length>4){ lunboList[i].nickname=lunboList[i].nickname.substring(0, 2)+"..." } if(lunboList[i].orderRebate!=0){ content += `
恭喜 `+ lunboList[i].nickname + ` 获得 `+ lunboList[i].orderRebate + `元购物佣金+ `+ lunboList[i].rewardMoeny + `元奖励佣金
` }else { content += `
恭喜 `+ lunboList[i].nickname + ` 邀请新用户下单获得`+lunboList[i].rewardMoeny+`元奖励佣金
` } } $("#wrapper").html(content) swiper() } }, fail: function () { } }) } function userInfo() { $.ajax({ type: 'post', url: '/api/v2/pullTheNewUser/userLogin', dataType: 'json', headers: { 'token': token, }, data: { 'token': token }, success: function (res) { if (res && res.errno == 0) { content = `
`+ res.rst.desc + `
` odometer.innerHTML = Number(res.rst.oneUserMoney); $("#info").html(content) } }, fail: function () { } }) } function nextPage(str,data) { // 埋点 if(str=='share'){ // 佣金翻倍显示 if(!$("#newUser").is(":hidden")) { writeLogH5({action:'christmas-double-share',channel:'H5',url:window.location.href});// 佣金翻倍 }else { writeLogH5({action:'christmas-specail-share',channel:'H5',url:window.location.href});//运营商 } }else if(str=='upload') { writeLogH5({action:'christmas-upload',channel:'H5',url:window.location.href});//埋点 } ua = navigator.userAgent.toLowerCase();//获取判断用的对象 if (ua.match(/MicroMessenger/i) == "micromessenger") { //在微信中打开 window.location.href = "http://a.app.qq.com/o/simple.jsp?pkgname=com.kuxuan.coupon_liedou" } else { // 没有token if(!token){ getToken() }else { $.ajax({ type: 'post', url: '/api/v2/pullTheNewUser/shareToFriend', dataType: 'json', headers: { 'token': token, }, data: { 'token': token }, success: function (res) { nextUrl = res.rst.url if (res && res.errno == 0) { // 判断时候在微信 shareWechatUrl(data) } }, fail: function () { } }) } } } // 倒计时 function count_down(o) { // $("#test").html(o); 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; // $("#test1").text(sec) if (sec == 0 || sec < 0) { html = `` $('.daojishi').html(html); $(".button").addClass('buttonActive'); $(".button").click(function () { copyPassword(); }) clearTimeout(time); } else { s = { '天': sec / 24 / 3600, '时': Math.floor(sec / 3600 % 24), '分': Math.floor(sec / 60 % 60) }; for (i in s) { if (s[i] < 10) { s[i] = '0' + s[i] }; if (i != '天') { str += '' + s[i] + '' + i; } else { str += '' + parseInt(s[i]) + '' + i; } } $("#count").html(str) } } //分享到微信url function shareWechatUrl(data) { var param = { "shareImageUrl": "https://kx-youhuiquan.oss-cn-beijing.aliyuncs.com/lieodu_gw/ldyx.png", "shareTitle": "领完券再返钱,佣金翻倍0元购", "shareDescirpt": "帮你发现隐藏优惠券,下单还能返双倍佣金", "shareUrl": nextUrl,//详情链接 "shareType": data //1:微信好友 2:朋友圈 } param = JSON.stringify(param) 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); } } // 滚动 function swiper() { var mySwiper = new Swiper(".dirList", { autoplay: true, loop: true, slidesPerView: 2, slidesPerGroup: 2, speed: 5000, initialSlide:0, direction: 'vertical' }) } // 弹框显示 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); } // h5埋点 function writeLogH5 (data) { $.ajax({ type:'post', url:'/api/v2/channel/writeLogH5', dataType:'json', data:data, success:function (res) { } }) }