123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- var user_id,token,source = '0';
- var qs = parseQueryString(location.href);
- var source=qs.source?qs.source:"";
- var version=qs.version?qs.version:"";
- $().ready(function(){
- getTokenAddUserIdEvent();//获取token 等信息
- })
- $('.button').on('click',function (event) {
- event.stopPropagation();//阻止事件冒泡
- $(".alert").toggle();
- //点击空白处,下拉框隐藏-------开始
- var tag = $(this).siblings('.alert');
- var flag = true;
- $(document).bind("click",function(e){//点击空白处,设置的弹框消失
- var target = $(e.target);
- if(target[0]!=tag[0] && flag == true){
- $(tag).hide();
- flag = false;
- }
- });
- });
- $(".title").on("click",function(){
- window.location.href="inviteDetail.html?token="+token+"&source="+source+"&version="+version
- })
- $(".weixin").on("click",function(){
- var param = {
- "shareImageUrl": "https://credit-loan.oss-cn-beijing.aliyuncs.com/Uploads/logo/60%403x.png",
- "shareTitle": "信贷经理线上获客神器",
- "shareDescirpt": "真实一手好单,时时推送,边抢边赚钱,邀好友免费抢单~",
- "shareUrl": getLocation()+"inviteWeixin.html?user_id="+user_id+'&source='+source+'&version='+version,//详情链接
- "shareType": 1 //1:微信好友 2:朋友圈
- }
- param = JSON.stringify(param);
- try {
- if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
- window.webkit.messageHandlers.shareWithWechatSession.postMessage(param);
- }
- if (navigator.userAgent.match(/android/i)) {
- obj4H5.shareWithWechatSession(param);
- }
- } catch (error) {
- console.log("微信share")
- }
- })
- $(".quan").on("click",function(){
- var param = {
- "shareImageUrl": "https://credit-loan.oss-cn-beijing.aliyuncs.com/Uploads/logo/60%403x.png",
- "shareTitle": "信贷经理线上获客神器",
- "shareDescirpt": "真实一手好单,时时推送,边抢边赚钱,邀好友免费抢单~",
- "shareUrl": getLocation()+"inviteWeixin.html?user_id="+user_id+'&source='+source+'&version='+version,//详情链接
- "shareType": 1 //1:微信好友 2:朋友圈
- }
- console.log(param.shareUrl)
- param = JSON.stringify(param);
- try {
- if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
- window.webkit.messageHandlers.shareWithWechatTimeline.postMessage(param);
- }
- if (navigator.userAgent.match(/android/i)) {
- obj4H5.shareWithWechatTimeline(param);
- }
- } catch (error) {
- console.log("朋友圈share")
- }
- })
- $(".qqShare").on("click",function(){
- console.log("QQQ");
- var param = {
- "shareImageUrl": "https://credit-loan.oss-cn-beijing.aliyuncs.com/Uploads/logo/60%403x.png",
- "shareTitle": "信贷经理线上获客神器",
- "shareDescirpt": "真实一手好单,时时推送,边抢边赚钱,邀好友免费抢单~",
- "shareUrl": getLocation()+"inviteWeixin.html?user_id="+user_id+'&source='+source+'&version='+version,//详情链接
- "shareType": 1 //1:微信好友 2:朋友圈
- }
- console.log(param.shareUrl)
- param = JSON.stringify(param);
- try {
- if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
- window.webkit.messageHandlers.shareWithWQQTimeline.postMessage(param);
- }
- if (navigator.userAgent.match(/android/i)) {
- obj4H5.shareWithWQQTimeline(param);
- }
- } catch (error) {
- console.log("qq share")
- }
- })
- $(".copy").on("click",function(){
- console.log("copy");
- copyPassword();
- })
- // 获取token
- function getTokenAddUserIdEvent () {
- //获取token 和 user_id
- var param = '{"js_callback" : "getTokenAddUserId"}';
- try{
- if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
- window.webkit.messageHandlers.app_h5_getTokenAndUserid.postMessage(param);
- }
- if(navigator.userAgent.match(/android/i)){
- obj4H5.app_h5_getTokenAndUserid(param);
- }
- }catch(e){
- console.log("兼容");
- // token = '5c7e767d445a81276a49bf346ae170bb'
- // user_id = '6'
- // inviteInformation();//获得的金币数量
- // console.log(user_id)
- // $(".copyTarget").text(getLocation()+"inviteWeixin.html?user_id="+user_id+'&source='+source+'&version='+version)
- }
- }
- function getTokenAddUserId (data) {//app token 回调
- var dataes = JSON.parse(data)
- token = dataes.token;
- user_id = dataes.user_id;
- // if(dataes.source){source = dataes.source}
- inviteInformation();//获得的金币数量
- $(".copyTarget").text(getLocation()+"inviteWeixin.html?user_id="+user_id+'&source='+source+'&version='+version)
- }
- function inviteInformation () {
- //获取邀请好友数量以及获得的金币数量
- $.ajax({
- url:'/user/inviteInformation',
- type:'get',
- dataType:'json',
- headers:{
- token:token,
- version:version,
- source:source
- },
- success: function (res){
- if(res && res.errno == 0){
- // 认证人数=>有效人数
- $("#inviteNum").html(res.rst.auth_num?res.rst.auth_num:0);
- $("#inviteGold").html(res.rst.invite_gold?res.rst.invite_gold:0);
- }
- },
- error: function (err){
- showMsg(res.err)
- console.log("error")
- }
- })
- }
- // 获取上级地址
- function getLocation() {
- var upper=window.location.href.split("/")[window.location.href.split("/").length-1]
- return window.location.href.replace(upper,"");
- }
- //获取地址栏参数
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, function($0, $1, $2) {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
- // 复制淘口令
- function copyPassword() {
- var data=$(".copyTarget").text()
- copy_2.innerHTML = data;
- copy_1.value = data;
- if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
- //区分iPhone设备
- window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
- var Url2=document.getElementById("copy_2");//要复制文字的节点
- var range = document.createRange();
- // 选中需要复制的节点
- range.selectNode(Url2);
- // 执行选中元素
- window.getSelection().addRange(range);
- // 执行 copy 操作
- var successful = document.execCommand('copy');
- // 移除选中的元素
- window.getSelection().removeAllRanges();
- }else{
- var Url2=document.getElementById("copy_1");//要复制文字的节点
- Url2.select(); // 选择对象
- document.execCommand("Copy"); // 执行浏览器复制命令
- }
- showMsg("复制成功")
- }
- // 展示错误提示信息
- function showMsg(msg) {
- $(".alert-info").show();
- $(".alert-info p").text(msg);
- setTimeout(function() {
- $(".alert-info").hide();
- }, 1000);
- }
|