From a6ca58881e7842583814b643a0af9b037a987c3f Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 28 Mar 2019 12:52:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BD=8E=E7=89=88=E6=9C=ACge?= =?UTF-8?q?tLaunchOptionsSync=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.wpy | 22 +++++++++++----------- src/jcfw/SDKManage.js | 14 +++++++++----- src/jcfw/jcfw.js | 15 +++++++++++---- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/app.wpy b/src/app.wpy index 11093a0..6d0e20d 100644 --- a/src/app.wpy +++ b/src/app.wpy @@ -58,16 +58,6 @@ export default class extends wepy.app { this.use('requestfix'); this.use('promisify'); // (g.env === 'test') && hookConsoleLog(); - sdkManage.init(); - sdkManage.Login(() => { - let account = wepy.getStorageSync('account'); - console.log('finish parse jcfw'); - console.log(account); - jcEvent.emit(jcEvent.events.NEED_UPDATE_CFG, {}); - if (this.checkClientLogin()) { - this.login(); - } - }); //全局拦截器 this.intercept('request', { config(p) { @@ -118,7 +108,17 @@ export default class extends wepy.app { } }) } - onLaunch() { + onLaunch(options) { + sdkManage.init(options); + sdkManage.Login(() => { + let account = wepy.getStorageSync('account'); + console.log('finish parse jcfw'); + console.log(account); + jcEvent.emit(jcEvent.events.NEED_UPDATE_CFG, {}); + if (this.checkClientLogin()) { + this.login(); + } + }); } onShow(options) { console.log('app.onShow'); diff --git a/src/jcfw/SDKManage.js b/src/jcfw/SDKManage.js index 2910119..103af84 100755 --- a/src/jcfw/SDKManage.js +++ b/src/jcfw/SDKManage.js @@ -22,8 +22,9 @@ var SDKManage = function() { this.hasLogin = false; this.vision = '1.0.0'; this.ChannelId = 6001; - this.init = function() { - jcfw.init(this.ChannelId, this.gameId, this.isoffical); + this.init = function(launchObj) { + this.launchObj = launchObj; + jcfw.init(this.ChannelId, this.gameId, this.isoffical, launchObj); }; this.doLogin = function(res) { if (this.loginStep < this.logincbarr.length) { @@ -34,9 +35,12 @@ var SDKManage = function() { } }; this.checkSharedata = function() { - var ldata = wx.getLaunchOptionsSync().query; - console.log('checkSharedata'); - console.log(ldata); + var ldata; + if (this.launchObj) { + ldata = this.launchObj.query; + } else { + ldata = wx.getLaunchOptionsSync().query; + } if (ldata.inviter_id) { jcshare.acceptAchievementInvite(ldata.inviter_id, '100', JSON.stringify([['100', 100]])); } diff --git a/src/jcfw/jcfw.js b/src/jcfw/jcfw.js index 8b2694d..8536ba3 100755 --- a/src/jcfw/jcfw.js +++ b/src/jcfw/jcfw.js @@ -66,7 +66,7 @@ var JCFW = { * .onShare(***) * .onShareFail(***) */ - init(channelid, gameid, isoffical, response, env) { + init(channelid, gameid, isoffical, launchObj, response, env) { if (this._inited) { if (this.rsp != response) { this.rsp = response; @@ -95,7 +95,7 @@ var JCFW = { this._loadLocalID(); - this._loadLaunchInfo(); + this._loadLaunchInfo(launchObj); this._loadSystemInfo(); //this._loadConfig(); @@ -474,8 +474,15 @@ var JCFW = { storage.remove(_GAME_LOCALUUID); }, - _loadLaunchInfo() { - this.lauchInfo = wx.getLaunchOptionsSync(); + _loadLaunchInfo(res) { + let info = null; + if(wx && wx.getLaunchOptionsSync){ + info = wx.getLaunchOptionsSync(); + } + this.lauchInfo = res? res: info; + if(!this.lauchInfo){ + return; + } this.gamelog.handlelaunch(this.lauchInfo, (sharetype, shareparam, shareid, inviterid, fromid, fromscene, launchobj) => {