提交 fde188ed 作者: 王进

调整启动参数获取方式

上级 7bf4d1f2
...@@ -25,15 +25,14 @@ class WechatSDK { ...@@ -25,15 +25,14 @@ class WechatSDK {
that.ReportParams.productCode = that.sdkParams.product_code = SDKConfig.productCode that.ReportParams.productCode = that.sdkParams.product_code = SDKConfig.productCode
that.sdkParams.appid = SDKConfig.appid that.sdkParams.appid = SDKConfig.appid
that.sdkParams.version = SDKConfig.sdkVersion that.sdkParams.version = SDKConfig.sdkVersion
const p1 = this.getLaunchOptionsSync().then(res => { const options = this.getOptionsInfo()
let queryObj = res.referrerInfo && res.referrerInfo.extraData && Object.keys(res.referrerInfo.extraData).length > 0 ? res.referrerInfo.extraData : {} let queryObj = options.referrerInfo && options.referrerInfo.extraData && Object.keys(options.referrerInfo.extraData).length > 0 ? options.referrerInfo.extraData : {}
res = that.deepCopy({}, res.query, queryObj) queryObj = that.deepCopy({}, options.query, queryObj)
that.printf("SDK -> p1:", 0) that.printf("SDK -> p1:", 0)
that.printf(res, 0) that.printf(queryObj, 0)
that.ReportParams.from = res.from || '' that.ReportParams.from = queryObj.from || ''
that.ReportParams.tag = res.tag || '' that.ReportParams.tag = queryObj.tag || ''
that.ReportParams.fromOpenId = res.fromId || '' that.ReportParams.fromOpenId = queryObj.fromId || ''
}, err => { console.log(err) })
const p2 = this.getNetworkType().then(res => { const p2 = this.getNetworkType().then(res => {
that.printf("SDK -> p2:", 0) that.printf("SDK -> p2:", 0)
that.printf(res, 0) that.printf(res, 0)
...@@ -51,7 +50,7 @@ class WechatSDK { ...@@ -51,7 +50,7 @@ class WechatSDK {
that.sdkParams.os = (res.system).split(' ')[0].toLowerCase() that.sdkParams.os = (res.system).split(' ')[0].toLowerCase()
}, err => { console.log(err) }) }, err => { console.log(err) })
// 同步完所有参数后调用getUserOpenId // 同步完所有参数后调用getUserOpenId
Promise.all([p1, p2, p3]).then(res => { Promise.all([p2, p3]).then(res => {
console.log("队列结束....") console.log("队列结束....")
that.getUserOpenId() that.getUserOpenId()
}, err => { console.log(err) }) }, err => { console.log(err) })
...@@ -159,7 +158,8 @@ class WechatSDK { ...@@ -159,7 +158,8 @@ class WechatSDK {
that.sdkParams.token = res.data.token // 记录用户toekn that.sdkParams.token = res.data.token // 记录用户toekn
that.ReportParams.userId = res.data.uid // 记录用户ID that.ReportParams.userId = res.data.uid // 记录用户ID
that.ReportData({ action: type }) // 上报登录/注册 that.ReportData({ action: type }) // 上报登录/注册
LoginCallBack(that.deepCopy({}, res.data, userInfo, {
LoginCallBack(that.deepCopy({}, res.data, that.getOptionsInfo(), userInfo, {
os: (that.ReportParams.system).split(' ')[0], // 返回系统类型IOS或者android os: (that.ReportParams.system).split(' ')[0], // 返回系统类型IOS或者android
session_key: that.sdkParams.session_key // 返回session_key session_key: that.sdkParams.session_key // 返回session_key
})) // 将用户信息拼上平台用户信息返回 })) // 将用户信息拼上平台用户信息返回
...@@ -237,10 +237,6 @@ class WechatSDK { ...@@ -237,10 +237,6 @@ class WechatSDK {
public sdkAlert(str) { public sdkAlert(str) {
this.showMsg(str) this.showMsg(str)
} }
// 获取分享参数
public getShareParams() {
return this.getLaunchOptionsSync()
}
// 分享 // 分享
public ShareApp(params?) { public ShareApp(params?) {
const that = this const that = this
...@@ -587,19 +583,17 @@ class WechatSDK { ...@@ -587,19 +583,17 @@ class WechatSDK {
}) })
}) })
} }
// 获取启动参数
private async getLaunchOptionsSync():Promise<any> { public getOptionsInfo() {
const that = this const that = this
return new Promise((resolve) => {
const options = (wx as any).getLaunchOptionsSync() const options = (wx as any).getLaunchOptionsSync()
if (Object.keys(options.query).length > 0 || Object.keys(options.referrerInfo).length > 0) { if (Object.keys(options.query).length > 0 || Object.keys(options.referrerInfo).length > 0) {
const obj = {} const obj = {}
that.deepCopy(obj, options.query, options.referrerInfo.extraData) // 合并数据 that.deepCopy(obj, options.query, options.referrerInfo.extraData) // 合并数据
resolve(obj) return obj
} else { } else {
resolve(options) return options
} }
})
} }
private createUserInfoButton() { private createUserInfoButton() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论