修正低版本getLaunchOptionsSync报错的问题

This commit is contained in:
zhl 2019-03-28 12:52:15 +08:00
parent 55c5eb84d0
commit a6ca58881e
3 changed files with 31 additions and 20 deletions

View File

@ -58,16 +58,6 @@ export default class extends wepy.app {
this.use('requestfix'); this.use('requestfix');
this.use('promisify'); this.use('promisify');
// (g.env === 'test') && hookConsoleLog(); // (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', { this.intercept('request', {
config(p) { 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) { onShow(options) {
console.log('app.onShow'); console.log('app.onShow');

View File

@ -22,8 +22,9 @@ var SDKManage = function() {
this.hasLogin = false; this.hasLogin = false;
this.vision = '1.0.0'; this.vision = '1.0.0';
this.ChannelId = 6001; this.ChannelId = 6001;
this.init = function() { this.init = function(launchObj) {
jcfw.init(this.ChannelId, this.gameId, this.isoffical); this.launchObj = launchObj;
jcfw.init(this.ChannelId, this.gameId, this.isoffical, launchObj);
}; };
this.doLogin = function(res) { this.doLogin = function(res) {
if (this.loginStep < this.logincbarr.length) { if (this.loginStep < this.logincbarr.length) {
@ -34,9 +35,12 @@ var SDKManage = function() {
} }
}; };
this.checkSharedata = function() { this.checkSharedata = function() {
var ldata = wx.getLaunchOptionsSync().query; var ldata;
console.log('checkSharedata'); if (this.launchObj) {
console.log(ldata); ldata = this.launchObj.query;
} else {
ldata = wx.getLaunchOptionsSync().query;
}
if (ldata.inviter_id) { if (ldata.inviter_id) {
jcshare.acceptAchievementInvite(ldata.inviter_id, '100', JSON.stringify([['100', 100]])); jcshare.acceptAchievementInvite(ldata.inviter_id, '100', JSON.stringify([['100', 100]]));
} }

View File

@ -66,7 +66,7 @@ var JCFW = {
* .onShare(***) * .onShare(***)
* .onShareFail(***) * .onShareFail(***)
*/ */
init(channelid, gameid, isoffical, response, env) { init(channelid, gameid, isoffical, launchObj, response, env) {
if (this._inited) { if (this._inited) {
if (this.rsp != response) { if (this.rsp != response) {
this.rsp = response; this.rsp = response;
@ -95,7 +95,7 @@ var JCFW = {
this._loadLocalID(); this._loadLocalID();
this._loadLaunchInfo(); this._loadLaunchInfo(launchObj);
this._loadSystemInfo(); this._loadSystemInfo();
//this._loadConfig(); //this._loadConfig();
@ -474,8 +474,15 @@ var JCFW = {
storage.remove(_GAME_LOCALUUID); storage.remove(_GAME_LOCALUUID);
}, },
_loadLaunchInfo() { _loadLaunchInfo(res) {
this.lauchInfo = wx.getLaunchOptionsSync(); 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, this.gamelog.handlelaunch(this.lauchInfo, (sharetype, shareparam, shareid, inviterid,
fromid, fromscene, launchobj) => { fromid, fromscene, launchobj) => {