Authored by 陈峰

uniontype fix

... ... @@ -548,7 +548,8 @@ exports.user = function(req, res, next) {
let result = {
code: 403,
message: '未登录',
data: ''
data: '',
unionType: req.query.union_type || req.cookies.unionTypeYas || ''
};
if (req.user.uid) {
... ...
... ... @@ -13,9 +13,10 @@ const isTest = process.env.NODE_ENV === 'test3' || process.env.NODE_ENV === 'tes
const domains = {
// api: 'http://api.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// service: 'http://service.yoho.cn/',
// yoLuck: 'https://action.yoho.cn',
// liveApi: 'http://testapi.live.yohops.com:9999/',
... ... @@ -27,8 +28,8 @@ const domains = {
// platformApi: 'http://172.16.6.210:8088/',
api: 'http://api-test3.dev.yohocorp.com/',
service: 'http://api-test3.dev.yohocorp.com/',
// api: 'http://api-test3.dev.yohocorp.com/',
// service: 'http://api-test3.dev.yohocorp.com/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.dev.yohocorp.com/',
ufo: 'http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/',
... ... @@ -132,7 +133,7 @@ module.exports = {
notifyUrl: domains.service + 'payment/weixin_notify',
},
geetestJs: '//static.geetest.com/static/tools/gt.js',
jsSdk: '//cdn.yoho.cn/js-sdk/1.3.17/jssdk.js',
jsSdk: '//cdn.yoho.cn/js-sdk/1.3.19/jssdk.js',
redis: {
connect: {
host: '192.168.102.49',
... ...
... ... @@ -54,6 +54,8 @@ module.exports = () => {
// IP 地址
yoho.clientIp = _getClientIp(req);
yoho.unionTypeYas = req.query.union_type || req.cookies.unionTypeYas || '';
if (req.query.fullscreen) {
yoho.fullScreen = true;
}
... ... @@ -79,6 +81,12 @@ module.exports = () => {
res.locals.showHeader = false;
}
if (yoho.unionTypeYas && req.cookies.unionTypeYas !== yoho.unionTypeYas) {
res.cookie('unionTypeYas', yoho.unionTypeYas, {
path: '/'
});
}
next();
};
};
... ...
... ... @@ -12,7 +12,7 @@
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.19/yas.js', '_yas'));
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.20/yas.js', '_yas'));
var _hmt = _hmt || [];
... ...
... ... @@ -244,7 +244,7 @@ $.extend({
// 单击下载按钮 - 接受微信商城或者第三方来源的数据埋点信息
let unionType = queryString().union_type || '';
if (unionType) {
if (unionType && cookie('unionTypeYas') !== unionType) {
setCookie('unionTypeYas', unionType, {
path: '/'
});
... ... @@ -332,6 +332,20 @@ $('body').on('touchstart', '.similar-btn', function() {
return false;
});
// 更新union_type
+(() => {
$('a[href*=activity]').each(function() {
const $el = $(this);
const href = $el.attr('href');
if (href.indexOf('union_type') < 0) {
const sps = href.split('?');
$el.attr('href', `${sps[0]}?union_type=${cookie('unionTypeYas')}&${sps[1]}`);
}
});
})();
(function() {
let lastTime = 0,
prefixes = 'webkit moz ms o'.split(' '),
... ...
... ... @@ -3,6 +3,8 @@
*/
const qs = require('yoho-qs');
const cookie = require('yoho-cookie');
const dialog = require('js/plugin/dialog');
const yoho = require('js/yoho-app');
const u = navigator.userAgent;
const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer);
... ... @@ -49,7 +51,7 @@ const getMktcBySeo = function() {
};
const getMktc = () => {
return qs.mkt_code || qs.union_type || getMktcBySeo() || '100000000000349';
return qs.mkt_code || qs.union_type || cookie.get('unionTypeYas') || getMktcBySeo() || '100000000000349';
};
const canOpenApp = () => {
... ... @@ -76,36 +78,117 @@ const getAppPath = () => {
};
if (canOpenApp()) {
setTimeout(function() {
// if (window._yas && window._yas.sendCustomInfo) {
// window._yas.sendCustomInfo({
// op: 'YB_H5_AWAKE_APP',
// param: JSON.stringify({
// PAGE_NAME: encodeURIComponent(document.title),
// PAGE_URL: encodeURIComponent(location.href)
// })
// }, true);
// }
if (window._hmt && window._hmt.push) {
window._hmt.push(['_trackEvent', 'H5唤起APP', isiOS ? 'Apple' : 'Android', document.title, location.href]);
window._getMktCode = getMktc;
const getIOSVersion = () => {
const verion = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
return parseInt(verion[1], 10);
};
const ua = navigator.userAgent;
const isOriginalChrome = /chrome\/[\d.]+ Mobile Safari\/[\d.]+/i.test(ua) &&
yoho.isAndroid &&
ua.indexOf('Version') < 0;
const getFallUrl = (schemeUrl) => {
let clientId = cookie.get('_yasvd');
let unionTypeYas = cookie.get('unionTypeYas');
const appPath = (schemeUrl || '').replace('yohobuy://yohobuy.com/goapp?', '') || 'openby:yohobuy={"action":"go.home","params":{"gender":"1","channel":"2"}}';
return `https://union.yoho.cn/union/app-downloads.html?union_type=${unionTypeYas}&client_id=${clientId}&${appPath}`;
};
const checkOpenFall = (url, callFunc, noFall) => {
let time = Date.now();
callFunc();
const fallUrl = getFallUrl(url);
if (noFall) {
return;
}
window.setTimeout(function() {
if (Date.now() - time < 1200) {
window.location.href = fallUrl;
}
}, 1000);
};
const callIframe = (url, noFall) => {
checkOpenFall(url, () => {
const ifr = document.createElement('iframe');
ifr.src = url;
ifr.style.display = 'none';
document.body.appendChild(ifr);
}, noFall);
};
setTimeout(function() {
let appPath = getAppPath();
let ifr;
const callUrl = (url, noFall) => {
checkOpenFall(url, () => {
window.location.href = url;
}, noFall);
};
const callA = (url, noFall) => {
checkOpenFall(url, () => {
const ca = document.createElement('a');
ca.setAttribute('href', url);
ca.style.display = 'none';
document.body.appendChild(ca);
ca.click();
}, noFall);
};
if (isiOS) {
window.location.href = appPath;
export const toAppPage = (appUrl, noFall) => {
if (isOriginalChrome) {
callA(appUrl, noFall);
} else if (yoho.isiOS) {
if (getIOSVersion() < 9) {
callIframe(appUrl, noFall);
} else {
ifr = document.createElement('iframe');
ifr.src = appPath;
ifr.style.display = 'none';
document.body.appendChild(ifr);
callUrl(appUrl, noFall);
}
}, 2000);
}
} else {
callIframe(appUrl, noFall);
}
};
window._getMktCode = getMktc;
export const toAppPageDialog = (options) => {
dialog.showDialog({
dialogText: options.title,
hasFooter: {
rightBtnText: '打开Yoho!Buy有货APP'
}
}, function() {
toAppPage(options.appUrl);
}, null, true);
};
export const openApp = () => {
if (canOpenApp()) {
setTimeout(function() {
if (window._hmt && window._hmt.push) {
window._hmt.push(['_trackEvent',
'H5唤起APP',
isiOS ? 'Apple' : 'Android',
document.title,
location.href]);
}
}, 1000);
setTimeout(function() {
let appPath = getAppPath();
toAppPage(appPath, true);
}, 2000);
}
};
openApp();
... ...
require('scss/product/detail/detail.page.scss');
import {toAppPageDialog} from 'js/common/open-app';
let $ = require('yoho-jquery'),
tip = require('js/plugin/tip');
let productId = $('#productId').val();
... ... @@ -277,9 +278,6 @@ setTimeout(() => {
return false;
});
$('#limit-sale').on('touchend', function(e) {
let time,
ifr;
e.stopPropagation();
if ($('.is-mars-app').length > 0 && yoho && yoho.isMarsApp) {
... ... @@ -291,28 +289,10 @@ setTimeout(() => {
return false;
}
dialog.showDialog({
dialogText: '进入有货APP,获取限购码',
hasFooter: {
rightBtnText: '打开Yoho!Buy有货APP'
}
}, function() {
let appUrl = $('input[name="limitCodeUrl"]').val();
ifr = document.createElement('iframe');
ifr.src = appUrl;
ifr.style.display = 'none';
document.body.appendChild(ifr);
window.location.href = appUrl;
time = Date.now();
window.setTimeout(function() {
document.body.removeChild(ifr);
if (Date.now() - time < 1200) {
window.location.href = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho';
}
}, 1000);
}, null, true);
toAppPageDialog({
appUrl: $('input[name="limitCodeUrl"]').val(),
title: '进入有货APP,获取限购码'
});
$('.dialog-wrapper').off('touchstart').on('touchstart', function(para) {
para.stopPropagation();
... ...
... ... @@ -11056,9 +11056,9 @@ yo-cli@=2.1.9:
webpack-merge "^4.1.1"
yargs "^10.0.3"
yoho-activity-sdk@1.1.2:
version "1.1.2"
resolved "http://npm.yohops.com/yoho-activity-sdk/-/yoho-activity-sdk-1.1.2.tgz#47870af1221ad1bfb8cbb9cbc8dd4d70c5eb28bf"
yoho-activity-sdk@1.1.3:
version "1.1.3"
resolved "http://npm.yohops.com/yoho-activity-sdk/-/yoho-activity-sdk-1.1.3.tgz#14a8a952e1fd68cc7c167f1e6336d67262d55ba6"
yoho-cookie@^1.2.0:
version "1.2.0"
... ...