提交 fde188ed 作者: 王进

调整启动参数获取方式

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