Authored by Zhang

pull

... ... @@ -34,7 +34,7 @@ module.exports = class extends global.yoho.BaseModel {
val.couponDescribe = '任意商品使用';
} else if (val.shopNames) {
val.couponDescribe = '限' + val.shopNames + '使用';
} else if (val.shareCoupon === '商品券'){
} else if (val.shareCoupon === '商品券') {
val.couponDescribe = '指定商品可用';
}
});
... ...
... ... @@ -18,7 +18,9 @@ const index = (req, res) => {
let isLogin = req.user && req.user.uid,
pageData = {
isLogin,
signurl: helpers.urlFormat('/signin.html')
signurl: helpers.urlFormat('/signin.html', {
refer: req.originalUrl
})
};
// 唤起 APP 的路径
... ... @@ -38,7 +40,8 @@ const index = (req, res) => {
text: ' '
},
navBtn: false
})
}),
isWechat: req.yoho.isWechat || req.yoho.isMarsApp // 默认判断微信,mars下同微信
}));
};
... ...
... ... @@ -45,9 +45,9 @@ router.get('/index/new/jitDetail', authMW, order.jitDetail); // JIT 拆单配送
router.post('/index/add', indexController.add); // 加入购物车
router.get('/index/index', indexController.index); // 购物车 TODO: 删除
router.get('/index/index', authMW, indexController.index); // 购物车 TODO: 删除
router.get('/index/new', indexController.index); // 购物车(新版接口)
router.get('/index/new', authMW, indexController.index); // 购物车(新版接口)
router.post('/index/new/data', indexController.indexData); // 购物车
router.post('/index/new/select', indexController.select); // 选择取消购物车商品
router.post('/index/new/del', indexController.del); // 删除购物车商品
... ...
... ... @@ -129,6 +129,7 @@ const index = (params) => {
signinUrl: helpers.urlFormat('/signin.html', {
refer: helpers.urlFormat('/home')
}),
referUrl: helpers.urlFormat('/home'),
verifyUrl: helpers.urlFormat('/activity/student/register')
};
... ...
... ... @@ -9,7 +9,7 @@
</label>
<label class="mobile">
联系电话:
<input type="text" name="mobile" value="{{address.mobile}}">
<input type="tel" name="mobile" value="{{address.mobile}}">
</label>
<label class="area">
所在地区:
... ...
... ... @@ -20,7 +20,7 @@
{{/unless}}
{{^}}
<div class="user-info">
<a class="login-btn" href="{{signinUrl}}">
<a class="login-btn" href="{{signinUrl}}" data-refer="{{referUrl}}">
登录/注册
</a>
{{#if @root.studentSwitch}}
... ...
... ... @@ -71,7 +71,8 @@ const newDetail = {
`YOHO!BUY 有货${result.brandName}官网专卖店提供${result.brandName}正品、${result.brandName}真品、 ${result.brandName}打折、${result.brandName}代购等。`, // eslint-disable-line
pageFooter: true,
localCss: true,
appPath: appPath
appPath: appPath,
isMarsApp: req.yoho.isMarsApp // 判断mars
});
}).catch(next);
},
... ...
... ... @@ -334,7 +334,8 @@ const shop = {
shopPage: true,
appPath: 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.shop","params":{"shop_template_type":"2","shop_id":"' +
shopId + '","shop_name":"' + result.seoTitle + '"}}',
localCss: true
localCss: true,
isMarsApp: req.yoho.isMarsApp
});
});
... ...
... ... @@ -14,8 +14,8 @@ const domains = {
// api: 'http://192.168.103.59:8080/gateway',
// service: 'http://192.168.103.59:8080/gateway',
api: 'http://api-test2.yohops.com:9999/',
service: 'http://service-test2.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test2.yohops.com:9999/',
global: 'http://global-test-soa.yohops.com:9999',
liveApi: 'http://testapi.live.yohops.com:9999/',
... ...
... ... @@ -23,6 +23,9 @@ module.exports = () => {
if (req.query.nogoback || req.cookies.nogoback) {
res.locals.nogoback = true;
}
if (req.yoho.isMarsApp) {
res.locals.nodownload = true;
}
next();
};
... ...
... ... @@ -67,7 +67,7 @@ exports.serverError = () => {
return res.render('error/app-auth', {
module: 'common',
page: 'app-redirect-login',
message: '验证失败,请登录',
message: '请登录',
localCss: true,
refer: err.refer
});
... ...
... ... @@ -43,8 +43,6 @@ module.exports = () => {
pageChannel: {}
};
let ua = (req.get('User-Agent') || '').toLowerCase();
const channel = req.query.channel || req.cookies._Channel || 'boys';
// IP 地址
... ... @@ -57,12 +55,15 @@ module.exports = () => {
yoho.channel = channel;
// 判断请求是否来自app
yoho.isApp = (req.query.app_version && req.query.app_version !== 'false') ||
(req.query.appVersion && req.query.appVersion !== 'false') ||
req.cookies.app_version || /YohoBuy/i.test(req.get('User-Agent') || '');
yoho.isMarsApp = /yohomars/i.test(req.get('User-Agent') || '');
yoho.isApp = yoho.isMarsApp ||
req.cookies.app_version ||
/YohoBuy/i.test(req.get('User-Agent') || '') ||
(req.query.app_version && req.query.app_version !== 'false') ||
(req.query.appVersion && req.query.appVersion !== 'false');
yoho.isMobile = /(nokia|iphone|android|ipad|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i.test(req.get('User-Agent') || ''); // eslint-disable-line
yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || '');
yoho.isWeibo = ua.indexOf('weibo') !== -1;
yoho.isWeibo = /weibo/i.test(req.get('User-Agent') || '');
yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || '');
Object.assign(res.locals, yoho);
... ...
... ... @@ -77,6 +77,8 @@ module.exports = () => {
res.cookie('app_version', appVersion);
res.cookie('app_client_type', appSessionType);
}
next();
};
};
... ...
... ... @@ -59,7 +59,7 @@
<link rel="apple-touch-startup-image" sizes="640x920" href="http://static.yohobuy.com/m/v1/img/startup/startup-retina.png" media="screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)">
<link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)">
</head>
<body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}">
<body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if isMarsApp}}is-mars-app{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}">
<div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{{appPath}}}'{{/if}}>
{{#if systemUpdate}}
{{> updata}}
... ...
... ... @@ -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.1/yas.js', '_yas'));
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.2/yas.js', '_yas'));
var _hmt = _hmt || [];
... ... @@ -56,7 +56,7 @@
uid = uid === 0 ? '' : uid;
window._ozuid = uid; // 暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '2.4.1', 'yohobuy_m', uid, '', '');
window._yas(1 * new Date(), '2.4.2', 'yohobuy_m', uid, '', '');
}
setTimeout(function() {
... ...
{
"name": "m-yohobuy-node",
"version": "5.9.10",
"version": "5.9.13",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -256,28 +256,30 @@ $.extend({
5. yas的cookies 种在 .yohobuy.com 根域下
周奇琪
*/
let isWechat = /micromessenger/i.test(navigator.userAgent || '');
let mktc = queryString().mkt_code || queryString().union_type || '';
function saveMktCode() {
if (mktc) {
setCookie('mkt_code', mktc, {
path: '/',
domain: 'yohobuy.com',
expires: 7 // 7天
});
}
}
mkt_code 控制移动到 YAS 2017.07.13
*/
if (isWechat) {
saveMktCode();
} else {
if (!cookie('mkt_code') || mktc === '100000000000349') {
saveMktCode();
}
}
// let isWechat = /micromessenger/i.test(navigator.userAgent || '');
// let mktc = queryString().mkt_code || queryString().union_type || '';
// function saveMktCode() {
// if (mktc) {
// setCookie('mkt_code', mktc, {
// path: '/',
// domain: 'yohobuy.com',
// expires: 7 // 7天
// });
// }
// }
// if (isWechat) {
// saveMktCode();
// } else {
// if (!cookie('mkt_code') || mktc === '100000000000349') {
// saveMktCode();
// }
// }
// 尝试打开 APP
require('./common/open-app');
... ...
... ... @@ -186,16 +186,18 @@ class ChosePanel {
$yohoPage.on('touchstart', '#chose-btn-buynow', (e) => {
let sku = this._checkSku(this.buyNum);
window._yas.sendCustomInfo({
op: 'YB_GDS_BUYNOW_BTN',
param: JSON.stringify({
C_ID: this.C_ID,
PRD_ID: this.data.cartInfo.productId,
PRD_NUM: this.buyNum,
PRD_SKN: this.data.cartInfo.productSkn,
PRD_SKU: sku && sku.skuId
})
}, true);
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_GDS_BUYNOW_BTN',
param: JSON.stringify({
C_ID: this.C_ID,
PRD_ID: this.data.cartInfo.productId,
PRD_NUM: this.buyNum,
PRD_SKN: this.data.cartInfo.productSkn,
PRD_SKU: sku && sku.skuId
})
}, true);
}
return this._choseBtnSureClick(e, true);
});
}
... ...
... ... @@ -71,6 +71,7 @@ $usernameInput.bind('input propertychange', function() {
// 提交表单请求
$addressForm.on('submit', function() {
let username = $usernameInput.val().replace(/(^\s+)|(\s+$)/g, '');
let phone = $(this).find('[name="mobile"]').val();
if (isSubmiting) {
return false;
... ... @@ -95,6 +96,12 @@ $addressForm.on('submit', function() {
tip.show('手机号不能为空');
return false;
}
if (!(/^[0-9]{11}$/.test(phone))) {
tip.show('请填写正确的手机号');
return false;
}
if (!$(this).find('[name="area_code"]').val() || !$(this).find('[name="area"]').val() ||
$(this).find('[name="area_code"]').val().length < 6) {
tip.show('省市区不能为空');
... ...
... ... @@ -82,3 +82,4 @@ $('.res-c').on('click', 'a', function() {
}, true);
}
});
... ...
... ... @@ -17,7 +17,7 @@ let introUrl = $('#introUrl').val(),
end = false;
$('#is-deposit-advance').on('click', function() {
tip.show('定金预售商品只能在APP端购买');
tip.show('定金预售商品只能在有货App购买');
});
// 判断是否要显示向左滑动提示
... ...
let $ = require('yoho-jquery'),
tip = require('plugin/tip');
tip = require('plugin/tip'),
yoho = require('yoho-app');
let functions = {
/**
... ... @@ -68,6 +69,17 @@ let functions = {
* 添加到购物车
*/
addToCart(sku, skn, buyNum) {
if (!yoho.isLogin()) {
let preInfo = `${sku}_${skn}_${buyNum}`;
let actCkOpthn = {
path: '/',
expires: 1
};
window.setCookie('tmp-cart-info', preInfo, actCkOpthn);
window.location.href = '//m.yohobuy.com/signin.html?refer=' + encodeURIComponent(window.location.href);
return false;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_GDS_DT_ADD_TO_SC',
... ... @@ -100,6 +112,7 @@ let functions = {
cartNum = '99+';
}
$('.num-tag').html(cartNum).removeClass('hide');
window.setCookie('tmp-cart-info', '');
}
if (res.message) {
... ...
... ... @@ -151,7 +151,7 @@ function render(data) {
if (data.isDepositAdvance === 'Y') {
setTimeout(function() {
$('#addtoCart').text('立即购买').off('touchstart').on('touchstart', function() {
tip.show('定金预售商品只能在APP端购买');
tip.show('定金预售商品只能在有货App购买');
return false;
});
}, 200);
... ...
... ... @@ -7,6 +7,7 @@ let productSkn = $('#productSkn').val();
let brandId = $('#brand-id').val();
let shopId = $('#shopId').val();
let bundleType = $('#bundleType').val();
let yoho = require('yoho-app');
require('common');
... ... @@ -21,6 +22,26 @@ require('./detail/recommend-for-you-product-desc');
let detailFuns = require('./detail/functions');
let productName = $('.goods-name .name').text();
let productPic = $('.banner-container').find('img:first').attr('src');
if (productPic && productPic.indexOf('http:') < 0) {
productPic = `http:${productPic}`;
}
let shareData = {
title: `推荐这本城市指南给你:${productName}`,
link: location.href,
desc: '最近很多 KOL 在推!据说是探索城市必备神器',
desCircle: `最近被刷屏的这本城市指南终于可以买到了!${productName}`,
imgUrl: productPic
};
if (yoho.isMarsApp) {
yoho.ready(function() {
yoho.invokeMethod('set.shareInfo', shareData);
});
}
window.rePosFooter && window.rePosFooter();
setTimeout(() => {
... ... @@ -87,7 +108,7 @@ setTimeout(() => {
setTimeout(function() {
$('#isDepositAdvance').on('touchstart', function() {
tip.show('定金预售商品只能在APP端购买');
tip.show('定金预售商品只能在有货App购买');
return false;
});
}, 200);
... ... @@ -155,6 +176,16 @@ setTimeout(() => {
let chosePanel = require('common/chose-panel-new');
if (window.cookie('tmp-cart-info') && yoho.isLogin()) {
let preInfo = window.cookie('tmp-cart-info').split('_');
if (preInfo[1] === $('#productSkn').val()) {
detailFuns.addToCart(preInfo[0], preInfo[1], preInfo[2]);
} else {
window.setCookie('tmp-cart-info', '');
}
}
$('#addtoCart, #ticketsToCart').on('touchstart', function() {
let productCode = $('#limitProductCode').val();
let seckill = $('.seckill-time').length;
... ... @@ -180,8 +211,14 @@ setTimeout(() => {
return;
}
if (result.buyNow) { // 立即购买
location.href = '/cart/index/buynow/orderensure?product_sku=' +
let nextUrl = location.origin + '/cart/index/buynow/orderensure?product_sku=' +
result.sku.skuId + '&buy_number=' + result.buyNum;
if (yoho.isMarsApp && !yoho.isLogin()) {
yoho.goLogin(nextUrl);
} else {
location.href = nextUrl;
}
return;
}
detailFuns.addToCart(result.sku.skuId, productSkn, result.buyNum);
... ... @@ -368,7 +405,8 @@ setTimeout(() => {
// 加载详情页的返回顶部按钮并注册事件
$(document).scroll(function() {
if ($(document).scrollTop() >= $(document).height() - $(window).height() - 120) {
if (($(document).scrollTop() >= $(document).height() - $(window).height() - 120) &&
$('.back-to-top').length > 0) {
let top = $('.back-to-top').offset().top - $('.float-top').offset().top +
($('.back-to-top').height() - $('.float-top').height()) / 2;
let left = $('.back-to-top').offset().left - $('.float-top').offset().left;
... ...
... ... @@ -37,7 +37,10 @@ yoho = {
/**
* 判断是否是 APP
*/
isApp: /YohoBuy/i.test(navigator.userAgent || '') || qs && qs.app_version || cookie.get('app_version'),
isMarsApp: /YohoMars/i.test(navigator.userAgent || ''),
isApp: /YohoMars/i.test(navigator.userAgent || '') ||
/YohoBuy/i.test(navigator.userAgent || '') ||
qs && qs.app_version || cookie.get('app_version'),
isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''),
isAndroid: /Android/i.test(navigator.userAgent || ''),
... ... @@ -46,13 +49,6 @@ yoho = {
*/
data: window.yohoInterfaceData,
/**
* 判断是否是 登录
*/
isLogin: function() {
return cookie.get('_YOHOUID');
},
ready: function(callback) {
if (this.isApp) {
document.addEventListener('deviceready', callback);
... ... @@ -121,17 +117,29 @@ yoho = {
getUid: function() {
if (yoho.isApp) {
return qs.uid;
return qs.uid || cookie.get('_YOHOUID') || cookie.get('app_uid');
}
return window.getUid();
},
/**
* 判断是否是 登录
*/
isLogin: function() {
return this.getUid();
},
goLogin: function(refer, data) {
let url;
if (refer.indexOf('//') === 0) {
refer = location.protocol + refer;
}
url = 'http://m.yohobuy.com/signin.html?refer=' + encodeURIComponent(refer);
refer = yoho.parseUrl(refer || location.href);
if (this.isApp) {
url = location.href;
if (this.isAndroid) {
... ...
... ... @@ -353,3 +353,9 @@
}
}
}
.is-mars-app {
.my-page {
padding-bottom: 120px;
}
}
... ...
... ... @@ -257,3 +257,9 @@
}
}
}
.is-mars-app {
.yoho-header {
display: none;
}
}
... ...
... ... @@ -1190,3 +1190,29 @@ $basicBtnC: #eb0313;
iframe {
display: none;
}
.is-mars-app {
.good-detail-page {
margin-bottom: 140px;
.addto-cart,
.sold-out {
background-color: #000;
margin-left: 100px;
}
.cart-bar {
.num-tag {
background-color: #89b374;
}
.new-foot-ico.fav {
display: none;
}
}
.suspend-home {
display: none;
}
}
}
... ...
... ... @@ -715,3 +715,9 @@
left: 0;
}
}
.is-mars-app {
.collect {
display: none;
}
}
... ...
... ... @@ -76,3 +76,9 @@
background-size: contain;
}
}
.is-mars-app {
#collect {
display: none;
}
}
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:02:31
* @Last Modified by: Targaryen
* @Last Modified time: 2017-05-26 16:42:29
* @Last Modified time: 2017-07-18 14:29:33
*/
/* 红人店铺数据处理 */
... ... @@ -152,13 +152,18 @@ const _tools = {
* @param {*} moduleData
*/
tripleImage(moduleData) {
let displayType = _.get(moduleData, 'properties.displayType', 0);
let displayType = parseInt(_.get(moduleData, 'properties.displayType', 0), 10);
// 没有展示方式,不展示此模块,处理接口返回数据异常的情况
if (!displayType) {
return {};
}
return {
module_type: 'TripleImage',
pics: _picsHandle(moduleData),
isModuleMargin: _.get(moduleData, 'properties.isModuleMargin', 0),
displayType: parseInt(displayType, 10),
displayType: displayType,
};
},
... ...