Authored by 沈志敏

升级到1.1.5

{
"name": "yoho-js-sdk",
"version": "1.1.4",
"version": "1.1.5",
"description": "YOHO!前端js的功能封装包,主要用于在活动页面中,对主要功能的封装。",
"keywords": [
"YOHO!",
... ...
import $ from 'jquery';
import jsonp from './jsonp';
import user from './user';
import utils from './utils';
import cookies from './cookies';
... ... @@ -129,17 +130,8 @@ let _jsonp = function(el, param, cond){
});
};
let _abTest = function(uid) {
let mkt_code;
if (uid) {
if (Number(uid) % 1024 >= 512) {
mkt_code = 100000000000195; // 默认的值
} else {
mkt_code = 100000000000193; // 个性化,动态接口数据
}
} else {
mkt_code = 100000000000197; // 访客接口数据
}
let _abTest = function() {
let mkt_code = user.getMktCode();
// cover覆盖mkt_code
utils.sParamByIframe('cover=1&mkt_code=' + mkt_code +'&expires=' + (7 * 24 * 60 * 60 * 1000));
... ... @@ -147,11 +139,21 @@ let _abTest = function(uid) {
// 上报曝光事件
let actionUrl = [];
$('a').each(function(){
actionUrl.push($(this).attr('href'));
let href = $(this).attr('href');
if (href && !/^#.*$/.test(href) && !/^javascript.*$/i.test(href)) {
actionUrl.push(href);
}
});
setTimeout(function(){
if (window._yas && window._yas.sendAppLogs) {
var cnt = 0;
var timer = setInterval(function() {
cnt++;
if (cnt > 3) {
clearInterval(timer);
return;
}
if (window._yas && window._yas.sendAppLogs && window.appBaseLogs) {
clearInterval(timer);
window._yas.sendAppLogs({
appop: 'YB_H5_PAGE_AB_OPEN_L',
param: JSON.stringify({
... ... @@ -164,16 +166,19 @@ let _abTest = function(uid) {
}, true);
$('a').click(function() {
window._yas.sendAppLogs({
appop: 'YB_H5_PAGE_AB_FLR_C',
param: JSON.stringify({
C_ID: utils.queryString().yh_channel || 1,
PAGE_URL: window.originUrl,
PAGE_NAME: decodeURI(window.qs.title || document.title),
F_URL: $(this).attr('href'),
CROWD_CODE: mkt_code + ''
})
}, true);
let furl = $(this).attr('href');
if (furl && !/^#.*$/.test(furl) && !/^javascript.*$/i.test(furl)) {
window._yas.sendAppLogs({
appop: 'YB_H5_PAGE_AB_FLR_C',
param: JSON.stringify({
C_ID: utils.queryString().yh_channel || 1,
PAGE_URL: window.originUrl,
PAGE_NAME: decodeURI(window.qs.title || document.title),
F_URL: furl,
CROWD_CODE: mkt_code + ''
})
}, true);
}
});
}
}, 1000);
... ... @@ -202,7 +207,7 @@ let _getProduct = function(param) {
}
});
abTestFlag && _abTest(param.uid);
abTestFlag && _abTest();
};
export default {
... ... @@ -210,6 +215,8 @@ export default {
if (utils.isApp()) {
document.addEventListener('deviceready', function() {
window.yohoInterface.triggerEvent(function(data) {
user.uid = data.uid; // app端 获取uid
// 获取个性话数据
_getProduct({
uid: data.uid,
... ...
... ... @@ -22,5 +22,8 @@ $(function() {
export default {
auth: user.auth,
favout: user.favout
favout: user.favout,
getMktCode: function(){
return user.getMktCode();
}
};
\ No newline at end of file
... ...
... ... @@ -67,5 +67,19 @@ export default {
close: false
});
});
},
getMktCode() {
let mkt_code;
if (this.uid) {
if (Number(this.uid) % 1024 >= 512) {
mkt_code = 100000000000195; // 默认的值
} else {
mkt_code = 100000000000193; // 个性化,动态接口数据
}
} else {
mkt_code = 100000000000197; // 访客接口数据
}
return mkt_code;
}
};
\ No newline at end of file
... ...