index.obj.js 629 字节
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
const uniStat = require('uni-stat')
const uniID = require('uni-id-common')
module.exports = {
	report: async function (params = {}) {
		//客户端信息
		const clientInfo = this.getClientInfo()
		//云服务信息
		const cloudInfo = this.getCloudInfo()
		//token信息
		const token = this.getUniIdToken()
		//当前登录用户id
		let uid
		if(token) {
			const tokenRes  = await uniID.createInstance({
				clientInfo
			}).checkToken(token)
			
			if(tokenRes.uid) {
				uid = tokenRes.uid
			}
		}
		//数据上报
		return await uniStat.initReceiver().report(params, {
			...clientInfo,
			...cloudInfo,
			uid
		})
	}
}