1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- var user_id,token,source = '0';
- var qs = parseQueryString(location.href);
- $().ready(function(){
- getTokenAddUserIdEvent();//获取token 等信息
- })
- $(".button").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,//详情链接
- "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) {
-
- }
- })
- // 获取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 = '2b288bf6765af2147392e85d40380014'
- // user_id = '6'
- // inviteInformation();//获得的金币数量
- }
- }
- 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();//获得的金币数量
- }
- function inviteInformation () {
- //获取邀请好友数量以及获得的金币数量
- $.ajax({
- url:'/user/inviteInformation',
- type:'get',
- dataType:'json',
- headers:{
- token:token
- },
- success: function (res){
- if(res && res.errno == 0){
- $("#inviteNum").html(res.rst.invite_num);
- $("#inviteGold").html(res.rst.invite_gold);
- $(".myReward span").html(res.rst.invite_gold + '江湖币');
- $("#authNum").html(res.rst.auth_num);
- }
- },
- error: function (err){
-
- }
- })
- }
- // 获取上级地址
- 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;
- }
|