提交 f1975ebb 作者: 王进

暴露上报注册和登录接口

上级 155b3925
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* @time: 2018-09-19 * @time: 2018-09-19
*/ */
class WechatSDK { class WechatSDK {
private sdkVersion:string = '1.2'
public constructor() { public constructor() {
this.sdkInit() this.sdkInit()
} }
...@@ -11,7 +12,7 @@ class WechatSDK { ...@@ -11,7 +12,7 @@ class WechatSDK {
const _selt = this const _selt = this
_selt.ReportParams.productCode = _selt.sdkParams.product_code = SDKConfig.productCode _selt.ReportParams.productCode = _selt.sdkParams.product_code = SDKConfig.productCode
_selt.sdkParams.appid = SDKConfig.appid _selt.sdkParams.appid = SDKConfig.appid
_selt.sdkParams.version = SDKConfig.sdkVersion _selt.sdkParams.version = _selt.sdkVersion
const options = _selt.getOptionsInfo() // 返回参数对象 const options = _selt.getOptionsInfo() // 返回参数对象
_selt.ReportParams.from = options.from || 0 _selt.ReportParams.from = options.from || 0
_selt.ReportParams.tag = options.tag || 0 _selt.ReportParams.tag = options.tag || 0
...@@ -47,9 +48,7 @@ class WechatSDK { ...@@ -47,9 +48,7 @@ class WechatSDK {
_selt.sdkParams.pay_channel = res.data.default_pay_channel _selt.sdkParams.pay_channel = res.data.default_pay_channel
_selt.getAuthorize = res.data.weixin_from _selt.getAuthorize = res.data.weixin_from
_selt.sdkLogin(LoginCallBack) _selt.sdkLogin(LoginCallBack)
_selt.ReportData({ // 上报激活 _selt.ActiReport() // 上报激活
action: 'activation'
})
}, err => { console.log(err) }) }, err => { console.log(err) })
} }
private sdkLogin(LoginCallBack) { private sdkLogin(LoginCallBack) {
...@@ -60,15 +59,8 @@ class WechatSDK { ...@@ -60,15 +59,8 @@ class WechatSDK {
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
// 根据SDK返回用户状态来判断用户是否注册 // 根据SDK返回用户状态来判断用户是否注册
const type = res.data.action == 'login' ? 'login' : 'register'
_selt.sdkParams.token = res.data.token // 记录用户toekn _selt.sdkParams.token = res.data.token // 记录用户toekn
_selt.ReportParams.userId = res.data.uid // 记录用户ID _selt.ReportParams.userId = res.data.uid // 记录用户ID
if( type == 'register') {
_selt.ReportData({ action: 'register' }) // 上报注册
}
// 所有用户(包括注册)也需要上报登录
_selt.ReportData({ action: 'login' }) // 上报登录
LoginCallBack(_selt.deepCopy({}, res.data, { LoginCallBack(_selt.deepCopy({}, res.data, {
os: _selt.sdkParams.os, // 返回系统类型IOS或者android os: _selt.sdkParams.os, // 返回系统类型IOS或者android
session_key: _selt.sdkParams.session_key // 返回session_key session_key: _selt.sdkParams.session_key // 返回session_key
...@@ -329,6 +321,18 @@ class WechatSDK { ...@@ -329,6 +321,18 @@ class WechatSDK {
console.log("##SDK激活上报参数", portData) console.log("##SDK激活上报参数", portData)
return this.request(link, portData) return this.request(link, portData)
} }
// 上报激活
public ActiReport() {
this.ReportData({ action: 'activation' })
}
// 上报注册
public RegisterReport() {
this.ReportData({ action: 'register' })
}
// 上报登录
public LoginReport() {
this.ReportData({ action: 'login' })
}
// 数据上报接口,外部调用,参数中必须含有action值 // 数据上报接口,外部调用,参数中必须含有action值
public ReportData(portData) { public ReportData(portData) {
const that = this const that = this
...@@ -543,7 +547,7 @@ class WechatSDK { ...@@ -543,7 +547,7 @@ class WechatSDK {
}, },
complete() { complete() {
console.log("##SDK分享发起") console.log("##SDK分享发起")
resolve(0) resolve(0);
} }
})) }))
} catch (err) { } catch (err) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论