|
|
import api from './api';
|
|
|
|
|
|
let logEvent = function(eventId, data,appData) {
|
|
|
let app = appData ? appData : getApp();
|
|
|
let ln;//语言
|
|
|
let os;//系统类型
|
|
|
let dm;//设备型号
|
|
|
let re;//屏幕大小
|
|
|
let osv;//系统版本
|
|
|
let ak = 'yohobuy_mp';//
|
|
|
let net = '0';
|
|
|
let ts = new Date().getTime() + '';
|
|
|
//用户id
|
|
|
let uid = app && app.globalData && app.globalData.userInfo && app.globalData.userInfo.uid ? app.globalData.userInfo.uid : '';
|
|
|
//设备id
|
|
|
let udid = app && app.globalData && app.globalData.udid ? app.globalData.udid : '';
|
|
|
//会话id
|
|
|
let sid = app && app.globalData && app.globalData.sid ? app.globalData.sid : '';
|
|
|
let cid = app && app.globalData && app.globalData.cid ? app.globalData.cid : '';
|
|
|
|
|
|
let open_id = app && app.globalData && app.globalData.openID ? app.globalData.openID : wx.getStorageSync('openID');
|
|
|
let union_id = app && app.globalData && app.globalData.WXUnion_ID ? app.globalData.WXUnion_ID : wx.getStorageSync('unionID');
|
|
|
let ch = app && app.globalData && app.globalData.ch ? app.globalData.ch : '';
|
|
|
let union_type = app && app.globalData && app.globalData.union_type ? app.globalData.union_type : '';
|
|
|
|
|
|
wx.getSystemInfo({
|
|
|
success: function (res) {
|
|
|
//返回设备信息
|
|
|
dm = res.model;
|
|
|
ln = res.language;
|
|
|
os = res.platform;
|
|
|
osv = res.system;
|
|
|
re = res.screenWidth+'*'+res.screenHeight;
|
|
|
},
|
|
|
complete: function () {
|
|
|
wx.getNetworkType({
|
|
|
success: function (res) {
|
|
|
// 返回网络类型, 有效值:
|
|
|
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
|
|
|
var networkType = res.networkType
|
|
|
if (networkType === 'wifi') {
|
|
|
net = '1';
|
|
|
} else if (networkType === '2g') {
|
|
|
net = '2';
|
|
|
} else if (networkType === '3g') {
|
|
|
net = '3';
|
|
|
} else if (networkType === '4g') {
|
|
|
net = '4';
|
|
|
} else {
|
|
|
net = '0';
|
|
|
}
|
|
|
},
|
|
|
complete: function () {
|
|
|
let statusParam = { 'net': net, 'ln': ln };
|
|
|
let deviceParam = { 'res': re, 'osv': osv, 'os': os, 'ak': ak, 'dm': dm, 'udid': udid, 'ch': union_type != '' ? union_type+"" : ch+""};
|
|
|
let userParam = data;
|
|
|
userParam.C_ID = cid;
|
|
|
userParam.UNION_ID = union_id;
|
|
|
let eventParam = [{ 'param': userParam, 'ts': ts, 'op': eventId, 'uid': uid, 'sid': sid}]
|
|
|
let parameters = { 'status': statusParam, 'device': deviceParam, 'events': eventParam }
|
|
|
// console.log(parameters)
|
|
|
//
|
|
|
api.get({
|
|
|
api: 'yasApi',
|
|
|
url: '',
|
|
|
data: parameters
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
|
logEvent
|
|
|
} |