diff --git a/apps/activity/controllers/feature.js b/apps/activity/controllers/feature.js index c1e857c..18053f9 100644 --- a/apps/activity/controllers/feature.js +++ b/apps/activity/controllers/feature.js @@ -99,6 +99,11 @@ exports.couponSend = (req, res, next) => { } model.couponSend(uid, token, app).then(result => { + res.set({ + 'Cache-Control': 'no-cache', + Pragma: 'no-cache', + Expires: (new Date(1900, 0, 1, 0, 0, 0, 0)).toUTCString() + }); res.jsonp(result); }).catch(next); }; diff --git a/apps/activity/controllers/individuation.js b/apps/activity/controllers/individuation.js index a5ee906..279d39f 100644 --- a/apps/activity/controllers/individuation.js +++ b/apps/activity/controllers/individuation.js @@ -1,5 +1,6 @@ 'use strict'; const moment = require('moment'); +const _ = require('lodash'); const model = require('../models/individuation'); const channels = { boys: 1, @@ -61,6 +62,11 @@ exports.productLst = function(req, res, next) { } getProductList.then((result) => { + res.set({ + 'Cache-Control': 'no-cache', + Pragma: 'no-cache', + Expires: (new Date(1900, 0, 1, 0, 0, 0, 0)).toUTCString() + }); res.jsonp(result); }).catch(next); }; @@ -68,6 +74,18 @@ exports.productLst = function(req, res, next) { exports.coupon = function(req, res, next) { let activity_template_id = req.query.activity_id; let uid = req.user.uid || req.query.uid; + let app = req.query.app; + + if (app && app.app_version && app.client_type && app.session_key && app.uid) { + uid = { + toString: () => { + return _.parseInt(app.uid); + }, + sessionKey: app.session_key, + appVersion: app.app_version, + appSessionType: app.client_type + }; + } if (!uid || !activity_template_id) { return res.jsonp({ @@ -83,6 +101,11 @@ exports.coupon = function(req, res, next) { result.data.startTime = moment.unix(result.data.startTime).format('YYYY.M.D'); result.data.endTime = moment.unix(result.data.endTime).format('YYYY.M.D'); } + res.set({ + 'Cache-Control': 'no-cache', + Pragma: 'no-cache', + Expires: (new Date(1900, 0, 1, 0, 0, 0, 0)).toUTCString() + }); res.jsonp(result); }).catch(next); }; diff --git a/apps/channel/models/cate.js b/apps/channel/models/cate.js index 5c30d40..13b9038 100644 --- a/apps/channel/models/cate.js +++ b/apps/channel/models/cate.js @@ -5,8 +5,9 @@ */ 'use strict'; const _ = require('lodash'); -const helpers = global.yoho.helpers; -const utils = require('../../../utils'); + +// const helpers = global.yoho.helpers; +// const utils = require('../../../utils'); const genderMap = { boys: '1,3', @@ -38,27 +39,34 @@ module.exports = class extends global.yoho.BaseModel { // 如果有二级菜单,二级菜单跳转,否则一级菜单跳转 if (firstItem.sub && firstItem.sub.length) { _.map(firstItem.sub, function(secondItem) { - secondItem.url = helpers.urlFormat('/', utils.mapSort({ - sort: _.get(secondItem, 'relation_parameter.sort'), - sort_name: secondItem.category_name, - gender: genderMap[key] || '' - }), 'list'); + // secondItem.url = helpers.urlFormat('/', utils.mapSort({ + // sort: _.get(secondItem, 'relation_parameter.sort'), + // sort_name: secondItem.category_name, + // gender: genderMap[key] || '' + // }), 'list'); + secondItem.url = + `//m.yohobuy.com/list/gd${genderMap[key] || ''}-ci${_.get(secondItem, 'category_id')}`; }); firstItem.sub.unshift({ category_name: `全部${firstItem.category_name}`, - url: helpers.urlFormat('/', utils.mapSort({ - sort: _.get(firstItem, 'relation_parameter.sort'), - sort_name: firstItem.category_name, - gender: genderMap[key] || '' - }), 'list') + + // url: helpers.urlFormat('/', utils.mapSort({ + // sort: _.get(firstItem, 'relation_parameter.sort'), + // sort_name: firstItem.category_name, + // gender: genderMap[key] || '' + // }), 'list'), + url: `//m.yohobuy.com/list/gd${genderMap[key] || ''}-ci${_.get(firstItem, 'category_id')}-sn${firstItem.category_name}` // eslint-disable-line }); } else { - firstItem.url = helpers.urlFormat('/', utils.mapSort({ - sort: _.get(firstItem, 'relation_parameter.sort'), - sort_name: firstItem.category_name, - gender: genderMap[key] || '' - }), 'list'); + // firstItem.url = helpers.urlFormat('/', utils.mapSort({ + // sort: _.get(firstItem, 'relation_parameter.sort'), + // sort_name: firstItem.category_name, + // gender: genderMap[key] || '' + // }), 'list'); + + firstItem.url = + `//m.yohobuy.com/list/gd${genderMap[key] || ''}-ci${_.get(firstItem, 'category_id')}`; } }); }); diff --git a/apps/channel/views/partial/brand/hot_brands_swipe.hbs b/apps/channel/views/partial/brand/hot_brands_swipe.hbs index e2ab84c..63ee051 100644 --- a/apps/channel/views/partial/brand/hot_brands_swipe.hbs +++ b/apps/channel/views/partial/brand/hot_brands_swipe.hbs @@ -5,7 +5,7 @@ {{# list}} <li class="swiper-slide"> <a href="{{url}}"> - <img src="{{image2 img q=60}}" alt=""> + <img src="{{image2 img q=60}}" alt="{{textCn}}"> </a> <span class="brands-title">{{textCn}}</span> </li> diff --git a/apps/guang/controllers/detail.js b/apps/guang/controllers/detail.js index 3cfa32a..b91269b 100644 --- a/apps/guang/controllers/detail.js +++ b/apps/guang/controllers/detail.js @@ -86,17 +86,20 @@ const _relatedTag = (tags, isApp) => { */ const _relatedInfo = (getOtherArticle, isApp) => { let relatedInfo = []; - let articleUrl; getOtherArticle.forEach(value => { - articleUrl = helpers.urlFormat('/info/index', { - id: value.id - }, 'guang'); - if (isApp) { - value.url = articleUrl + '&openby:yohobuy={"action":"go.h5","params":{"id":"' + value.id + '","shareparam":{"id":"' + value.id + '"},"islogin":"N","type":1,"url":"http://guang.m.yohobuy.com/info/index","param":{"id":"' + value.id + '"}}}'; + if (value.url.indexOf('guang.m.yohobuy.com') < 0) { + value.url = `${helpers.https(value.url)}?openby:yohobuy={"url":"${value.url}","islogin":"N"}}`; + } else { + value.url = `//m.yohobuy.com/guang/${value.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${value.id}"},"shareparam":{"id":"${value.id}"},"share":"/guang/api/v1/share/guang","id":${value.id},"type":1,"url":"http://m.yohobuy.com/guang/${value.id}.html","islogin":"N"}}`; + } } else { - value.url = articleUrl; + if (value.url.indexOf('guang.m.yohobuy.com') < 0) { + value.url = value.url; + } else { + value.url = `//m.yohobuy.com/guang/${value.id}.html`; + } } value.thumb = helpers.image(value.thumb, 279, 175); @@ -270,18 +273,30 @@ const index = (req, res, next) => { let shareInfo = _shareInfo(id, detail.getArticle); Object.assign(guang, shareInfo); - data.title = detail.getArticle.article_title + ' | Yoho!Buy有货 | 潮流购物逛不停'; + data.title = detail.getArticle.article_title + '-YOHO!BUY 有货网'; data.title_more = true; - data.description = detail.getArticle.article_summary; + data.description = detail.getArticle.descriptionText; data.description_more = true; } + if (detail.getArticle.article_title) { + parameter.tltle = detail.getArticle.article_title + '-YOHO!BUY 有货网'; + parameter.keywords = detail.getArticle.article_title; + } + + if (detail.getArticle.descriptionText) { + parameter.description = detail.getArticle.descriptionText; + } + // 标识有微信分享 data.hasWxShare = true; data.guang.wxFooter = wxFooter; res.render('info/index', Object.assign({ page: 'info-index', + canonical: { + currentHref: `https://www.yohobuy.com${req.originalUrl}` + }, gender: gender, wechatShare: true, isWeixin: isWeixin, @@ -297,17 +312,21 @@ const indexRedirect = (req, res, next) => { let id = req.query.id; if (id) { - let redirectUrl = '/guang/info/'; + let redirectUrl = '/guang/'; + + // if (req.yoho.channel !== req.cookies._Channel) { + // redirectUrl += `${req.yoho.channel}-`; + // } - if (req.yoho.channel !== req.cookies._Channel) { - redirectUrl += `${req.yoho.channel}-`; - } delete req.query.id; + delete req.query.channel; + let param = qs.stringify(req.query); if (param) { param = '?' + param; } + redirectUrl += `${id}.html${param}`; res.redirect(301, redirectUrl); } else { diff --git a/apps/guang/controllers/index.js b/apps/guang/controllers/index.js index 653d904..d990db6 100644 --- a/apps/guang/controllers/index.js +++ b/apps/guang/controllers/index.js @@ -21,6 +21,34 @@ const channels = { lifestyle: 4 }; +const listTDK = { + 0: { + title: '最新潮流文章,逛最新潮流资讯-YOHO!BUY 有货网', + keywords: '最新潮流文章,潮流资讯,逛潮流', + description: '有货网每天提供全球最新最潮的潮流文章资讯,宣传潮流商品,潮流文化,潮流品牌等信息,想更多了解潮流最新资讯就来有货网!' + }, // 最新 + 1001: { + title: '高人气潮流文章,逛人气潮流资讯-YOHO!BUY 有货网', + keywords: '人气潮流文章,潮流人气,逛潮流人气', + description: '有货网每天提供全球人气最高的潮流文章资讯,宣传潮流商品,潮流文化,潮流品牌等信息,想更多了解高人气潮流资讯就来有货网!' + }, // 人气 + 2: { + title: '各种潮流搭配,逛潮流搭配资讯-YOHO!BUY 有货网', + keywords: '搭配潮流文章,潮流搭配', + description: '有货网每天提供全球最新最潮的潮流搭配文章资讯,宣传潮流商品,潮流文化,潮流品牌等信息,想更多了解学习潮流搭配资讯就来有货网!' + }, // 搭配 + 4: { + title: '潮流品牌,逛各种潮流品牌资讯-YOHO!BUY 有货网', + keywords: '逛潮品,潮流潮品,潮品资讯', + description: '有货网每天提供全球最新最潮的潮流潮品文章资讯,宣传潮流商品,潮流文化,潮流品牌等信息,想更多了解学习潮流潮品资讯就来有货网!' + }, // 潮品 + 22: { + title: '潮流视频,欣赏最新最好玩的潮流视频-YOHO!BUY 有货网', + keywords: '潮流视频,看潮流', + description: '有货网每天提供全球最新最潮最精彩的潮流视频,宣传潮流商品,潮流文化,潮流品牌等信息,想更多欣赏潮流视频就来有货网!' + } // 视频 +}; + /** * [编辑页面] */ @@ -68,9 +96,9 @@ const editor = (req, res, next) => { res.render('index/list', Object.assign({ page: 'index-editor', - title: `潮流编辑${name}|YOHO!BUY有货`, - keywords: `潮流编辑${name}`, - description: `YOHO!BUY有货潮流编辑${name}!`, + title: `【${name}】潮流编辑${name}-YOHO!BUY 有货网`, + keywords: `${name},潮流编辑${name},潮流编辑`, + description: `有货逛潮流,潮流编辑${name}分享大量原创潮流资讯,掌握大量不同类别的潮流文化知识信息,尽在有货逛潮流。`, guangList: true, gender: gender, guang: { @@ -196,9 +224,9 @@ const index = (req, res, next) => { let responseData = { module: 'guang', page: 'index', - title: '逛|逛潮流,逛购物,官方授权正品潮流购物中心|YOHO!BUY有货', - keywords: '逛,逛潮流,逛购物', - description: 'YOHO!BUY有货逛频道,来YOHO!玩潮流!潮搭大解析!年轻人潮流购物中心,中国潮流购物风向标,吴亦凡重磅代言!YOHO!BUY有货100%正品保证,支持货到付款。', + title: '逛潮流,最新原创潮流资讯 |YOHO!BUY有货', + keywords: '潮流资讯,潮流文章,有货潮流分享', + description: '来有货玩潮流,潮流资讯大分享!年轻人潮流购物中心,了解潮流趋势、掌握潮流文化知识信息,尽在有货逛潮流!', showFooterTab: footerModel.getUrlData('guang') }; @@ -209,6 +237,8 @@ const index = (req, res, next) => { gender: req.query.gender || req.query.channel && typeLib.gender[req.query.channel] || '1,3' }; + responseData = Object.assign(responseData, listTDK[param.type]); + req.ctx(IndexModel).getArticle(param).then(result => { if (result && result.guang && result.guang.infos) { if (!result.guang.infos.length) { @@ -243,9 +273,9 @@ const tag = (req, res, next) => { pageHeader: headerData, module: 'guang', page: 'index-editor', - title: tagTitle + ' | Yoho!Buy有货 | 潮流购物逛不停', - keywords: tagTitle, - description: 'YOHO!BUY有货潮流' + tagTitle + '!' + title: '【' + tagTitle + '】' + tagTitle + '潮流资讯-YOHO!BUY 有货网', + keywords: tagTitle + ',' + tagTitle + '潮流资讯,' + tagTitle + '文章', + description: '来有货逛潮流,' + tagTitle + '潮流资讯大分享!了解' + tagTitle + '潮流趋势,掌握' + tagTitle + '潮流文化知识信息,尽在有货逛潮流。' }; let param = { diff --git a/apps/guang/models/detail.js b/apps/guang/models/detail.js index 97f0a25..f9b0226 100644 --- a/apps/guang/models/detail.js +++ b/apps/guang/models/detail.js @@ -7,6 +7,7 @@ const serviceAPI = global.yoho.ServiceAPI; const _ = require('lodash'); const helpers = global.yoho.helpers; +const redis = require('../../../utils/redis'); const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; @@ -204,6 +205,21 @@ class DetailModel extends global.yoho.BaseModel { }); } + // 获取逛文章分词内容 + _getGuangArticleKeyword(id) { + return redis.all([ + ['get', `global:yoho:guang:detail:${id}`] + ]).then(redisData => { + redisData = JSON.parse(redisData[0] || '{}'); + + if (!redisData.data) { + return this._getArticleContent(id); + } + + return redisData; + }); + } + /** * [逛资讯详情页数据封装] * @param {[int]} id [内容ID] @@ -229,7 +245,7 @@ class DetailModel extends global.yoho.BaseModel { let article = result.getArticle = data && data.data || {}; let promises = [ this._getAuthor(article.author_id), - this._getArticleContent(id), + this._getGuangArticleKeyword(id), this._getBrand(id) ]; @@ -260,7 +276,19 @@ class DetailModel extends global.yoho.BaseModel { } if (datas[1]) { + let textPosition = 1, + descriptionText; + result.getArticleContent = getArticleContent = datas[1].data; + + for (let i = 0; i < getArticleContent.length; i++) { + + if (getArticleContent[i].text && textPosition === 1) { + descriptionText = _.get(getArticleContent[i], 'text.data.text'); + _.set(result, 'getArticle.descriptionText', descriptionText.replace(/<\/?[^>]*>/g, '')); + textPosition++; + } + } } if (isApp && datas[4] && datas[4].data) { @@ -330,6 +358,10 @@ class DetailModel extends global.yoho.BaseModel { if (datas[2]) { result.getBrand = datas[2].data; + + _.forEach(result.getBrand, function(val) { + val.url = `//m.yohobuy.com/shop?domain=${val.brandDomain}`; + }); } if (isShare && datas[4]) { diff --git a/apps/guang/models/plustar.js b/apps/guang/models/plustar.js index d9005b8..b95ef6c 100644 --- a/apps/guang/models/plustar.js +++ b/apps/guang/models/plustar.js @@ -261,9 +261,23 @@ module.exports = class extends global.yoho.BaseModel { data.url = data.url + ''; } + if (isApp) { + if (data.url.indexOf('guang.m.yohobuy.com') < 0) { + data.url = `${helpers.https(data.url)}?openby:yohobuy={"url":"${data.url}","islogin":"N"}}`; + } else { + data.url = `//m.yohobuy.com/guang/${data.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${data.id}"},"shareparam":{"id":"${data.id}"},"share":"/guang/api/v1/share/guang","id":${data.id},"type":1,"url":"http://m.yohobuy.com/guang/${data.id}.html","islogin":"N"}}`; + } + } else { + if (data.url.indexOf('guang.m.yohobuy.com') < 0) { + data.url = data.url; + } else { + data.url = `//m.yohobuy.com/guang/${data.id}.html`; + } + } + list.push({ id: data.id, - url: isApp ? `${helpers.https(data.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${data.id}"},"shareparam":{"id":"${data.id}"},"share":"/guang/api/v1/share/guang","id":${data.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : data.url, // eslint-disable-line + url: data.url, title: data.title, text: data.intro, img: helpers.image(data.src, 640, 640), @@ -333,7 +347,7 @@ module.exports = class extends global.yoho.BaseModel { if (isApp) { url = '?openby:yohobuy={"action":"go.brand","params":{"brand_id":"' + brandId + '","is_different":"' + isDifferent + '"}}'; // eslint-disable-line - uid = parseInt(uid, 10); + // uid = parseInt(uid, 10); } else { url = '//' + brandDomain + '.m.yohobuy.com'; } diff --git a/apps/guang/router.js b/apps/guang/router.js index df6bafa..336d4b6 100644 --- a/apps/guang/router.js +++ b/apps/guang/router.js @@ -53,9 +53,9 @@ router.post('/opt/collectArticle', opt.collectArticle); // 资讯文章收藏 (H router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏 router.get('/info/index', rewrite.channel, detail.indexRedirect); // 逛详情页 -router.get(/^\/info\/(.*?)\.html/, rewrite.resolve, mip, detail.index); // 逛详情页 SEO优化 +router.get(/^\/info\/(.*?)\.html/, rewrite.resolve, mip, detail.indexRedirect); // 逛详情页 SEO优化 -router.get('/:id.html', detail.index); // 逛详情页(兼容 PC 跳转过来的链接) +router.get('/:id.html', mip, detail.index); // 逛详情页(兼容 PC 跳转过来的链接) router.get('/info/mini', detail.mini); // 逛mini内容页 router.get('/info/foryoho', detail.foryoho); // 逛foryoho内容页 diff --git a/apps/guang/views/action/guang.hbs b/apps/guang/views/action/guang.hbs index dd01d26..2334a9b 100644 --- a/apps/guang/views/action/guang.hbs +++ b/apps/guang/views/action/guang.hbs @@ -7,6 +7,9 @@ {{type}} </li> {{/ navs}} + <li class="guang-nav-item news-jump" data-type=-1> + <a href='//m.yohobuy.com/guang/news' title='资讯'>资讯</a> + </li> </ul> <div id="info-list" class="info-list-container"> diff --git a/apps/guang/views/action/info/index.hbs b/apps/guang/views/action/info/index.hbs index 4c3d5a0..af55ab9 100644 --- a/apps/guang/views/action/info/index.hbs +++ b/apps/guang/views/action/info/index.hbs @@ -17,7 +17,7 @@ {{# detail}} <div class="detail" data-id="{{id}}"> <div class="post-title"> - <p class="title">{{title}}</p> + <h1 class="title">{{title}}</h1> {{> index/tvls}} </div> <div class="post-content"> @@ -31,9 +31,9 @@ {{#if bigImage}} <div class="post-block big-img-block"> {{#if noLazy}} - <img src={{image2 bigImage q=60}}> + <img src={{image2 bigImage q=60}} alt="{{@root.guang.detail.title}}"> {{else}} - <img class="lazy" data-original={{image2 bigImage q=60}}> + <img class="lazy" data-original={{image2 bigImage q=60}} alt="{{@root.guang.detail.title}}"> {{/if}} {{#if tagList}} <div class="tag-list-box"> @@ -49,11 +49,11 @@ <div class="post-block small-img-block clearfix"> {{#if noLazy}} {{# smallImage}} - <img src={{image2 src q=60}}> + <img src={{image2 src q=60}} alt="{{@root.guang.detail.title}}"> {{/ smallImage}} {{else}} {{# smallImage}} - <img class="lazy" data-original={{image2 src q=60}}> + <img class="lazy" data-original={{image2 src q=60}} alt="{{@root.guang.detail.title}}"> {{/ smallImage}} {{/if}} @@ -153,7 +153,7 @@ <li class="brand buriedpoint" data-bp-id="guang_brand_{{name}}_0"> <a href={{url}}> <div class="brand-logo"> - <img class="lazy" data-original="{{image2 thumb q=60}}"> + <img class="lazy" data-original="{{image2 thumb q=60}}" alt="{{name}}"> </div> <p class="brand-name">{{name}}</p> </a> diff --git a/apps/home/views/action/family/coin-detail.hbs b/apps/home/views/action/family/coin-detail.hbs index 7165f21..bbb1d45 100644 --- a/apps/home/views/action/family/coin-detail.hbs +++ b/apps/home/views/action/family/coin-detail.hbs @@ -19,19 +19,19 @@ <span class="tick"></span> </li> <li data-source="2"> - <span class="title">Mars</span> + <span class="title">mars</span> <span class="tick"></span> </li> <li data-source="6"> - <span class="title">Yo!Coffee</span> + <span class="title">Yo!COFFEE</span> <span class="tick"></span> </li> <li data-source="5"> - <span class="title">Yo!Green</span> + <span class="title">Yo!GREEN</span> <span class="tick"></span> </li> <li data-source="7"> - <span class="title">Yo!Little</span> + <span class="title">Yo!LITTLE</span> <span class="tick"></span> </li> </ul> diff --git a/apps/mip/controllers/guang.js b/apps/mip/controllers/guang.js index 8c00909..ba4ba47 100644 --- a/apps/mip/controllers/guang.js +++ b/apps/mip/controllers/guang.js @@ -10,6 +10,7 @@ const guangProcess = require(`${global.utils}/guang-process`); const mRoot = '../models'; const DetailModel = require(`${mRoot}/guang`); const typeLib = require('../../../config/type-lib'); +const moment = require('moment'); const channels = { boys: 1, girl: 2, @@ -17,6 +18,10 @@ const channels = { lifestyle: 4 }; +const mipDate = (day) => { + return moment(day).format('YYYY-MM-DDTHH:mm:ss'); +}; + // const testStr = ''; /** @@ -202,7 +207,11 @@ const detailIndex = (req, res, next) => { css: yield css('guang/detail.css'), gender: gender, localStyle: processContents.css, - title: detail.getArticle.article_title + title: detail.getArticle.article_title, + mipId: id, + mipPublishTime: mipDate(detail.getArticle.publish_time * 1000), + mipPic: detail.getArticle.cover_image ? detail.getArticle.cover_image.split('?')[0] : '', + mipDes: detail.getArticle.article_summary }, data)); })().catch(next); }; diff --git a/apps/mip/router.js b/apps/mip/router.js index 9bcdd7f..c7fd9fe 100644 --- a/apps/mip/router.js +++ b/apps/mip/router.js @@ -16,5 +16,6 @@ const guang = require(`${cRoot}/guang`); router.use(mip); router.get(/^\/guang\/info\/(.*?)\.html/, rewrite.resolve, guang.detailIndex); +router.get(/^\/guang\/(.*?)\.html/, rewrite.resolve, guang.detailIndex); module.exports = router; diff --git a/apps/mip/views/action/guang/detail.hbs b/apps/mip/views/action/guang/detail.hbs index e194863..daedbe1 100644 --- a/apps/mip/views/action/guang/detail.hbs +++ b/apps/mip/views/action/guang/detail.hbs @@ -129,7 +129,7 @@ <div class="related-info"> {{# relatedInfo}} <div class="info-item"> - <a data-type="mip" data-title="{{title}}" href="//m.yohobuy.com/mip/guang/info/{{id}}.html"> + <a data-type="mip" data-title="{{title}}" href="//m.yohobuy.com/mip/guang/{{id}}.html"> <div class="pic"> <mip-img class="pic-mip" width="117" height="73" src="{{thumb}}"> </mip-img> diff --git a/apps/news/controllers/index.js b/apps/news/controllers/index.js index 4a2c810..ecb09a1 100644 --- a/apps/news/controllers/index.js +++ b/apps/news/controllers/index.js @@ -19,9 +19,9 @@ exports.index = (req, res, next) => { } return res.render('news-index', Object.assign({ - title: '新闻 | ' + (res.locals.title || ''), + title: '资讯 | ' + (res.locals.title || ''), pageHeader: headerModel.setNav({ - navTitle: '新闻' + navTitle: '资讯' }), module: 'news', localCss: true, @@ -38,10 +38,12 @@ exports.detail = (req, res, next) => { let channel = req.yoho.channel; let id = req.params[0] || 0; let cid = req.params[1] || 0; + let app = req.params[2] || 0; let query = { channel: channel, id: id, cid: cid, + app: app, }; if (!id || !cid) { @@ -51,13 +53,13 @@ exports.detail = (req, res, next) => { req.ctx(newsService).detail(channel, query).then(result => { return res.render('news-detail', Object.assign({ pageHeader: headerModel.setNav({ - navTitle: result.header && result.header.title || '新闻详情页' + navTitle: result.header && result.header.title || '资讯详情页' }), module: 'news', localCss: true, pageFooter: true, page: 'detail', - cononical: { + canonical: { currentHref: `//www.yohobuy.com${req.originalUrl}` } }, result)); diff --git a/apps/news/models/news-service.js b/apps/news/models/news-service.js index acafe91..7f72534 100644 --- a/apps/news/models/news-service.js +++ b/apps/news/models/news-service.js @@ -2,8 +2,10 @@ const _ = require('lodash'); const helpers = global.yoho.helpers; +const utils = '../../../utils'; +const redis = require(`${utils}/redis`); const NewsAPi = require('./news-api'); -const utils = require('./utils'); +const newsUtils = require('./utils'); const moment = require('moment'); const ATYPE = 'yohobuy4008899646,yohogroup,YOHO_GIRL,mars-app'; @@ -24,7 +26,7 @@ module.exports = class extends global.yoho.BaseModel { lresult = { id: articleData.id, - url: helpers.urlFormat(`/news/${articleData.id}_${articleData.cid}.html`), + url: helpers.urlFormat(`/guang/news/${articleData.id}_${articleData.cid}_${articleData.app}.html`), img: helpers.image(articleData.image, width, height, 1), title: articleData.title, publishTime: articleData.update_time && moment(articleData.update_time * 1000).format('MM月DD HH:mm'), @@ -80,32 +82,48 @@ module.exports = class extends global.yoho.BaseModel { title: contents.title, summary: contents.summary, tag: contents.tag, + syncTypeName: contents.syncTypeName || 'YOHO潮流志', publishTime: contents.update_time && moment(contents.update_time * 1000).format('MM月DD HH:mm'), }; - let content = utils.filterPhtml(contents.content, [ - '阅读原文', - '点击这里', - '点这里' - ]); - - return {header: header, content: utils.filterAhtml(content)}; + let content = newsUtils.filterPhtml( + contents.content.replace(/www.yohobuy.com\/chanpin\//ig, 'm.yohobuy.com/chanpin/'), + [ + '阅读原文', + '点击这里', + '点这里' + ] + ); + + content = newsUtils.filterAhtml(content); + + return {header: header, content: newsUtils.imgAlt(content, contents.title, 5)}; } detail(channel, param) { let params = { id: param.id, - cid: param.cid + cid: param.cid, + app: param.app }; - let newsAPi = new NewsAPi(this.ctx); - return newsAPi.getContentDetail(params).then(result => { + return redis.all([ + ['get', `global:yoho:news:detail:${params.id}-${params.cid}-${params.app}`] + ]).then(redisData => { + redisData = JSON.parse(redisData[0] || '{}'); + + if (!redisData.data) { + return new NewsAPi(this.ctx).getContentDetail(params); + } + + return redisData; + }).then(result => { let responseData = {}; // 详情页数据 Object.assign(responseData, this._formatDetail(result, params)); // seo - let title = _.get(responseData, 'header.title', '新闻详情页'); + let title = _.get(responseData, 'header.title', '资讯详情页'); let keywords = []; let tags = _.compact(_.get(responseData, 'header.tag', []).map(el => { return el.tag_name; diff --git a/apps/news/models/utils.js b/apps/news/models/utils.js index 99a406b..0961ce6 100644 --- a/apps/news/models/utils.js +++ b/apps/news/models/utils.js @@ -23,7 +23,10 @@ const util = { }); - return $.html(); + html = $.html(); + $ = ''; + + return html; }, // 过滤 a标签连接和删除html标签中的script和link脚本 @@ -34,9 +37,33 @@ const util = { let $ = cheerio.load(html, {decodeEntities: false}); - $('a').attr('href', 'javascript:void(0);').css({cursor: 'text'});// eslint-disable-line + $('a').removeAttr('style').not('.a-anchor').attr('href', 'javascript:void(0);').css({cursor: 'text'});// eslint-disable-line $('script,link').remove(); - return $.html(); + + html = $.html(); + $ = ''; + + return html; + }, + + // 过滤 a标签连接和删除html标签中的script和link脚本 + imgAlt: (html, alt, num) => { + if (!html) { + return html; + } + + let $ = cheerio.load(html, {decodeEntities: false}); + + _.each($('img').slice(0, num), item => { + let $dom = $(item); + + $dom.attr('alt', $dom.attr('alt') || alt); + }); + + html = $.html(); + $ = ''; + + return html; } }; diff --git a/apps/news/router.js b/apps/news/router.js index aed2328..8c1a21c 100644 --- a/apps/news/router.js +++ b/apps/news/router.js @@ -12,7 +12,7 @@ const cRoot = './controllers'; const newsController = require(`${cRoot}/index`); router.get(['/', '/index/index'], newsController.index); -router.get(/\/([\d]+)_([\d]+).html/, newsController.detail); +router.get(/\/([\d]+)_([\d]+)_([\d]+).html/, newsController.detail); // ajax diff --git a/apps/news/views/action/news-detail.hbs b/apps/news/views/action/news-detail.hbs index a466d3c..a440710 100644 --- a/apps/news/views/action/news-detail.hbs +++ b/apps/news/views/action/news-detail.hbs @@ -2,7 +2,7 @@ <div class="detail" data-id="{{id}}"> {{# header}} <div class="post-title"> - <p class="title">{{title}}</p> + <h1 class="title">{{title}}</h1> {{> news-index/tvls}} </div> {{/header}} diff --git a/apps/news/views/partial/news-index/tvls.hbs b/apps/news/views/partial/news-index/tvls.hbs index 9e108ff..fe121f2 100644 --- a/apps/news/views/partial/news-index/tvls.hbs +++ b/apps/news/views/partial/news-index/tvls.hbs @@ -1,11 +1,14 @@ <div class="time-view-like-share clearfix"> - <i class="iconfont"></i> - {{publishTime}} - {{#if pageView}} - <i class="iconfont"></i> - <span class="page-view">{{pageView}}</span> + {{#if syncTypeName}} + <span class="page-view">来源于微信公众号:{{syncTypeName}}</span> {{/if}} <div class="like-share-container"> + <i class="iconfont"></i> + {{publishTime}} + {{#if pageView}} + <i class="iconfont"></i> + <span class="page-view">{{pageView}}</span> + {{/if}} {{#like}} <i class="iconfont like-btn{{#isLiked}} like{{/isLiked}}"></i> <span class="like-count">{{count}}</span> diff --git a/apps/product/controllers/chanpin.js b/apps/product/controllers/chanpin.js index 3d25e19..8c6519c 100644 --- a/apps/product/controllers/chanpin.js +++ b/apps/product/controllers/chanpin.js @@ -83,8 +83,8 @@ const keyId = (req, res, next) => { description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(result, 'total', 0)}条${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`, pageFooter: true, - cononical: { - currentHref: `//www.yohobuy.com${req.originalUrl}` + canonical: { + currentHref: `https://www.yohobuy.com${req.originalUrl}` } }); }).catch(next); diff --git a/apps/product/controllers/detail.js b/apps/product/controllers/detail.js index 7ec6c81..0676208 100644 --- a/apps/product/controllers/detail.js +++ b/apps/product/controllers/detail.js @@ -313,8 +313,8 @@ exports.index = (req, res, next) => { title: result.goodsName, pageFooter: true, localCss: true, - cononical: { - currentHref: result.cononical + canonical: { + currentHref: result.canonical } }); }).catch(next); diff --git a/apps/product/controllers/global.js b/apps/product/controllers/global.js index 91c3a52..e3af62c 100644 --- a/apps/product/controllers/global.js +++ b/apps/product/controllers/global.js @@ -2,6 +2,7 @@ const headerModel = require('../../../doraemon/models/header'); const model = require('../models/global'); +const _ = require('lodash'); const list = (req, res, next) => { let brand = req.query.brand; @@ -84,6 +85,13 @@ const detail = (req, res, next) => { let appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.globalpurchase","params":${JSON.stringify(appParams)}}`; res.render('global/detail', { + title: (_.get(result, 'brand_info.brand_name', '') ? '【' + result.brand_info.brand_name + '】' : '') + + _.get(result, 'product_name', '') + '|YOHO!BUY 有货', + keywords: _.get(result, 'brand_info.brand_name', '') + ',' + _.get(result, 'brand_info.brand_name', '') + + '价格,' + _.get(result, 'brand_info.brand_name', '') + '图片,', + description: _.get(result, 'product_name', '') + ' 有货网仅售' + _.get(result, 'sales_price', '') + '元,购买' + + _.get(result, 'brand_info.brand_name', '') + ',了解' + _.get(result, 'brand_info.brand_name', '') + + '商品信息就上有货网!', module: 'product', page: 'global-detail', pageHeader: headerModel.setNav({ diff --git a/apps/product/controllers/list.js b/apps/product/controllers/list.js index cc725c5..904af40 100644 --- a/apps/product/controllers/list.js +++ b/apps/product/controllers/list.js @@ -10,12 +10,26 @@ const mRoot = '../models'; const headerModel = require('../../../doraemon/models/header'); const listModel = require(`${mRoot}/list`); const _ = require('lodash'); +const md5 = require('yoho-md5'); +const co = Promise.coroutine; const helpers = global.yoho.helpers; const productProcess = require(`${utils}/product-process`); const searchModel = require(`${mRoot}/search`); const shopModel = require(`${mRoot}/shop`); const searchProcess = require(`${utils}/search-process`); const stringProcess = require(`${utils}/string-process`); +const listParamsProcess = require(`${utils}/list-params-process`); +const redis = require(`${utils}/redis`); +const logger = global.yoho.logger; + +/** + * 封面图 + * @type {{boys: string, gilrs: string}} + */ +const _coverChannel = { + boys: '1,3', + gilrs: '2,3' +}; /** * 从 useragent 获取 uid @@ -212,6 +226,7 @@ const category = (req, res, next) => { } let params = Object.assign({}, req.query); + let seoTitle = decodeURIComponent(req.query.title || req.query.sort_name || '商品列表'); /* 勿修改,唤起 APP 使用 */ let appParams = Object.assign({}, req.query, { @@ -248,8 +263,12 @@ const category = (req, res, next) => { _noLazy: true, // 首屏不使用lazyload module: 'product', page: 'search-list', + + // canonical: { + // currentHref: 'https://www.yohobuy.com/list?' // TODO + // }, pageHeader: headerModel.setNav({ - navTitle: req.query.title || req.query.sort_name + navTitle: seoTitle }), goodList: params, firstPageGoods: firstPageGoods || [], @@ -260,7 +279,154 @@ const category = (req, res, next) => { localCss: true, appPath: appPath, introText: req.query.intro_text - }, searchProcess.getListSeoData(req.query.gender, req.query.title || req.query.sort_name))); + }, searchProcess.getListSeoData(req.query.gender, seoTitle))); + }).catch(next); +}; + +/** + * 品类落地页 SEO 友好的新路由 + */ +const listNew = (req, res, next) => { + req.query = listParamsProcess.getParams(req.url); + + if (req.query) { + _.forEach(req.query, (perParam, index) => { + req.query[index] = stringProcess.paramsFilter(perParam); + }); + } + + let params = Object.assign({}, req.query); + + /* 勿修改,唤起 APP 使用 */ + let appParams = Object.assign({}, req.query, { + title: req.query.title || req.query.sort_name || '', + productPool: req.query.filter_poolId, + actiontype: req.query.actiontype || '1' + }); + + delete appParams.filter_poolId; + + let appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.list","params":' + + JSON.stringify(appParams) + + '}'; + + let uid = req.user.uid || 0; + + // 获取第一页数据做服务端渲染 + let initialData = _.assign({ + gender: params.gender, + type: 'default', + order: '0', + page: 1, + limit: 24, + isApp: params.app_version + }, params); + + if (uid) { + initialData.uid = uid; + } + co(function* () { + let result = yield req.ctx(searchModel).getCategoryGoods(initialData); + let categoryIntroRedis = []; + + let responseResult = { + list: productProcess.processProductList(result.data.product_list || [], { + isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'), + gender: _coverChannel[params.coverChannel], + showSimilar: params.shop_id || params.material === 'true' ? false : true + }) + }; + + let seoTitle = _.get(result, 'data.filter.group_sort[0].sub[0].category_name'); + + if (!seoTitle || !initialData.category_id) { + seoTitle = '商品列表'; + } + + if (params.sort_name) { + try { + seoTitle = decodeURIComponent(params.sort_name); + } catch (e) { + logger.error('decodeURIComponent seoTitle: ' + e); + return res.redirect('/'); + } + } + + try { + categoryIntroRedis = + yield redis.hmgetAsync(`category:description:${md5(seoTitle)}`, 'category', 'description').timeout(200); + } catch (e) { + logger.error('redis.hmgetAsync.category.description:' + e); + } + + let categoryIntro = categoryIntroRedis[1] ? { + title: categoryIntroRedis[0], + desc: categoryIntroRedis[1] + } : null; + + res.render('search/goods-list', Object.assign({ + _noLazy: true, // 首屏不使用lazyload + module: 'product', + page: 'search-list-new', + canonical: { + currentHref: `https://www.yohobuy.com${req.url}` + }, + pageHeader: headerModel.setNav({ + navTitle: seoTitle + }), + goodList: params, + firstPageGoods: responseResult || [], + showDownloadApp: true, + pageFooter: true, + category: true, + localCss: true, + appPath: appPath, + categoryIntro: categoryIntro + }, searchProcess.getListSeoData(req.query.gender, seoTitle))); + })().catch(next); +}; + +/** + * 品类落地页异步获取商品数据 + */ +const getCategoryGoods = (req, res, next) => { + let allowOrigin = _.get(req, 'headers.origin', null) ? + req.headers.origin : req.protocol + '://' + req.headers.host; + + res.setHeader('Access-Control-Allow-Origin', allowOrigin); + res.setHeader('Access-Control-Allow-Credentials', 'true'); + + let currentUrlParams = listParamsProcess.getParams(req.query.currentUrl); + + delete req.query.currentUrl; + + let params = _.assign({}, currentUrlParams, req.query); + let uid = req.user.uid || 0; + + if (uid) { + params.uid = uid; + } + + params.isApp = req.yoho.isApp; + params.limit = 24; + + req.ctx(searchModel).getCategoryGoods(params).then((result) => { + if (result.data.product_list && result.data.product_list.length > 0) { + + let product_list = productProcess.processProductList(result.data.product_list || [], { + isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'), + gender: _coverChannel[params.coverChannel], + showSimilar: params.shop_id || params.material === 'true' ? false : true + }); + + res.render('search/page', { + layout: false, + new: product_list, + total: result.data.total, + }); + } else { + res.json({}); + } }).catch(next); }; @@ -543,5 +709,7 @@ module.exports = { shopFav, baseShopFav, shopCategory, - getBrandCouponsList + getBrandCouponsList, + listNew, + getCategoryGoods }; diff --git a/apps/product/controllers/new-detail.js b/apps/product/controllers/new-detail.js index 969307b..89dd93e 100644 --- a/apps/product/controllers/new-detail.js +++ b/apps/product/controllers/new-detail.js @@ -62,13 +62,14 @@ const newDetail = { pageHeader: headerData, result: result, page: 'new-detail', - title: `${result.brandName}|${result.sortName}|${result.goodsName}|YOHO!BUY 有货`, - keywords: result.brandName + result.sortName + ',' + result.brandName + '官网专卖店,' + - result.brandName + '官方授权店,' + result.brandName + '正品,' + result.brandName + '打折,' + - result.brandName + '折扣店,' + - result.brandName + '真品,' + result.brandName + '代购', - description: `YOHO!BUY 有货-${result.brandName}官方授权店,${result.goodsName}图片、报价、介绍。` + - `YOHO!BUY 有货${result.brandName}官网专卖店提供${result.brandName}正品、${result.brandName}真品、 ${result.brandName}打折、${result.brandName}代购等。`, // eslint-disable-line + canonical: { + currentHref: `https://www.yohobuy.com${req.originalUrl}` + }, + title: `【${result.brandName}${result.sortName}】${result.goodsName}|YOHO!BUY 有货`, + keywords: result.brandName + result.sortName + ',' + result.brandName + result.sortName + '价格,' + + result.brandName + result.sortName + '图片,', + description: result.goodsName + ' 有货网仅售' + result.goodsPrice.currentPrice + '元,购买' + + result.brandName + result.sortName + ',了解' + result.brandName + result.sortName + '商品信息就上有货网!', pageFooter: true, localCss: true, appPath: appPath, diff --git a/apps/product/controllers/new-shop.js b/apps/product/controllers/new-shop.js index a974b6c..b750840 100644 --- a/apps/product/controllers/new-shop.js +++ b/apps/product/controllers/new-shop.js @@ -17,6 +17,18 @@ const stringProcess = require(`${utils}/string-process`); const shopPrcs = require(`${utils}/shop-process`); const co = require('bluebird').coroutine; +/** + * SEO 优化,页面 TDK + * @param {*} keyword + */ +const _tdkProcess = (keyword) => { + return { + title: `${keyword}| ${keyword}品牌旗舰店 |正品保证, YOHO!BUY 有货`, + keywords: `${keyword},${keyword}品牌旗舰店,${keyword}正品`, + description: `有货网${keyword}旗舰店销售${keyword}正品商品,100%质量保证,支持货到付款,想了解${keyword}价格、图片、评价等信息,就上YOHO!BUY 有货中国最大的潮流商品购物网站!`, // eslint-disable-line + }; +}; + const shop = { /** @@ -199,7 +211,7 @@ const shop = { let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', [])); - res.render('newshop/shop-brand', { + res.render('newshop/shop-brand', _.assign({ module: 'product', page: 'shop-brand', pageHeader: headerModel.setNav({ @@ -207,15 +219,12 @@ const shop = { }), showDownloadApp: true, pageFooter: true, - title: title + '|' + title + '潮流服装服饰-Yoho!Buy有货', - keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰', - description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。', brandId: brandId, goodsList: goodsList, shopPage: true, _noLazy: true, localCss: true - }); + }, _tdkProcess(title))); })().catch(next); }, @@ -253,10 +262,6 @@ const shop = { shopInfo.shop_intro_link = helpers.urlFormat('/product/index/intro', { shop_id: shopId }); let finalResult = { - title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货', - keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' + shopInfo.shop_name + '潮流服装服饰', - description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name + - '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。', pageHeader: _.assign({ shopPage: { text: '分类', @@ -288,8 +293,8 @@ const shop = { if (domain) { _.assign(finalResult, { - cononical: { - currentHref: `https://${domain}.m.yohobuy.com` + canonical: { + currentHref: `https://www.yohobuy.com${req.originalUrl}` } }); } @@ -299,7 +304,7 @@ const shop = { res.render('newshop/shop-reds', _.assign(finalResult, { shppFavHide: shppFavHide - })); + }, _tdkProcess(shopInfo.shop_name))); })().catch(next); }, @@ -339,7 +344,7 @@ const shop = { let appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.shop","params":{"shop_template_type":"1","shop_id":"' + shopId + '","shop_name":"' + shopInfo.shop_name + '"}}'; - res.render('newshop/shop-list', { + res.render('newshop/shop-list', _.assign({ module: 'product', page: 'shop-list', pageHeader: headerModel.setNav({ @@ -347,9 +352,6 @@ const shop = { }), showDownloadApp: true, pageFooter: true, - title: title + '|' + title + '潮流服装服饰-Yoho!Buy有货', - keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰', - description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。', shopId: shopId, shopInfo: shopInfo, goodsList: goodsList, @@ -358,7 +360,7 @@ const shop = { _noLazy: true, localCss: true, couponData - }); + }, _tdkProcess(title))); })().catch(next); }, @@ -440,7 +442,8 @@ const shop = { let data = {}; cryptCouponId = parseInt(cryptCouponId, 10); - uid = parseInt(uid, 10); + + // uid = parseInt(uid, 10); if (uid) { req.ctx(couponModel).receiveCoupon( diff --git a/apps/product/controllers/new.js b/apps/product/controllers/new.js index d0c86c6..137cfcf 100644 --- a/apps/product/controllers/new.js +++ b/apps/product/controllers/new.js @@ -24,6 +24,15 @@ const channelToAppChannel = (channel) => { }[channel] || '1'; }; +const channelSeo = (channel) => { + return { + boys: '男生', + girls: '女生', + kids: '潮童', + lifestyle: '创意生活' + }[channel] || '男生'; +}; + // 新品到着(blk) const blkNewGoods = (req, res, next) => { let params = Object.assign({ @@ -76,8 +85,9 @@ const newGoods = (req, res, next) => { res.render('new/new', { module: 'product', page: 'new', - - // title: '新品到着', + title: channelSeo(req.yoho.channel) + '新品上架,100%正品保证-YOHO!BUY 有货', + keywords: channelSeo(req.yoho.channel) + '新品,潮流新品,潮流正品', + description: channelSeo(req.yoho.channel) + '新品上架,正品网购,官方授权!100%品牌正品保证,支持货到付款。 想购买潮流商品就来YOHO! 有货中国最大的潮流商品购物网站。', // eslint-disable-line pageHeader: headerModel.setNav({ navTitle: '新品到着' }), @@ -104,7 +114,7 @@ const newGoodsRedirect = (req, res) => { if (param) { param = '?' + param; } - res.redirect(301, `/product/${req.yoho.channel}-new/${param}`); + res.redirect(301, `/${req.yoho.channel}-new/${param}`); }; /** diff --git a/apps/product/controllers/sale.js b/apps/product/controllers/sale.js index fb390fe..8e7c335 100644 --- a/apps/product/controllers/sale.js +++ b/apps/product/controllers/sale.js @@ -145,6 +145,9 @@ let breakingYards = (req, res, next) => { }).then((result) => { res.render('sale/break-code', Object.assign(params.renderData, result, { + title: '断码商品|断码折扣商品|YOHO!BUY有货', + keywords: '断码商品、断码专区、断码折扣', + description: '有货网为您带断码专区精选商品,大量断码商品,价格优惠幅度大,支持货到付款,让您全面了解潮流断码商品价格、品牌、图片、折扣等方面信息,想网购潮流断码区商品就上有货网!', localCss: true })); }).catch(next); @@ -185,6 +188,9 @@ let discountDetail = (req, res, next) => { res.locals.appPath = result.activity && result.activity.cover_url ? `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.discountmarketpro","params":{"id":"${id}","cover_url":"${result.activity.cover_url.split('?')[0]}","title":"${result.title}"}}` : ''; res.render('sale/discount-detail', Object.assign(params.renderData, result, { + title: `【${result.title}】潮流折扣商品|YOHO!BUY 有货`, + keywords: `${result.title}`, + description: `有货网为您提供大量${result.title}商品,支持货到付款,质量保证,让您全面了解${result.title}商品价格、品牌、图片、折扣等方面信息,想网购${result.title}商品就上有货网!`, // eslint-disable-line localCss: true })); }).catch(next); @@ -209,6 +215,9 @@ let vip = (req, res, next) => { saleModel.getVipData(params.channel).then((result) => { res.render('sale/vip', Object.assign(params.renderData, { + title: 'VIP会员专享|会员专享|YOHO!BUY有货', + keywords: '会员专享,VIP专享,专享商品', + description: '有货网为您带VIP会员专享精选商品,大量潮流品牌商品,VIP价格优惠幅度大,支持货到付款,让您全面了解VIP会员专享商品价格、品牌、图片、折扣等方面信息,想网购VIP会员专享商品就上有货网!', // eslint-disable-line content: result, localCss: true })); diff --git a/apps/product/controllers/search.js b/apps/product/controllers/search.js index e6e6e65..bbbcf56 100644 --- a/apps/product/controllers/search.js +++ b/apps/product/controllers/search.js @@ -13,6 +13,7 @@ const _ = require('lodash'); const helpers = global.yoho.helpers; const searchProcess = require(`${utils}/search-process`); const productProcess = require(`${utils}/product-process`); +const listParamsProcess = require(`${utils}/list-params-process`); const co = require('bluebird').coroutine; /** @@ -254,7 +255,17 @@ exports.filter = (req, res, next) => { res.setHeader('Access-Control-Allow-Origin', allowOrigin); res.setHeader('Access-Control-Allow-Credentials', 'true'); - let params = Object.assign({}, req.query); + let params = {}; + let currentUrlParams = {}; // 页面链接伪静态固定参数 + + if (req.query.currentUrl) { + currentUrlParams = listParamsProcess.getParams(req.query.currentUrl); + delete req.query.currentUrl; + delete req.query.page; + } + + _.assign(params, currentUrlParams, req.query); + let uid = req.user.uid || 0; if (uid) { diff --git a/apps/product/models/detail.js b/apps/product/models/detail.js index d4c2641..88c876b 100644 --- a/apps/product/models/detail.js +++ b/apps/product/models/detail.js @@ -292,7 +292,7 @@ module.exports = class extends global.yoho.BaseModel { } /* tar add 161129 SEO 优化使用 */ - finalResult.cononical = result.product_url; + finalResult.canonical = result.product_url; return finalResult; }); diff --git a/apps/product/models/global.js b/apps/product/models/global.js index a02cdde..a0bbd5a 100644 --- a/apps/product/models/global.js +++ b/apps/product/models/global.js @@ -4,6 +4,7 @@ const utils = '../../../utils'; const productProcess = require(`${utils}/product-process`); const globalapi = global.yoho.GlobalAPI; const $ = require('cheerio'); +const _ = require('lodash'); exports.list = (param) => { return globalapi.get('product/api/v2/detail/getlist', param).then((result) => { @@ -46,13 +47,15 @@ exports.detail = (param) => { if (goods.length === 1) { result.bannerTop = { - img: (goods[0].images_list[0] || {}).image_url + img: (goods[0].images_list[0] || {}).image_url, + imgAlt: _.get(result, 'brand_info.brand_name', '') + '|' + _.get(result, 'product_name', '') }; } else { result.bannerTop = { list: goods.map((g) => { return { - img: (g.images_list[0] || {}).image_url + img: (g.images_list[0] || {}).image_url, + imgAlt: _.get(result, 'brand_info', 'brand_name', '') + '|' + _.get(result, 'product_name', '') }; }) }; diff --git a/apps/product/models/search.js b/apps/product/models/search.js index 73bfe63..f6ab514 100644 --- a/apps/product/models/search.js +++ b/apps/product/models/search.js @@ -316,6 +316,20 @@ module.exports = class extends global.yoho.BaseModel { } /** + * 获取品类下的商品列表 + */ + getCategoryGoods(params) { + let requestData = { + method: 'web.search.search' + }; + + _.assign(requestData, searchProcess.getSearchParamsWithoutMethod(params)); + return this.get({ + data: requestData + }); + } + + /** * 模糊搜索,获取商品数据 */ getSearchGoods(params) { @@ -370,6 +384,8 @@ module.exports = class extends global.yoho.BaseModel { filterDataResult = yield self.getBrandGoods(params); } else if (params.isShopList === 'Y') { // 无店铺有店铺 ID 的商品列表 filterDataResult = yield self.getShopGoods(params); + } else if (params.isNewList === 'Y') { // 新的 SEO 友好的品类落地页 + filterDataResult = yield self.getCategoryGoods(params); } else { filterDataResult = yield self._searchGoods(params); } diff --git a/apps/product/router.js b/apps/product/router.js index 48400df..0d08028 100644 --- a/apps/product/router.js +++ b/apps/product/router.js @@ -158,6 +158,8 @@ router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的� // 品类 router.get('/index/index', rewrite.sortParams, list.category); router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接 +router.get(/^\/list/, list.listNew); // 列表新的 URL +router.get('/search/category', list.getCategoryGoods); // 品牌 | 店铺 router.get('/index/shopAppCookie', list.shopAppCookie); diff --git a/apps/product/views/action/detail/new/detail.hbs b/apps/product/views/action/detail/new/detail.hbs index c73d745..0965753 100644 --- a/apps/product/views/action/detail/new/detail.hbs +++ b/apps/product/views/action/detail/new/detail.hbs @@ -31,32 +31,33 @@ {{/ bannerTop}} </div> - <h2 class="goods-name"> + <div class="goods-name"> {{# marketPhrase}} <span class="activity-phrase">{{.}}</span> {{/ marketPhrase}} {{# goodsName}} - <span class="name">{{.}}</span> + <h1 class="name">{{.}}</h1> {{/ goodsName}} - </h2> + </div> {{# goodsSubtitle}} - <h1 class="goods-subtitle"><span>{{.}}</span></h1> + <h2 class="goods-subtitle"><span>{{.}}</span></h2> {{/ goodsSubtitle}} <div class="price-date"> <div class="goods-price"> - <h1 class="current-price">{{goodsPrice.currentPrice}}</h1> - <h1 class="previous-price">{{goodsPrice.previousPrice}}</h1> + <h2 class="current-price">{{goodsPrice.currentPrice}}</h2> + <h2 class="previous-price">{{goodsPrice.previousPrice}}</h2> </div> <button class="limit-sale data-can-get-limit-code data-bind" id='limit-sale'>获取限购码</button> <button class="got-limit-sale data-code-empty data-bind">限购码已被抢光</button> <button class="got-limit-sale data-got-code data-bind">已获取限购码</button> </div> + {{#if periodOfMarket}} <div class="period-of-market"> - <h1>上市期:</h1> - <h1 >{{periodOfMarket}}</h1> + <h2>上市期:</h2> + <h2>{{periodOfMarket}}</h2> </div> {{/if}} @@ -85,7 +86,7 @@ {{!--占位: 购物车部分--}} <div id="placeholder-infodata"> <div class="cart-bar"> - <a href="javascript:;" class="new-foot-ico"> + <a href="javascript:;" class="new-foot-ico" rel="nofollow"> <div class="num-incart iconfont"> <span class="num-tag {{#unless @root.cartCount}}hide{{/unless}}">{{@root.cartCount}}</span>  diff --git a/apps/product/views/action/global/detail.hbs b/apps/product/views/action/global/detail.hbs index 05fc78c..98fbdba 100644 --- a/apps/product/views/action/global/detail.hbs +++ b/apps/product/views/action/global/detail.hbs @@ -20,7 +20,7 @@ {{/ bannerTop}} </div> - <div class="goods-name"><span class="name">{{product_name}}</span></div> + <div class="goods-name"><h1 class="name">{{product_name}}</h1></div> <div class="price-date"> <div> diff --git a/apps/product/views/action/newshop/shop-reds.hbs b/apps/product/views/action/newshop/shop-reds.hbs index f583834..e5a71bf 100644 --- a/apps/product/views/action/newshop/shop-reds.hbs +++ b/apps/product/views/action/newshop/shop-reds.hbs @@ -10,7 +10,7 @@ {{#if shopInfo.shop_logo}} <img class="logo" src="{{image shopInfo.shop_logo 100 100}}"> {{/if}} - <p class="store-name">{{shopInfo.shop_name}}</p> + <h1 class="store-name">{{shopInfo.shop_name}}</h1> <div class="fav-box clearfix"> <div class="favs pull-left">粉丝数: {{favCount}} </div> {{!-- 店铺收藏开关 data-switch --}} diff --git a/apps/product/views/action/search/goods-list.hbs b/apps/product/views/action/search/goods-list.hbs index 90f9a1e..8c2e79f 100644 --- a/apps/product/views/action/search/goods-list.hbs +++ b/apps/product/views/action/search/goods-list.hbs @@ -4,3 +4,8 @@ <input type="text" id="category-point" style="display:none" value="{{category}}"> {{/if}} </div> +{{#categoryIntro}} +<div class="seo-data"> + <h1>{{title}}</h1>{{desc}} +</div> +{{/categoryIntro}} diff --git a/apps/product/views/partial/detail/banner-swiper-arrow.hbs b/apps/product/views/partial/detail/banner-swiper-arrow.hbs index 03ea05f..ff28f13 100644 --- a/apps/product/views/partial/detail/banner-swiper-arrow.hbs +++ b/apps/product/views/partial/detail/banner-swiper-arrow.hbs @@ -6,9 +6,9 @@ <li class="swiper-slide"> <a href="javascript:;"> {{#if @first}} - <img src="{{image2 img w=450 h=600 q=60}}" alt=""> + <img src="{{image2 img w=450 h=600 q=60}}" alt="{{imgAlt}}"> {{else}} - <img class="swiper-lazy" data-src="{{image2 img w=450 h=600 q=60}}" alt=""> + <img class="swiper-lazy" data-src="{{image2 img w=450 h=600 q=60}}" alt="{{imgAlt}}"> {{/if}} </a> </li> @@ -27,10 +27,10 @@ <div class="banner-top-single"> {{#if url}} <a href="{{url}}"> - <img class="img" src="{{image2 img w=450 h=600 q=60}}"> + <img class="img" src="{{image2 img w=450 h=600 q=60}}" alt="{{imgAlt}}"> </a> {{^}} - <img class="img" src="{{image2 img w=450 h=600 q=60}}"> + <img class="img" src="{{image2 img w=450 h=600 q=60}}" alt="{{imgAlt}}"> {{/if}} </div> diff --git a/apps/product/views/partial/detail/feedback-tab.hbs b/apps/product/views/partial/detail/feedback-tab.hbs index 439deaa..218260b 100644 --- a/apps/product/views/partial/detail/feedback-tab.hbs +++ b/apps/product/views/partial/detail/feedback-tab.hbs @@ -25,7 +25,7 @@ </span> {{/ comments}} </div> - <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}"> + <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}" rel="nofollow"> 查看更多 <span class="iconfont"></span> </a> @@ -54,7 +54,7 @@ </div> {{/ consults}} </div> - <a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}"> + <a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}" rel="nofollow"> 查看更多 <span class="iconfont"></span> </a> diff --git a/apps/product/views/partial/reds-shop/item.hbs b/apps/product/views/partial/reds-shop/item.hbs index cdcea4c..58c4192 100644 --- a/apps/product/views/partial/reds-shop/item.hbs +++ b/apps/product/views/partial/reds-shop/item.hbs @@ -1,16 +1,16 @@ <div class="item"> - <a {{#if link}}href="{{link}}"{{/if}}> + <a {{#if link}}href="{{link}}"{{/if}}{{#if isGood}} title="{{alt}}"{{/if}}> {{#if isGood}} {{#ifor triple double single}} {{#within index 3}} - <img class="item-pic" src="{{image2 src w=235 h=314}}"> + <img class="item-pic" src="{{image2 src w=235 h=314}}" alt="{{alt}}"> {{^}} - <img class="item-pic lazy" data-original="{{image2 src w=235 h=314}}"> + <img class="item-pic lazy" data-original="{{image2 src w=235 h=314}}" alt="{{alt}}"> {{/within}} {{/ifor}} {{^}} {{#within index 3}} - <img class="item-pic" src="{{image2 src}}" alt=""> + <img class="item-pic" src="{{image2 src}}" alt="{{@root.title}}"> {{^}} <img class="item-pic lazy" data-original="{{image2 src}}"> {{/within}} diff --git a/apps/product/views/partial/reds-shop/modules.hbs b/apps/product/views/partial/reds-shop/modules.hbs index b2d1a4b..15cca36 100644 --- a/apps/product/views/partial/reds-shop/modules.hbs +++ b/apps/product/views/partial/reds-shop/modules.hbs @@ -17,7 +17,7 @@ <li class="swiper-slide"> <a{{#if link}} href="{{link}}"{{/if}}> {{#within @../index 3}} - <img src="{{image2 src}}" alt=""> + <img src="{{image2 src}}" alt="{{@root.title}}"> {{^}} <img class="lazy" data-original="{{image2 src}}" alt=""> {{/within}} diff --git a/config/common.js b/config/common.js index 71352a2..131c519 100644 --- a/config/common.js +++ b/config/common.js @@ -109,7 +109,7 @@ module.exports = { maxQps: 1200, maxQps10m: 2500, geetestJs: '//static.geetest.com/static/tools/gt.js', - jsSdk: '//cdn.yoho.cn/js-sdk/1.2.6/jssdk.js', + jsSdk: '//cdn.yoho.cn/js-sdk/1.2.8/jssdk.js', redis: { connect: { host: '127.0.0.1', diff --git a/dispatch.js b/dispatch.js index 190fac7..9e5a3a0 100644 --- a/dispatch.js +++ b/dispatch.js @@ -15,8 +15,8 @@ module.exports = app => { // 业务模块 app.use('/product', require('./apps/product')); + app.use('/guang/news', require('./apps/news'));// seo-潮流资讯页 app.use('/guang', require('./apps/guang')); - app.use('/news', require('./apps/news')); app.use('/activity', require('./apps/activity')); app.use('/cart', require('./apps/cart')); diff --git a/doraemon/middleware/sub-domain.js b/doraemon/middleware/sub-domain.js index ea9a57c..395565c 100644 --- a/doraemon/middleware/sub-domain.js +++ b/doraemon/middleware/sub-domain.js @@ -21,11 +21,11 @@ module.exports = () => { } } else if (req.subdomains.length) { switch (req.subdomains[0]) { - case 'guang': // 逛 + case 'guang': case 'cdnsrcguang': // CDN 逛 回源地址 req.url = req.url.replace('/guang', ''); - req.url = `/guang${req.url}`; - break; + req.url = `//m.yohobuy.com/guang${req.url}`; + return res.redirect(301, req.url); case 'list': // list case 'cdnsrclist':// CDN list 回源域名 if (req.path === '/') { diff --git a/doraemon/middleware/url-rewrite.js b/doraemon/middleware/url-rewrite.js index 43ddb54..0910da7 100644 --- a/doraemon/middleware/url-rewrite.js +++ b/doraemon/middleware/url-rewrite.js @@ -1,6 +1,7 @@ /** * URL 重写(主要用于兼容原来PHP的连接) */ + const helpers = global.yoho.helpers; module.exports = () => { @@ -71,6 +72,27 @@ module.exports = () => { req.url = `/product/${req.url}`; } + if (/^\/list/.test(req.url)) { + // 列表页路由重写 跳转到新的列表路由,进行参数的前置处理 + req.url = `/product/${req.url}`; + } + + if (/^\/boys-new/.test(req.url)) { + req.url = '/product/boys-new/'; + } + + if (/^\/girls-new/.test(req.url)) { + req.url = '/product/girls-new/'; + } + + if (/^\/kids-new/.test(req.url)) { + req.url = '/product/kids-new/'; + } + + if (/^\/lifestyle-new/.test(req.url)) { + req.url = '/product/lifestyle-new/'; + } + next(); }; }; diff --git a/doraemon/middleware/user.js b/doraemon/middleware/user.js index 7eb9c4d..f1b5438 100644 --- a/doraemon/middleware/user.js +++ b/doraemon/middleware/user.js @@ -69,6 +69,7 @@ module.exports = () => { let appUid = req.query.uid || req.cookies.app_uid; let appVersion = req.cookies.app_version || req.query.app_version || config.appVersion; let appSessionType = req.query.client_type || req.cookies.app_client_type; + let sessionKey = req.query.session_key || req.cookies.app_session_key; if (req.query.app_version && req.query.client_type) { logger.warn(`app session from querystring, url:${req.originalUrl}`); @@ -79,6 +80,7 @@ module.exports = () => { return _.parseInt(appUid); }, appVersion: appVersion, + sessionKey: sessionKey, appSessionType: appSessionType }; diff --git a/doraemon/models/footer_tab.js b/doraemon/models/footer_tab.js index 2e2d0e6..5a2ccdc 100644 --- a/doraemon/models/footer_tab.js +++ b/doraemon/models/footer_tab.js @@ -12,7 +12,7 @@ exports.getUrlData = function(type, gender) { const urlData = { indexUrl: helpers.urlFormat('/?go=1'), // 首页 categoryUrl: helpers.urlFormat('/cate'), // 分类 - guangUrl: helpers.urlFormat('', gender ? {gender: gender} : null, 'guang'), // 逛首页 + guangUrl: helpers.urlFormat('/guang', gender ? {gender: gender} : null), // 逛首页 shoppingCartUrl: helpers.urlFormat('/cart/index/index'), // 购物车 mineUrl: helpers.urlFormat('/home') // 个人中心 }; diff --git a/doraemon/views/layout.hbs b/doraemon/views/layout.hbs index e73e28c..74f8e7b 100644 --- a/doraemon/views/layout.hbs +++ b/doraemon/views/layout.hbs @@ -11,10 +11,10 @@ <meta content="telephone=no" name="format-detection" /> <meta content="email=no" name="format-detection" /> <meta name="referrer" content="always"> - {{# cononical}} + {{# canonical}} <meta name="applicable-device" content="mobile"> - <link rel="cononical" href="{{currentHref}}"> - {{/ cononical}} + <link rel="canonical" href="{{currentHref}}"> + {{/ canonical}} {{#if miphtml}} <link rel="miphtml" href="{{miphtml}}"> {{/if}} diff --git a/doraemon/views/mip.hbs b/doraemon/views/mip.hbs index 38d923e..f8bf8b0 100644 --- a/doraemon/views/mip.hbs +++ b/doraemon/views/mip.hbs @@ -5,19 +5,34 @@ <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> <title>{{title}} | Yoho!Buy有货 | 潮流购物逛不停</title> <link rel="stylesheet" type="text/css" href="https://mipcache.bdstatic.com/static/v1/mip.css"> - <link rel="canonical" href="{{canonical}}"> + <link rel="canonical" href="https://www.yohobuy.com/guang/{{mipId}}.html"/> <style mip-custom> .main-wrap{width: 100%;max-width: 750px;margin: 0 auto;} {{css}} {{localStyle}} </style> + <script type="application/ld+json"> + { + @context: "https://ziyuan.baidu.com/contexts/cambrian.jsonld", + @id: "https://m.yohobuy.com/mip/guang/info/{{mipId}}.html", + appid: "1583402501013173", + title: "{{title}} | Yoho!Buy有货 | 潮流购物逛不停", + images: [ + "{{mipPic}}" + ], + description: "{{mipDes}}", + pubDate: "{{mipPublishTime}}" + } +</script> </head> <body> <div class="main-wrap">{{{body}}}</div> <mip-stats-baidu token="d22478778b220ee60bce74bd15d390ae" setconfig="%5B'_trackEvent'%2C%20'mip'%2C%20'{{canonical}}'%5D"></mip-stats-baidu> +<mip-cambrian site-id="1583402501013173"></mip-cambrian> <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-audio/mip-audio.js"></script> +<script src="https://mipcache.bdstatic.com/extensions/platform/v1/mip-cambrian/mip-cambrian.js"></script> </body> </html> diff --git a/doraemon/views/partial/analysis.hbs b/doraemon/views/partial/analysis.hbs index fc224d0..2d88aea 100644 --- a/doraemon/views/partial/analysis.hbs +++ b/doraemon/views/partial/analysis.hbs @@ -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.8/yas.js', '_yas')); + }(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.9/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.8', 'yohobuy_m', uid, '', ''); + window._yas(1 * new Date(), '2.4.9', 'yohobuy_m', uid, '', ''); } setTimeout(function() { diff --git a/doraemon/views/partial/common/goods.hbs b/doraemon/views/partial/common/goods.hbs index 7e48da6..729b89e 100644 --- a/doraemon/views/partial/common/goods.hbs +++ b/doraemon/views/partial/common/goods.hbs @@ -34,9 +34,9 @@ <div class="good-detail-img"> <a class="good-thumb" href="{{url}}"> {{#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="{{imgAlt}}"/> {{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="{{imgAlt}}"/> {{/if}} </a> {{# is_soon_sold_out}} diff --git a/doraemon/views/partial/header.hbs b/doraemon/views/partial/header.hbs index 4314a98..e4a31f9 100644 --- a/doraemon/views/partial/header.hbs +++ b/doraemon/views/partial/header.hbs @@ -77,13 +77,13 @@ </a> </li> <li> - <a href="{{ shoppingCartUrl }}"> + <a href="{{ shoppingCartUrl }}" rel="nofollow"> <i class="iconfont"></i> <span>购物车</span> </a> </li> <li> - <a href="{{ mineUrl }}"> + <a href="{{ mineUrl }}" rel="nofollow"> <i class="iconfont"></i> <span>我的</span> </a> diff --git a/doraemon/views/partial/product/recommend-goods.hbs b/doraemon/views/partial/product/recommend-goods.hbs index 9c8ae2c..3fb75e8 100644 --- a/doraemon/views/partial/product/recommend-goods.hbs +++ b/doraemon/views/partial/product/recommend-goods.hbs @@ -53,11 +53,11 @@ {{/ tags}} </div> <div class="good-detail-img"> - <a class="good-thumb" href="{{url}}" title="{{seoTitle}}"> + <a class="good-thumb" href="{{url}}" title="{{imgAlt}}"> {{#if @root._noLazy}} - <img src="{{image2 default_images w=235 h=314 q=60}}" alt="{{seoTitle}}"/> + <img src="{{image2 default_images w=235 h=314 q=60}}" alt="{{imgAlt}}"/> {{else}} - <img class="lazy" data-original="{{image2 default_images w=235 h=314 q=60}}" alt="{{seoTitle}}"/> + <img class="lazy" data-original="{{image2 default_images w=235 h=314 q=60}}" alt="{{imgAlt}}"/> {{/if}} </a> {{# is_soon_sold_out}} @@ -79,7 +79,7 @@ </div> <div class="good-detail-text"> <div class="name"> - <a href="{{url}}" title="{{seoTitle}}">{{product_name}}</a> + <a href="{{url}}" title="{{imgAlt}}">{{product_name}}</a> </div> <div class="price"> {{#if @root.saleViplogin}} diff --git a/doraemon/views/partial/resources/discount-activity.hbs b/doraemon/views/partial/resources/discount-activity.hbs index 84f9d4d..2506258 100644 --- a/doraemon/views/partial/resources/discount-activity.hbs +++ b/doraemon/views/partial/resources/discount-activity.hbs @@ -7,9 +7,9 @@ <li> <a href="/product/sale/discount/detail?id={{id}}&channel={{@root.channel}}"> {{#within @index 3}} - <img src="{{image2 cover_url w=640 h=250 q=60}}"/> + <img src="{{image2 cover_url w=640 h=250 q=60}}" alt="{{title}}"/> {{^}} - <img class="lazy" data-original="{{image2 cover_url w=640 h=250 q=60}}"/> + <img class="lazy" data-original="{{image2 cover_url w=640 h=250 q=60}}" alt="{{title}}"/> {{/within}} <p class="discount-cont"> <span class="discount-title">{{title}}</span> diff --git a/package.json b/package.json index 0c34877..77700d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yohobuywap-node", - "version": "6.2.32", + "version": "6.2.34", "private": true, "description": "A New Yohobuy Project With Express", "repository": { diff --git a/process.json b/process.json index 84a1add..03cafd3 100644 --- a/process.json +++ b/process.json @@ -3,7 +3,7 @@ { "name": "yohobuywap-node", "script": "app.js", - "instances": "8", + "instances": "4", "exec_mode": "cluster", "merge_logs": true, "log_date_format": "YYYY-MM-DD HH:mm:ss Z", diff --git a/public/hbs/channel/brandlist.hbs b/public/hbs/channel/brandlist.hbs index 5ffe60d..8ac3ce3 100644 --- a/public/hbs/channel/brandlist.hbs +++ b/public/hbs/channel/brandlist.hbs @@ -24,7 +24,7 @@ {{# list}} <div class="brand-wall-box"> <a href="{{url}}"> - <img class="lazy" data-original="{{img}}"></img> + <img class="lazy" data-original="{{img}}" alt="{{brandName}}"></img> <div class="brand-name">{{brandName}}</div> </a> </div> @@ -37,7 +37,7 @@ {{# list}} <div class="brand-wall-box"> <a href="{{url}}"> - <img class="lazy" data-original="{{img}}"></img> + <img class="lazy" data-original="{{img}}" alt="{{brandName}}"></img> <div class="brand-name">{{brandName}}</div> </a> </div> diff --git a/public/hbs/product/detail/feedback-tab.hbs b/public/hbs/product/detail/feedback-tab.hbs index 71571d2..b6b88f4 100644 --- a/public/hbs/product/detail/feedback-tab.hbs +++ b/public/hbs/product/detail/feedback-tab.hbs @@ -28,7 +28,7 @@ </span> {{/ comments}} </div> - <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}"> + <a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}" rel="nofollow"> 查看更多 <span class="iconfont"></span> </a> @@ -57,7 +57,7 @@ </div> {{/ consults}} </div> - <a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}"> + <a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}" rel="nofollow"> 查看更多 <span class="iconfont"></span> </a> diff --git a/public/hbs/product/detail/infodata.hbs b/public/hbs/product/detail/infodata.hbs index 75f6334..bdb9444 100644 --- a/public/hbs/product/detail/infodata.hbs +++ b/public/hbs/product/detail/infodata.hbs @@ -3,7 +3,7 @@ {{#unless @root.wap.common.removeCartCount}} <input type="hidden" id="remove-cart-count" value="1"> {{/unless}} - <a class="new-foot-ico" href="{{cartUrl}}"> + <a class="new-foot-ico" href="{{cartUrl}}" rel="nofollow"> <div class="num-incart iconfont"> <span class="num-tag {{#unless @root.cartCount}}hide{{/unless}}">{{@root.cartCount}}</span>  diff --git a/public/hbs/product/detail/promotion.hbs b/public/hbs/product/detail/promotion.hbs index b74c7f2..44597c8 100644 --- a/public/hbs/product/detail/promotion.hbs +++ b/public/hbs/product/detail/promotion.hbs @@ -3,10 +3,10 @@ <div class="goods-discount" id="goodsDiscount"> {{#each promotion}} {{#if @first}} - <h1 class="first-item short-text tap-hightlight"><span class="promotion-icon">促</span>{{promotionTitle}}<span class="icon-down iconfont dropdown"></span></h1> + <h2 class="first-item short-text tap-hightlight"><span class="promotion-icon">促</span>{{promotionTitle}}<span class="icon-down iconfont dropdown"></span></h2> {{else}} <div class="discount-folder"> - <h1 class="folder-item tap-hightlight"><span class="promotion-icon">促</span>{{promotionTitle}}</h1> + <h2 class="folder-item tap-hightlight"><span class="promotion-icon">促</span>{{promotionTitle}}</h2> </div> {{/if}} {{/each}} diff --git a/public/js/activity/feature.page.js b/public/js/activity/feature.page.js index 3b5e1cb..622c1f4 100644 --- a/public/js/activity/feature.page.js +++ b/public/js/activity/feature.page.js @@ -1,8 +1,9 @@ var $ = require('yoho-jquery'); var lazyLoad = require('yoho-jquery-lazyload'); var Swiper = require('yoho-swiper'); -var qs = require('yoho-qs'); var yoho = require('../yoho-app'); +const qs = require('yoho-qs'); +const cookie = require('yoho-cookie'); global.jQuery = $; @@ -220,8 +221,13 @@ function persenalCouponInit() { activity_id: $('.feature-page').data('id') }; - if (qs.uid) { - data.uid = qs.uid; + if (yoho.isApp) { + data.app = { + uid: cookie.get('app_uid') || qs.uid, + app_version: cookie.get('app_version') || qs.app_version, + client_type: cookie.get('app_client_type') || qs.client_type, + session_key: cookie.get('app_session_key') || qs.session_key + }; } $('.yoho-conpon').each(function() { diff --git a/public/js/channel/home.page.js b/public/js/channel/home.page.js index 2b10aa6..de979fc 100644 --- a/public/js/channel/home.page.js +++ b/public/js/channel/home.page.js @@ -379,7 +379,7 @@ let getResourceContent = function() { setTimeout(function() { getResourceContent(); -}, 50); +}, 5); // logo动画 function tsAnimate() { diff --git a/public/js/channel/maybe-like.js b/public/js/channel/maybe-like.js index 06bac18..6c334ff 100644 --- a/public/js/channel/maybe-like.js +++ b/public/js/channel/maybe-like.js @@ -203,12 +203,12 @@ module.exports = function(likeParameter) { loading.hideLoadingMask(); page++; - $('.good-detail-text .name').each(function() { - let $this = $(this), - $title = $this.find('a'); + // $('.good-detail-text .name').each(function() { + // let $this = $(this), + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); + // $title[0].mlellipsis(2); + // }); // 为您优选埋点 start $(data).closest('.good-info').each(function() { @@ -242,10 +242,9 @@ module.exports = function(likeParameter) { } } - // 优惠券页面直接加载你可能喜欢。add by @zhaobiao - if (specificGender || likeParameter && likeParameter.isExecute) { + setTimeout(() => { search(); - } + }, 50); // srcoll to load more $(window).scroll(function() { diff --git a/public/js/common.js b/public/js/common.js index 50edc3d..1846ccd 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -206,9 +206,9 @@ $.extend({ // 未登录 $op.prepend( - '<a href="/signin.html?refer=' + location.href + '">登录</a>' + + '<a href="/signin.html?refer=' + location.href + '" rel="nofollow">登录</a>' + '<span class="sep-line">|</span>' + - '<a href="/reg.html">注册</a>' + '<a href="/reg.html" rel="nofollow">注册</a>' ); } else { diff --git a/public/js/guang/detail/guang-comments.js b/public/js/guang/detail/guang-comments.js index 73a1d42..ef6cff0 100644 --- a/public/js/guang/detail/guang-comments.js +++ b/public/js/guang/detail/guang-comments.js @@ -29,7 +29,7 @@ const getComments = () => { $.ajax({ type: 'get', - url: '//guang.m.yohobuy.com/guang/info/getComments', + url: '//m.yohobuy.com/guang/info/getComments', data: { article_id: article_id, page: page++ diff --git a/public/js/guang/index.page.js b/public/js/guang/index.page.js index d08ff3a..f8bbfde 100644 --- a/public/js/guang/index.page.js +++ b/public/js/guang/index.page.js @@ -63,6 +63,10 @@ $nav.bind('contextmenu', function() { }); $nav.on('touchend touchcancel', function(e) { + if ($(e.target).closest('.news-jump').length > 0) { + return true; + } + let $this = $(e.target).closest('.guang-nav-item'), $content, index; diff --git a/public/js/guang/info-index.page.js b/public/js/guang/info-index.page.js index ea89d92..84c569a 100644 --- a/public/js/guang/info-index.page.js +++ b/public/js/guang/info-index.page.js @@ -257,7 +257,6 @@ $('.wei-share').on('touchend', function(e) { // 接口暴露在HTML中,使用压缩名 (function() { let isweixin = navigator.userAgent.indexOf('MicroMessenger') ? true : false; - let $this, $title; // pagecache 前端判断是否显示头 let param = location.search; @@ -272,14 +271,14 @@ $('.wei-share').on('touchend', function(e) { ellipsis.init(); - if ($('.good-detail-text .name').length > 0) { - $('.good-detail-text .name').each(function() { - $this = $(this); - $title = $this.find('a'); + // if ($('.good-detail-text .name').length > 0) { + // $('.good-detail-text .name').each(function() { + // $this = $(this); + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); - } + // $title[0].mlellipsis(2); + // }); + // } lazyLoad($('.lazy')); // offset.left约等于marginLeft的值则表示介绍被换行,则清除intro的paddingTop让其更靠近头像和作者名 diff --git a/public/js/guang/plustar-detail.page.js b/public/js/guang/plustar-detail.page.js index f5c4ede..1f08f0c 100644 --- a/public/js/guang/plustar-detail.page.js +++ b/public/js/guang/plustar-detail.page.js @@ -26,7 +26,7 @@ let jumpToApp = $('#jump-to-app').val(); let mIntro, aIntro, logoImg; -let likeHammer, $goodName, $title; +let likeHammer; require('plugin/wx-share'); require('common'); @@ -41,14 +41,14 @@ lazyLoad($('img.lazy')); $('.logo').attr('src', logoImg); -if ($('.good-detail-text .name').length > 0) { - $('.good-detail-text .name').each(function() { - $goodName = $(this); - $title = $goodName.find('a'); +// if ($('.good-detail-text .name').length > 0) { +// $('.good-detail-text .name').each(function() { +// $goodName = $(this); +// $title = $goodName.find('a'); - $title[0].mlellipsis(2); - }); -} +// $title[0].mlellipsis(2); +// }); +// } // 获取截取文字和完整文字 setTimeout(function() { diff --git a/public/js/home/installment-goods.js b/public/js/home/installment-goods.js index 329193e..ef8b4e5 100644 --- a/public/js/home/installment-goods.js +++ b/public/js/home/installment-goods.js @@ -64,8 +64,6 @@ ListData.prototype.getListData = function(page) { }, dataType: 'html', success: function(data) { - let $this, $title; - self.opt.stopLoading = false; if (data === '') { @@ -98,13 +96,13 @@ ListData.prototype.getListData = function(page) { } } - if ($('.good-detail-text').length > 0) { - $('.good-detail-text .name').each(function() { - $this = $(this); - $title = $this.find('a'); - $title[0].mlellipsis(2); - }); - } + // if ($('.good-detail-text').length > 0) { + // $('.good-detail-text .name').each(function() { + // $this = $(this); + // $title = $this.find('a'); + // $title[0].mlellipsis(2); + // }); + // } loading.hideLoadingMask(); }, diff --git a/public/js/home/installment.page.js b/public/js/home/installment.page.js index 1340b09..9fb4035 100644 --- a/public/js/home/installment.page.js +++ b/public/js/home/installment.page.js @@ -113,14 +113,14 @@ let installment = { }); }, setDetailText: function() { // 标题限制行数 - let $this, $title; + // let $this, $title; - $('.good-detail-text .name').each(function() { - $this = $(this); - $title = $this.find('a'); + // $('.good-detail-text .name').each(function() { + // $this = $(this); + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); + // $title[0].mlellipsis(2); + // }); }, tabChangeAction: function(dom) { let self = this, diff --git a/public/js/news/news-index/view.js b/public/js/news/news-index/view.js index e2d0110..2cd383b 100644 --- a/public/js/news/news-index/view.js +++ b/public/js/news/news-index/view.js @@ -62,7 +62,7 @@ export class IndexView extends View { this.indexModel.loadMoreAjax({ type: 'GET', - url: '/news/index/page', + url: '/guang/news/index/page', dataType: 'html', data: that.navState[index] }).then(rdata => { diff --git a/public/js/product/break-code.page.js b/public/js/product/break-code.page.js index ba175ec..ac2f7c7 100644 --- a/public/js/product/break-code.page.js +++ b/public/js/product/break-code.page.js @@ -276,12 +276,12 @@ function search(opt) { lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy')); } - $('.good-detail-text .name').each(function() { - let $this = $(this), - $title = $this.find('a'); + // $('.good-detail-text .name').each(function() { + // let $this = $(this), + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); + // $title[0].mlellipsis(2); + // }); } nav.reload = false; diff --git a/public/js/product/list/product-list-with-filter.js b/public/js/product/list/product-list-with-filter.js index 36290f9..4c78c25 100644 --- a/public/js/product/list/product-list-with-filter.js +++ b/public/js/product/list/product-list-with-filter.js @@ -69,26 +69,28 @@ class ProductListWithFilter { }); this.view.listNav.on('touchend touchcancel', this.listNavTouch.bind(this)); + let self = this; + /** * 滚动加载 */ - $(window).scroll(() => { - if (this.scrollActived) { - setTimeout(() => { - let afterScroll = document.body.scrollTop; + window.onscroll = function() { + if (self.scrollActived && !self.nav.end) { + setTimeout(function() { + let afterScroll = window.scrollY; - if (afterScroll - this.beforeScroll > 0) { + if (afterScroll - self.beforeScroll > 0) { window.requestAnimationFrame(() => { - this.scrollHandler(); + self.scrollHandler(); }); - this.beforeScroll = afterScroll; + self.beforeScroll = afterScroll; } else { - this.beforeScroll = afterScroll; + self.beforeScroll = afterScroll; return false; } }, 5); } - }); + }; } /** @@ -108,7 +110,9 @@ class ProductListWithFilter { // 去掉正在加载 $('.search-divide').remove(); - let noResult = !result || result.length < 1 || (result.list && result.list.length < 1); + let noResult = !result || !result.length || + result.length < 1 || + (result.list && result.list.length < 1); // 没有结果输出没有结果页面 if (noResult) { diff --git a/public/js/product/new/newarrival.js b/public/js/product/new/newarrival.js index 02038b1..db80eec 100644 --- a/public/js/product/new/newarrival.js +++ b/public/js/product/new/newarrival.js @@ -314,13 +314,6 @@ function search(opt) { loading.hideLoadingMask(); window.rePosFooter(); - - $('.good-detail-text .name').each(function() { - let $this = $(this), - $title = $this.find('a'); - - $title[0].mlellipsis(2); - }); }, error: function() { tip.show('网络断开连接了~'); diff --git a/public/js/product/sale.page.js b/public/js/product/sale.page.js index 3b4663e..cdb346f 100644 --- a/public/js/product/sale.page.js +++ b/public/js/product/sale.page.js @@ -60,12 +60,12 @@ $(function() { $vipFloor.html(res).addClass('goods-container'); lazyload($vipFloor.find('img.lazy')); - $('.good-detail-text .name').each(function() { - let $this = $(this), - $title = $this.find('a'); + // $('.good-detail-text .name').each(function() { + // let $this = $(this), + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); + // $title[0].mlellipsis(2); + // }); $vipFloor.css('padding-bottom', '0.75rem'); } diff --git a/public/js/product/sale/search.js b/public/js/product/sale/search.js index ab730a9..49d94db 100644 --- a/public/js/product/sale/search.js +++ b/public/js/product/sale/search.js @@ -334,12 +334,12 @@ function search(opt, params, isScroll) { window.rePosFooter(); - $('.good-detail-text .name').each(function() { - let $this = $(this), - $title = $this.find('a'); + // $('.good-detail-text .name').each(function() { + // let $this = $(this), + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); + // $title[0].mlellipsis(2); + // }); }, error: function() { tip.show('网络断开连接了~'); diff --git a/public/js/product/search-list-new.page.js b/public/js/product/search-list-new.page.js new file mode 100644 index 0000000..898f411 --- /dev/null +++ b/public/js/product/search-list-new.page.js @@ -0,0 +1,17 @@ +/** + * 搜索商品列表页 + * @author: wsl<shuiling.wang@yoho.cn> + * @date: 2016/7/21 + */ + +const ProductListWithFilter = require('./list/product-list-with-filter'); + +require('product/search/list.page.css'); +require('common/footer'); +require('./shop/coupon'); + +new ProductListWithFilter({ + page: 2, + currentUrl: location.pathname, + isNewList: 'Y' +}, 'product/search/category'); diff --git a/public/js/product/search/list.js b/public/js/product/search/list.js index 8a01085..b96cd4c 100644 --- a/public/js/product/search/list.js +++ b/public/js/product/search/list.js @@ -40,7 +40,7 @@ let $input = $('#search-input').find('input[name="query"]'), let shopId, sort, brand, outlets, app_type, age_level, msort, misort, coin, app_version, students, couponId, searchFrom; let size, color, style, standard, gender, price, p_d, oldquery, query, limited, specialoffer, specialsale_id, promotion; -let couponCode; +let couponCode, categoryId; // 默认筛选条件 let defaultOpt = require('common/query-param'); @@ -243,6 +243,7 @@ students = getQueryString('students'); couponId = getQueryString('coupon_id'); couponCode = getQueryString('coupon_code'); searchFrom = getQueryString('from'); +categoryId = getQueryString('categoryId'); if ($defaultgc.children().length > 0) { let fsgcgoods = [], @@ -301,8 +302,6 @@ function search(opt) { nav, navType, page, - $this, - $title, params; if (searching) { @@ -522,6 +521,10 @@ function search(opt) { params.from = searchFrom; } + if (categoryId) { + params.categoryId = categoryId; + } + $.extend(setting, defaultOpt, params); searching = true; loading.showLoadingMask(); @@ -691,12 +694,12 @@ function search(opt) { firstScreen = false; - $('.good-detail-text .name').each(function() { - $this = $(this); - $title = $this.find('a'); + // $('.good-detail-text .name').each(function() { + // $this = $(this); + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); + // $title[0].mlellipsis(2); + // }); // 用于统计点击了商品列表的第几个商品,序号从1开始计算。 if (window._yas) { diff --git a/public/js/product/shop/shop-base.js b/public/js/product/shop/shop-base.js index bac4ce6..a020419 100644 --- a/public/js/product/shop/shop-base.js +++ b/public/js/product/shop/shop-base.js @@ -222,8 +222,6 @@ function search(opt) { nav, navType, page, - $this, - $title, params; if (searching) { @@ -535,12 +533,12 @@ function search(opt) { window.rePosFooter(); - $('.good-detail-text .name').each(function() { - $this = $(this); - $title = $this.find('a'); + // $('.good-detail-text .name').each(function() { + // $this = $(this); + // $title = $this.find('a'); - $title[0].mlellipsis(2); - }); + // $title[0].mlellipsis(2); + // }); // 用于统计点击了商品列表的第几个商品,序号从1开始计算。 if (window._yas) { diff --git a/public/scss/guang/_detail.css b/public/scss/guang/_detail.css index c29d48e..8928103 100644 --- a/public/scss/guang/_detail.css +++ b/public/scss/guang/_detail.css @@ -873,6 +873,11 @@ $focus-size: 42px; overflow: visible; } } + + .a-anchor { + color: #93b4c5; + text-decoration: underline; + } } .guang-detail-page.menu-open { diff --git a/public/scss/guang/_info-list.css b/public/scss/guang/_info-list.css index ec7bd92..7db8342 100644 --- a/public/scss/guang/_info-list.css +++ b/public/scss/guang/_info-list.css @@ -75,6 +75,10 @@ &.focus { color: #000; } + + &.news-jump a { + color: inherit; + } } .bytouch { diff --git a/public/scss/layout/_header.css b/public/scss/layout/_header.css index efa5306..db540d4 100644 --- a/public/scss/layout/_header.css +++ b/public/scss/layout/_header.css @@ -43,6 +43,7 @@ width: 120px; height: 105px; line-height: 105px; + font-size: 32px; } .nav-title { diff --git a/public/scss/news/_detail.css b/public/scss/news/_detail.css index 21dde42..11f47ba 100644 --- a/public/scss/news/_detail.css +++ b/public/scss/news/_detail.css @@ -87,6 +87,9 @@ $focus-size: 42px; img { height: auto; + width: auto; + max-width: 100%; + color: #fff; } } @@ -877,6 +880,11 @@ $focus-size: 42px; overflow: visible; } } + + .a-anchor { + color: #93b4c5; + text-decoration: underline; + } } .news-detail-page.menu-open { diff --git a/public/scss/product/detail/_detail.css b/public/scss/product/detail/_detail.css index afa65ee..4b55938 100644 --- a/public/scss/product/detail/_detail.css +++ b/public/scss/product/detail/_detail.css @@ -560,7 +560,7 @@ $basicBtnC: #eb0313; float: left; font-size: 34.59px; - h1 { + h2 { display: inline-block; line-height: 88px; } @@ -603,7 +603,7 @@ $basicBtnC: #eb0313; font-size: 24px; border-bottom: 1px solid #e0e0e0; - h1 { + h2 { display: inline-block; line-height: 88px; } @@ -729,7 +729,7 @@ $basicBtnC: #eb0313; color: $mainFontC; font-size: 28px; - h1 { + h2 { position: relative; padding: 30px 60px 30px 30px; line-height: 36px; diff --git a/public/scss/product/search/_list.css b/public/scss/product/search/_list.css index e9cb929..8de604a 100644 --- a/public/scss/product/search/_list.css +++ b/public/scss/product/search/_list.css @@ -600,3 +600,12 @@ margin-bottom: 100px; } } + +.seo-data { + > h1 { + display: inline; + } + + color: #b0b0b0; + padding: 30px; +} diff --git a/utils/detail-process.js b/utils/detail-process.js index 4de4c77..50a56d6 100644 --- a/utils/detail-process.js +++ b/utils/detail-process.js @@ -111,7 +111,11 @@ class DetailProcess { value.img = _.replace(value.img, '/quality/80', '/quality/70'); bannerList.push({ - img: value.img + img: value.img, + imgAlt: _.compact([_.get(origin, 'brand_info.brand_name_en'), + _.get(origin, 'brand_info.brand_name_cn'), + (_.get(origin, 'gender', '1') === '1' ? '男' : '女'), origin.small_sort_name, + origin.product_name]).join('|') }); }); diff --git a/utils/guang-process.js b/utils/guang-process.js index 01dd79d..50328b1 100644 --- a/utils/guang-process.js +++ b/utils/guang-process.js @@ -79,11 +79,11 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, top) => { if (!articleData.id) { return false; } + let result = { id: articleData.id, showTags: showTag, img: articleData.src ? helpers.image(articleData.src, 640, 640) : '', - url: isApp ? `${helpers.https(articleData.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.id}"},"shareparam":{"id":"${articleData.id}"},"share":"/guang/api/v1/share/guang","id":${articleData.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : articleData.url, //eslint-disable-line title: articleData.title, text: articleData.intro, publishTime: articleData.publish_time, @@ -91,6 +91,20 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, top) => { pageView: articleData.views_num }; + if (isApp) { + if (articleData.url.indexOf('guang.m.yohobuy.com') < 0) { + result.url = `${helpers.https(articleData.url)}?openby:yohobuy={"url":"${articleData.url}","islogin":"N"}}`; + } else { + result.url = `//m.yohobuy.com/guang/${articleData.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.id}"},"shareparam":{"id":"${articleData.id}"},"share":"/guang/api/v1/share/guang","id":${articleData.id},"type":1,"url":"http://m.yohobuy.com/guang/${articleData.id}.html","islogin":"N"}}`; + } + } else { + if (articleData.url.indexOf('guang.m.yohobuy.com') < 0) { + result.url = articleData.url; + } else { + result.url = `//m.yohobuy.com/guang/${articleData.id}.html`; + } + } + if (result.url.includes('feature.yoho.cn') || result.url.includes('cdn.yoho.cn')) { result.url = transHttpsUrl(result.url); @@ -246,7 +260,7 @@ const processArticleDetail = (articleContent, isApp, gender, isWeixin, isqq, isW newText = value.text.data.text; } finalDetail.push({ - text: newText + text: newText.replace(/www.yohobuy.com\/chanpin\//ig, 'm.yohobuy.com/chanpin/') }); } diff --git a/utils/list-params-process.js b/utils/list-params-process.js new file mode 100644 index 0000000..5e64815 --- /dev/null +++ b/utils/list-params-process.js @@ -0,0 +1,68 @@ +const _ = require('lodash'); + +/** + * 参数列表 + */ +const PARAMMAP = { + ag: 'age_level', + gd: 'gender', + sn: 'sort_name', + pa: 'phrase', + ci: 'category_id', + so: 'sort', + ms: 'msort', + mi: 'misort', + tp: 'type', + sz: 'size', + cl: 'color', + pc: 'price', + bd: 'brand', + qr: 'query', + lt: 'limit', + ld: 'limited', + od: 'order', + nw: 'new', + pg: 'page', + st: 'style', + sd: 'standard', + si: 'specialsale_id', + sf: 'specialoffer' +}; + +/** + * 获取标准参数 + */ +const getParams = (url) => { + let params = []; + let paramStringRaw = _.split(url, '/list/')[1]; + + if (paramStringRaw) { + let paramsRaw = _.split(paramStringRaw, '-'); + + _.forEach(paramsRaw, paramRaw => { + let keyRaw = paramRaw.substr(0, 2); + let valueRaw = _.chain(paramRaw) + .replace(keyRaw, '') + .replace('__', '-') + .value(); + + if (PARAMMAP[keyRaw]) { + params[PARAMMAP[keyRaw]] = valueRaw; + } + }); + } + + return params; +}; + +/** + * 生成链接 + */ +const generateUrl = () => { + return ''; +}; + +module.exports = { + getParams, + generateUrl +}; diff --git a/utils/product-process.js b/utils/product-process.js index f7f78b2..bef858c 100644 --- a/utils/product-process.js +++ b/utils/product-process.js @@ -233,9 +233,7 @@ 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 + product.imgAlt = _.compact([product.brand_name, (product.gender ? GENDER[product.gender] : false), product.small_sort_name, product.product_name]).join('|'); // eslint-disable-line pruductList.push(product); }); diff --git a/utils/search-process.js b/utils/search-process.js index 4f15444..af2b7d5 100644 --- a/utils/search-process.js +++ b/utils/search-process.js @@ -4,12 +4,6 @@ * @date: 2016/7/29 */ -const _getGender = { - '1,3': '男生', - '2,3': '女生', - '1,2,3': '', -}; - /** * 根据频道判断出性别 */ @@ -86,9 +80,9 @@ const getListSeoData = (gender, sort_name) => { if (gender && sort_name) { seoData = { - title: `${sort_name}|新款${sort_name}${_getGender[gender]}|品牌正品|YOHO!BUY有货`, - keywords: `新款${sort_name},${_getGender[gender]}${sort_name},品牌正品`, - description: `正品网购!YOHO!BUY有货提供新款${sort_name}${_getGender[gender]}${sort_name}100%品牌正品保证,支持货到付款。` + title: `${sort_name}|新款${sort_name},${sort_name}品牌正品|YOHO!BUY有货`, + keywords: `${sort_name},新款${sort_name},${sort_name}品牌正品`, + description: `有货网${sort_name}专卖店销售正品新款${sort_name},支持货到付款。了解新款${sort_name}、${sort_name}品牌价格、评价、图片等信息,网购超低折扣新款${sort_name}就上有货网。` // eslint-disable-line }; } return seoData; @@ -108,11 +102,15 @@ const getSearchParamsWithoutMethod = (params) => { finalParams.yh_channel = params.yh_channel; } - if (params.brand_id) { + if (params.brand && params.brand !== '0') { + finalParams.brand = params.brand; + } + + if (params.brand_id && params.brand_id !== '0') { finalParams.brand = params.brand_id; } - if (params.shop_id) { + if (params.shop_id && params.shop_id !== '0') { finalParams.shop_id = params.shop_id; } @@ -159,6 +157,11 @@ const getSearchParamsWithoutMethod = (params) => { if (params.type) { finalParams.type = params.type; } + + if (params.category_id && params.category_id !== '0') { + finalParams.category_id = params.category_id; + } + return finalParams; }; diff --git a/utils/shop-process.js b/utils/shop-process.js index 686ffa8..f391581 100644 --- a/utils/shop-process.js +++ b/utils/shop-process.js @@ -2,7 +2,6 @@ * @Author: Targaryen * @Date: 2017-03-23 11:02:31 * @Last Modified by: Targaryen - * @Last Modified time: 2017-08-11 11:40:02 */ /* 红人店铺数据处理 */ @@ -11,6 +10,11 @@ const _ = require('lodash'); const helpers = global.yoho.helpers; const productPrcs = require('./product-process'); +const GENDER = { + 1: '男', + 2: '女', + 3: '男|女' +}; let countCarouselImage = 0; // 轮播图模块统计 @@ -343,10 +347,15 @@ const pushGoodsInfo = (decorators, goodsList) => { if (salesPrice === 0) { decorators[key].noShowProductInfo = true; } + decorators[key].pics[subKey].name = _.get(goodsObj, `${subValue.skn}.product_name`, ''); decorators[key].pics[subKey].salesPrice = salesPrice ? '¥' + salesPrice : ''; decorators[key].pics[subKey].marketPrice = marketPrice ? '¥' + marketPrice : ''; decorators[key].pics[subKey].isGood = true; + decorators[key].pics[subKey].alt = _.get(goodsObj, `${subValue.skn}.brand_name`, '') + + '|' + GENDER[_.get(goodsObj, `${subValue.skn}.gender`, '3')] + + '|' + _.get(goodsObj, `${subValue.skn}.small_sort_name`, '') + + '|' + _.get(goodsObj, `${subValue.skn}.product_name`, ''); if (value.module_type === 'TripleImage' || value.module_type === 'DoubleImage' ||