Authored by 毕凯

Merge branch 'gray'

... ... @@ -156,7 +156,7 @@ module.exports = class extends global.yoho.BaseModel {
return {
1: helpers.urlFormat('', {from: 'search', query: row.brand_name}, 'search'),
2: helpers.urlFormat('/product/shop', {domain: row.brand_domain}),
2: `/shop/${row.brand_domain}-${row.shop_id}.html`,
3: helpers.urlFormat('/product/global/list/', {brand: row.global_brand_id})
}[key];
}
... ...
... ... @@ -71,12 +71,12 @@ module.exports = {
});
// mip-link
$('a').each(function() {
let $this = $(this);
let mipLink = `<mip-link href="${$this.attr('href')}" class="${$this.attr('class') || ''}" title="${$this.attr('title') || ''}">${$this.html()}</mip-link>`; // eslint-disable-line
$this.replaceWith(mipLink);
});
// $('a').each(function() {
// let $this = $(this);
// let mipLink = `<mip-link href="${$this.attr('href')}" class="${$this.attr('class') || ''}"
// title="${$this.attr('title') || ''}">${$this.html()}</mip-link>`; // eslint-disable-line
// $this.replaceWith(mipLink);
// });
// style
$('style').each(function() {
... ...
... ... @@ -2,12 +2,12 @@
{{# guang}}
{{# author}}
<div class="editor-info" data-id={{id}}>
<mip-link href="{{url}}">
<a href="{{url}}">
<mip-img class="pic" width="45" height="45" src={{image2 avatar mode=2 q=60}}>
</mip-img>
<div class="name">{{name}}</div>
<div class="intro">{{intro}}</div>
</mip-link>
</a>
</div>
{{/ author}}
{{# detail}}
... ... @@ -39,7 +39,7 @@
<div class="focus-small"></div>
</div>
</div>
<div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><mip-link href="{{href}}">{{tagName}}</mip-link></div>
<div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><a href="{{href}}">{{tagName}}</a></div>
<div class="lable-btn add-to-cart" data-skn="{{product_skn}}">
</div>
</div>
... ... @@ -65,7 +65,7 @@
{{#each relatedReco.goods}}
{{#if url}}
<div class="good-item">
<mip-link href="{{url}}">
<a href="{{url}}">
{{#if default_images}}
<div class="pic">
<mip-img class="pic-mip" width="76" height="102" src="{{image2 default_images w=152 h=204}}">
... ... @@ -78,7 +78,7 @@
<p class="price">&yen;{{sales_price}}</p>
{{/if}}
</div>
</mip-link>
</a>
</div>
{{/if}}
{{/each}}
... ... @@ -89,17 +89,17 @@
{{/ detail}}
{{#detail.content}}
{{#if moreLink}}
<mip-link class="more-goods" href="{{moreLink}}">更多商品</mip-link>
<a class="more-goods" href="{{moreLink}}">更多商品</a>
{{/if}}
{{#if recommendProducts}}
<div class="recommend-goods">
<div class="good-scroll">
{{#each recommendProducts}}
<div class="good-item">
<mip-link href="{{href}}">
<a href="{{href}}">
<mip-img class="pic" width="100" height="134" src="{{image2 pic_url w=152 h=204}}">
</mip-img>
</mip-link>
</a>
<p class="price">&yen;{{price}}</p>
</div>
{{/each}}
... ... @@ -113,13 +113,13 @@
<div class="brand-c">
{{# relatedBrand}}
<div class="brand-item">
<mip-link href="{{url}}">
<a href="{{url}}">
<div class="pic">
<mip-img class="pic-mip" width="75" height="75" src="{{thumb}}">
</mip-img>
</div>
<p>{{name}}</p>
</mip-link>
</a>
</div>
{{/ relatedBrand}}
</div>
... ... @@ -129,7 +129,7 @@
<div class="related-info">
{{# relatedInfo}}
<div class="info-item">
<mip-link href="{{url}}">
<a data-type="mip" data-title="{{title}}" href="//m.yohobuy.com/mip/guang/info/{{id}}.html">
<div class="pic">
<mip-img class="pic-mip" width="117" height="73" src="{{thumb}}">
</mip-img>
... ... @@ -138,7 +138,7 @@
<p class="title">{{title}}</p>
<p class="time">{{publishTime}}</p>
</div>
</mip-link>
</a>
</div>
{{/ relatedInfo}}
</div>
... ... @@ -146,7 +146,7 @@
{{#if relatedTag}}
<div class="brand-tag">
{{# relatedTag}}
<mip-link href="//guang.m.yohobuy.com/tags/index?query={{name}}" class="tag">{{name}}</mip-link>
<a href="//guang.m.yohobuy.com/tags/index?query={{name}}" class="tag">{{name}}</a>
{{/ relatedTag}}
</div>
{{/if}}
... ...
... ... @@ -62,7 +62,7 @@ const newDetail = {
pageHeader: headerData,
result: result,
page: 'new-detail',
title: result.goodsName + result.sortName + '正品 | YOHO!BUY 有货',
title: `${result.brandName}|${result.sortName}|${result.goodsName}|YOHO!BUY 有货`,
keywords: result.brandName + result.sortName + ',' + result.brandName + '官网专卖店,' +
result.brandName + '官方授权店,' + result.brandName + '正品,' + result.brandName + '打折,' +
result.brandName + '折扣店,' +
... ...
... ... @@ -20,15 +20,61 @@ const co = require('bluebird').coroutine;
const shop = {
/**
* 老路由处理,查数据,拼链接
*/
redirect(req, res, next) {
let shopId = _.parseInt(stringProcess.paramsFilter(req.query.shop_id));
let domain = stringProcess.paramsFilter(req.query.domain);
let brandId = _.parseInt(stringProcess.paramsFilter(req.query.brand_id));
co(function* () {
if (shopId && domain) {
return res.redirect(301, `//m.yohobuy.com/shop/${domain}-${shopId}.html`);
}
if (shopId) {
let shopInfoApi = (yield req.ctx(shopModel).getShopInfo(shopId)) || {};
return res.redirect(301, `//m.yohobuy.com/shop/${_.get(shopInfoApi, 'data.shop_domain', 'id')}-${shopId}.html`); // eslint-disable-line
}
if (domain) {
let domainInfo = (yield req.ctx(shopModel).getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息
if (domainInfo.shopId && domainInfo.type === '2') {
return res.redirect(301, `//m.yohobuy.com/shop/${domain}-${_.get(domainInfo, 'shopId')}.html`);
} else {
return res.redirect(301, helpers.urlFormat('/product/index/brand', {
brand_id: _.get(domainInfo, 'id')
}));
}
}
if (brandId) {
return res.redirect(301, helpers.urlFormat('/product/index/brand', { brand_id: brandId }));
}
})().catch(next);
},
/**
* 新路由承接页,参数解析
*/
resolveParams(req, res, next) {
let pathParams = _.last(_.split(req.path.replace('.html', ''), '/'));
req.query.shop_id = _.last(_.split(pathParams, '-'));
shop.entry(req, res, next);
},
/**
* 店铺统一入口
*/
entry(req, res, next) {
const shopId = _.parseInt(stringProcess.paramsFilter(req.query.shop_id));
const brandId = _.parseInt(stringProcess.paramsFilter(req.query.brand_id));
const {
domain
} = req.query;
const domain = req.query.domain;
const uid = req.user.uid;
req.shopInfo = {};
... ...
... ... @@ -561,9 +561,7 @@ module.exports = class extends global.yoho.BaseModel {
let storeUrl = '';
if (origin.shop_id) {
storeUrl = helpers.urlFormat('/product/shop', {
shop_id: origin.shop_id
});
storeUrl = `/shop/${_.get(origin, 'brand_info.brand_domain')}-${_.get(origin, 'shop_id')}.html`;
}
// 悬浮的购物车信息
... ...
... ... @@ -167,7 +167,9 @@ router.get('/index/category', list.shopCategory);
router.get('/index/getBrandCouponsList', list.getBrandCouponsList);
// 店铺重构
router.get('/shop', newShop.entry); // 统一店铺入口
router.get('/shop', newShop.redirect); // 老路由重定向前置处理
router.get('/shop/:domain-:shop_id.html', newShop.resolveParams); // 新入口
router.get('/index/brand', newShop.entry); // 旧的路由,走到新的 controller
router.get('/index/brandFav', newShop.brandFav);
router.get('/new/shop/hotlist', newShop.shopHotList);
... ...
... ... @@ -66,6 +66,11 @@ module.exports = () => {
req.url = `/product/search${req.path}`;
}
if (/^\/shop/.test(req.url)) {
// SEO 店铺路由重写 新路由
req.url = `/product/${req.url}`;
}
next();
};
};
... ...
... ... @@ -25,7 +25,7 @@ function yohoSession(opts) {
res.emit('sessionError');
req.sessionError = true;
req.sessionID = uuid.v4();
req.sessionID = req.sessionID || uuid.v4();
req.session = new memcachedSession.Session(req, req[opts.backSession].sessionBack);
req.session.cookie = new memcachedSession.Cookie({
domain: 'yohobuy.com',
... ...
... ... @@ -18,7 +18,6 @@
<script src="https://mipcache.bdstatic.com/static/v1/mip.js"></script>
<script src="https://mipcache.bdstatic.com/static/v1/mip-stats-baidu/mip-stats-baidu.js"></script>
<script src="https://mipcache.bdstatic.com/static/v1/mip-anim/mip-anim.js"></script>
<script src="https://mipcache.bdstatic.com/static/v1/mip-link/mip-link.js"></script>
<script src="https://mipcache.bdstatic.com/static/v1/mip-audio/mip-audio.js"></script>
</body>
</html>
... ...
... ... @@ -79,6 +79,15 @@
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})(); --}}
<!-- Google Tag Manager -->
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W958MG');
<!-- End Google Tag Manager -->
}, 1000);
}());
... ...
... ... @@ -53,11 +53,11 @@
{{/ tags}}
</div>
<div class="good-detail-img">
<a class="good-thumb" href="{{url}}">
<a class="good-thumb" href="{{url}}" title="{{seoTitle}}">
{{#if @root._noLazy}}
<img src="{{image2 default_images w=235 h=314 q=60}}"/>
<img src="{{image2 default_images w=235 h=314 q=60}}" alt="{{seoTitle}}"/>
{{else}}
<img class="lazy" data-original="{{image2 default_images w=235 h=314 q=60}}"/>
<img class="lazy" data-original="{{image2 default_images w=235 h=314 q=60}}" alt="{{seoTitle}}"/>
{{/if}}
</a>
{{# is_soon_sold_out}}
... ... @@ -79,7 +79,7 @@
</div>
<div class="good-detail-text">
<div class="name">
<a href="{{url}}">{{product_name}}</a>
<a href="{{url}}" title="{{seoTitle}}">{{product_name}}</a>
</div>
<div class="price">
{{#if @root.saleViplogin}}
... ...
{
"name": "m-yohobuy-node",
"version": "6.2.8",
"version": "6.2.9",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -16,6 +16,7 @@ module.exports = merge(baseConfig, {
output: {
publicPath: devInfo.publicPath
},
devtool: 'cheap-module-source-map',
plugins: [
new ExtractTextPlugin('[name].css'),
new webpack.HotModuleReplacementPlugin(),
... ...
... ... @@ -70,10 +70,11 @@ if (/MicroMessenger/i.test(navigator.userAgent)) {
cache: true,
success: function() {
$.ajax({
url: '/activity/wechat/share',
url: location.protocol + '//m.yohobuy.com/activity/wechat/share',
data: {
url: location.href
},
dataType: 'jsonp',
success: function(res) {
if (window.wx) {
window.wx.config({
... ...
const tip = require('plugin/tip');
$(window).on('seckill', function() {
$('.btn-c').before('<a href="https://union.yoho.cn/union/app-downloads.html" class="seckill-download-app">下载APP购买</a>');
$('.btn-c').remove();
});
// 调用秒杀js
// $(window).on('seckill', function(event, detailData) {
// /**
// * [秒抢页面js]
// * author: 李靖<jing.li@yoho.cn>
// * date: 2016/09/08
// */
// let $ = require('yoho-jquery'),
// tip = require('plugin/tip');
// let seckillObj = {};
// let offsetTime = 0;
// let nowTime = 0;
// let startTime = 0;
// let endTime = 0,
// diffTime = 0; // 误差时间
// let dateText = 0,
// newDate = 0,
// newMonth = 0,
// newDay = 0,
// newHour = 0,
// newMinus = 0;
// let secKillPrice = 0;
// // 隐藏折扣信息
// $('.good-detail-page').addClass('hide-discount');
// require('common');
// seckillObj = {
// el: {
// iScroll: null,
// currentTick: null
// },
// startTick: function(status, offTime) {
// let that = this,
// $el = this.el,
// day = parseInt(offTime / (60 * 60 * 24), 10),
// hour = parseInt(offTime % (60 * 60 * 24) / (60 * 60), 10),
// minute = parseInt(offTime % (60 * 60) / 60, 10),
// second = offTime % 60;
// let $elem = status === 0 ? $('.seckill-count-num') : $('.end-time');
// if (offTime >= -1) {
// if (day <= 0) {
// $('.day-c').addClass('hide');
// }
// $elem.find('.tick.day').text(that.formatNumber(day));
// $elem.find('.tick.hour').text(that.formatNumber(hour));
// $elem.find('.tick.minute').text(that.formatNumber(minute));
// $elem.find('.tick.second').text(that.formatNumber(second));
// if (offTime <= -1) { // 结束倒计时刷新状态
// window.location.reload();
// } else {
// $el.currentTick = setTimeout(function() {
// that.startTick(status, --offTime);
// }, 1000);
// }
// }
// },
// formatNumber: (number) => {
// if (number < 0) {
// return '00';
// } else if (number < 10) {
// return '0' + number;
// } else {
// return number;
// }
// },
// };
// $(
// function() {
// $('#goodsDiscount').hide(); // 隐藏折扣楼层
// $('.cart-bar').hide();
// $('.current-price').hide();
// let ajaxUrl = '/product/seckillDetail/seckillData/' + $('#productSkn').val();
// let timestamp = Date.parse(new Date());
// $.ajax({
// type: 'GET',
// url: ajaxUrl + '?tamp=' + timestamp,
// success: function(data) {
// // 秒杀是否结束
// if (data === '' || data.status === 0 || data.status === 3) {
// window.location.replace('/product/' + $('#productSkn').val() + '.html'); // 商品url改版
// // $('.sold-out').hide();
// // $('.cart-bar a:first').append('<a href="javascript:;" class="sold-out">已售罄</a>');
// // $('.addto-cart').hide();
// // $('.cart-bar').show();
// // $('.current-price').show();
// } else {
// // 秒杀开始前
// if (data.status === 1) {
// $('.cart-bar').before(
// '<div class="seckill-count">' +
// '<div class="seckill-count-bg"></div>' +
// '<div class="seckill-count-num">距秒杀开始:' +
// '<span class="day-c"><i class="tick day">00</i>天</span>' +
// '<i class="tick hour">00</i>时' +
// '<i class="tick minute">00</i>分' +
// '<i class="tick second">00</i>秒' +
// '</div>' +
// '</div>'
// );
// $('.current-price').text('¥' + data.secKillPrice).show();
// $('.price-date').eq(0).append(
// '<div class="seckill-time notStart">' +
// '<span class="seckill-time-pic">秒杀预告</span>' +
// '<span class="seckill-time-c">月日</span>' +
// '</div>'
// );
// $('.sold-out').hide();
// $('.btn-c').append('<a href="javascript:;" class="sold-out">即将开抢</a>');
// $('.addto-cart').hide();
// $('.cart-bar').show();
// $('.current-price').show();
// timeInit(data); // eslint-disable-line
// }
// // 秒杀进行中
// if (data.status === 2) {
// $('#addtoCart').off('touchstart');
// // 插入倒计时
// addTimeout($('.price-date').eq(0)); // eslint-disable-line
// let chosePanel = require('common/chose-panel-new');
// let seckillData = data.secKillSku;
// detailData.cartInfo.skus.forEach(
// function(val) {
// seckillData.forEach(
// function(item) {
// if (val.skuId === item.productSku) {
// val.storage = item.storageNum;
// }
// }
// );
// }
// );
// $('#addtoCart').on('touchstart', function() {
// $('.cart-bar').hide();
// chosePanel.show({
// data: detailData,
// disableNum: true
// }).then(result => {
// $('.cart-bar').show();
// if (result && result.sku) {
// window.location.href = '/cart/index/seckill?skn=' +
// $('#productSkn').val() + '&sku=' + result.sku.skuId;
// }
// }, () => {
// $('.cart-bar').show();
// });
// $('.text-info').append($('.seckill-time').clone());
// $('.chose-items .num').find('.clearfix').append(
// '<span class="limit-num-text">限购1件</span>'
// );
// $('.sale-price').text('¥' + secKillPrice).show();
// return false;
// });
// secKillPrice = toDecimal2(data.secKillPrice); // eslint-disable-line
// $('.current-price').text('¥' + secKillPrice).show();
// $('.left-num').hide();
// $('.btn-plus').removeClass('btn-plus');
// $('.addto-cart').text('立即购买');
// $('#chose-btn-sure').text('立即购买').addClass('isSecKill');
// $('.cart-bar').show();
// let seckillNum = 0;
// for (let i = 0; i < data.secKillSku.length; i++) {
// seckillNum = seckillNum + data.secKillSku[i].storageNum;
// }
// if (seckillNum === 0) {
// $('.sold-out').hide();
// $('.btn-c').append('<a href="javascript:;" class="sold-out">已售罄</a>');
// $('.addto-cart').hide();
// }
// $('.current-price').show();
// timeInit(data); // eslint-disable-line
// }
// }
// },
// error: function() {
// tip.show('网络异常~');
// }
// });
// }
// );
// // function seckHide() {
// // $('.chose-panel .size-list ul').each(
// // function() {
// // hideNum = 0;
// // $(this).find('li').each(
// // function() {
// // if ($(this).hasClass('hide')) {
// // oneIndex = $(this).index() + 1;
// // twoIndex = $(this).parent('ul').index() - 2;
// // $('.color-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').hide();
// // } else {
// // hideNum++;
// // }
// // }
// // );
// // if (hideNum === 0) {
// // hideIndex = $(this).index() - 2;
// // $('.color-list ul:first li:eq(' + hideIndex + ')').hide();
// // }
// // }
// // );
// // $('.chose-panel .color-list ul').each(
// // function() {
// // hideNum = 0;
// // $(this).find('li').each(
// // function() {
// // if ($(this).hasClass('hide')) {
// // oneIndex = $(this).index() + 1;
// // twoIndex = $(this).parent('ul').index() - 2;
// // $('.size-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').hide();
// // } else {
// // hideNum++;
// // }
// // }
// // );
// // if (hideNum === 0) {
// // hideIndex = $(this).index() - 2;
// // $('.size-list ul:first li:eq(' + hideIndex + ')').hide();
// // }
// // }
// // );
// // }
// function addTimeout(obj) {
// obj.append(
// '<div class="seckill-time seckill-time-border">' +
// '<span>距结束&nbsp</span>' +
// '<span class="end-time">' +
// '<i class="tick day hide">00</i>' +
// '<i class="tick hour">00</i>:' +
// '<i class="tick minute">00</i>:' +
// '<i class="tick second">00</i>' +
// '</span>' +
// '</div>'
// );
// }
// // 强制保留2位小数点
// function toDecimal2(num) {
// let f = parseFloat(num);
// if (isNaN(f)) {
// return false;
// }
// f = Math.round(num * 100) / 100;
// let s = f.toString();
// let rs = s.indexOf('.');
// if (rs < 0) {
// rs = s.length;
// s += '.';
// }
// while (s.length <= rs + 2) {
// s += '0';
// }
// return s;
// }
// function timeInit(data) {
// let status = 0;
// startTime = data.startTime;
// endTime = data.endTime;
// diffTime = data.currentTime;
// nowTime = diffTime;
// if (startTime > nowTime) {
// offsetTime = startTime - nowTime;
// } else if (nowTime > startTime && nowTime < endTime) {
// offsetTime = endTime - nowTime;
// status = 1;
// }
$(function() {
$('#goodsDiscount').hide(); // 隐藏折扣楼层
$('.current-price').hide();
let ajaxUrl = '/product/seckillDetail/seckillData/' + $('#productSkn').val();
let timestamp = Date.parse(new Date());
$.ajax({
type: 'GET',
url: ajaxUrl + '?tamp=' + timestamp,
success: function(data) {
let secKillPrice = toDecimal2(data.secKillPrice); // eslint-disable-line
if (secKillPrice) {
$('.current-price').before('<h1 class="seckill-price" style="display: inline-block;"></h1>').hide();
$('.current-price').remove();
$('.seckill-price').text('¥' + secKillPrice).show();
} else {
$('.current-price').show();
}
},
error: function() {
tip.show('网络异常~');
}
});
});
// dateText = Number(data.startTime * 1000);
// newDate = new Date(dateText);
// newMonth = newDate.getMonth() + 1;
// newDay = newDate.getDate();
// newHour = newDate.getHours();
// newMinus = newDate.getMinutes();
// if (newMinus === 0) {
// newMinus = '00';
// }
// $('.notStart').find('.seckill-time-c').text(newMonth + '月' + newDay + '日' + newHour + ':' + newMinus);
// seckillObj.startTick(status, offsetTime);
// }
// });
// 强制保留2位小数点
function toDecimal2(num) {
let f = parseFloat(num);
if (isNaN(f)) {
return false;
}
f = Math.round(num * 100) / 100;
let s = f.toString();
let rs = s.indexOf('.');
if (rs < 0) {
rs = s.length;
s += '.';
}
while (s.length <= rs + 2) {
s += '0';
}
return s;
}
// 调用新商品详情页js
require('./new-detail');
... ...
... ... @@ -565,6 +565,7 @@ $basicBtnC: #eb0313;
line-height: 88px;
}
.seckill-price,
.current-price {
margin-right: 10px;
color: #d0021b;
... ...
... ... @@ -2,7 +2,6 @@
* @Author: Targaryen
* @Date: 2017-06-20 15:48:39
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-20 16:04:05
*/
const _ = require('lodash');
const helpers = global.yoho.helpers;
... ... @@ -129,7 +128,7 @@ class DetailProcess {
// 底部简介URL链接
dest.introUrl = '/product/detail/intro/' + origin.product_skn;
dest.brandName = _.get(origin, 'brand_info.brand_name', '');
dest.sortName = _.get(origin, 'middle_sort_name', '');
dest.sortName = _.get(origin, 'small_sort_name', '');
return dest;
}
... ... @@ -149,9 +148,7 @@ class DetailProcess {
};
if (value.shop_id) {
shopInfo.url = helpers.urlFormat('/product/shop', {
shop_id: value.shop_id
});
shopInfo.url = `/shop/${value.brand_domain}-${value.shop_id}.html`;
} else {
shopInfo.url = helpers.urlFormat('', null, value.brand_domain);
}
... ...
... ... @@ -2,6 +2,11 @@
require('../app');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const GENDER = {
1: '男',
2: '女',
3: '男|女'
};
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
... ... @@ -228,6 +233,10 @@ exports.processProductList = (list, options) => {
product.similar = true;
}
let seoGender = product.gender ? GENDER[product.gender] + '|' : '';
product.seoTitle = `${product.brand_name}|${seoGender}${product.small_sort_name}|${product.product_name}|YOHO!BUY有货`; // eslint-disable-line
pruductList.push(product);
});
... ...