Authored by yyq

hot

  1 +/*
  2 + * @Author: yyq
  3 + * @Date: 2018-05-07
  4 + */
  5 +
  6 +'use strict';
  7 +
  8 +const seoModel = require('../models/seo-service'); // seo 页 model
  9 +
  10 +const hot = (req, res, next) => {
  11 + return req.ctx(seoModel).getHotKeywordDate(req.query, req.yoho.channel).then(result => {
  12 + res.render('seo/hot', result);
  13 + }).catch(next);;
  14 +};
  15 +
  16 +module.exports = {
  17 + hot
  18 +};
  1 +
  2 +
  3 +const _ = require('lodash');
  4 +const headerModel = require('../../../doraemon/models/header');
  5 +
  6 +const SearchApi = require('./search-api');
  7 +
  8 +const searchHandler = require('./search-handler');
  9 +const utils = '../../../utils';
  10 +const productProcess = require(`${utils}/product-process-simple`);
  11 +
  12 +const _setHotKeywordData = (result, params, channel) => {
  13 + let changeQuery = Object.assign({}, params);
  14 + let finalResult = {
  15 + headerData: Object.assign(result[0].headerData, {
  16 + header: true
  17 + })
  18 + };
  19 +
  20 + _.unset(changeQuery, 'query');
  21 +
  22 + // 获取商品数据和顶部筛选条件
  23 + if (result[1].code === 200) {
  24 + let data = result[1].data;
  25 +
  26 + Object.assign(finalResult,
  27 + searchHandler.handlePathNavData({total: data.total}, params, 'search', channel),
  28 + {
  29 + product: {
  30 + opts: searchHandler.handleOptsData(changeQuery, data.total),
  31 + totalCount: data.total,
  32 + footPager: searchHandler.handlePagerData(data.total, changeQuery),
  33 + goods: productProcess.processProductList(data.product_list,
  34 + Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
  35 + latestWalk: 6,
  36 + hasNextPage: searchHandler.handleNextPage(changeQuery, data.total)
  37 + }
  38 + }
  39 + );
  40 +
  41 + finalResult.hotBrands = _.get(data, 'filter.brand', []);
  42 +
  43 + finalResult.hotBrands.forEach((val) => {
  44 + val.href = '#'; // TODO
  45 + return val;
  46 + });
  47 +
  48 + console.log(_.get(data, 'filter.brand', []));
  49 +
  50 + // finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
  51 + }
  52 +
  53 + // console.log(finalResult);
  54 +
  55 + return finalResult;
  56 +};
  57 +
  58 +module.exports = class extends global.yoho.BaseModel {
  59 + constructor(ctx) {
  60 + super(ctx);
  61 +
  62 + this.searchApi = new SearchApi(ctx);
  63 + }
  64 +
  65 + getHotKeywordDate(params, channel) {
  66 + let searchParams = searchHandler.getSearchParams(params);
  67 +
  68 + switch (channel) {
  69 + case 'boys':
  70 + searchParams.physical_channel = 1;
  71 + break;
  72 + case 'girls':
  73 + searchParams.physical_channel = 2;
  74 + break;
  75 + case 'kids':
  76 + searchParams.physical_channel = 3;
  77 + break;
  78 + case 'lifestyle':
  79 + searchParams.physical_channel = 4;
  80 + break;
  81 + default:
  82 + break;
  83 + }
  84 +
  85 + searchParams.need_filter = 'yes';
  86 + searchParams.query = '夹克';
  87 + return Promise.all([
  88 + headerModel.requestHeaderData(channel),
  89 + this.searchApi.getSeoProductList(searchParams, 'fuzzySearch')
  90 + ]).then(result => {
  91 + return _setHotKeywordData(result, params, channel);
  92 + });
  93 + }
  94 +};
@@ -53,6 +53,9 @@ const globalCtrl = require(`${cRoot}/global`); @@ -53,6 +53,9 @@ const globalCtrl = require(`${cRoot}/global`);
53 // 店铺controller 53 // 店铺controller
54 const shop = require(`${cRoot}/shop`); 54 const shop = require(`${cRoot}/shop`);
55 55
  56 +// seo controller
  57 +const seo = require(`${cRoot}/seo`);
  58 +
56 // 商品促销routers 59 // 商品促销routers
57 router.get('/sale', sale.index); // sale 首页 60 router.get('/sale', sale.index); // sale 首页
58 router.get('/sale/vip', sale.vip); // VIP 活动专区 61 router.get('/sale/vip', sale.vip); // VIP 活动专区
@@ -118,6 +121,7 @@ router.get('/search/history', search.searchHistory); // 搜索历史提示 @@ -118,6 +121,7 @@ router.get('/search/history', search.searchHistory); // 搜索历史提示
118 router.get('/search/less/recommend', search.searchLessRecommend);// 搜索少或无 有可能喜欢 121 router.get('/search/less/recommend', search.searchLessRecommend);// 搜索少或无 有可能喜欢
119 router.get('/search/keyword/:id', search.keyword); 122 router.get('/search/keyword/:id', search.keyword);
120 router.get('/search/chanpin/:id', search.keyId); 123 router.get('/search/chanpin/:id', search.keyId);
  124 +router.get('/search/hot/:id.html', '/hot/:id.html', seo.hot);
121 125
122 // 新品到着 126 // 新品到着
123 router.get('/list/new', list.newWithChannel); 127 router.get('/list/new', list.newWithChannel);
  1 +<div class="yoho-page seo-hot-page">
  2 + {{> common/path-nav}}
  3 +
  4 + <div class="clearfix">
  5 + <div class="left-content">
  6 + <div class="hot-sort">
  7 + <div class="sort-intro">
  8 + <div class="inline">
  9 + <p class="name">
  10 + <span class="cn">夹克</span>
  11 + <span class="en">JACKETS & COATS</span>
  12 + </p>
  13 + <p class="desc">夹克(英语:Jacket),是一种长度至腰部或臀部的上半身衣着。夹克自诞生以来,款式演变千姿百态,形成了庞大的家族。 随着日新月异的世界发展, 夹克以各种各样的姿态永恒不衰,成为经典服饰之一。</p>
  14 + <ul class="key">
  15 + <li><a href="#">牛仔夹克户</a></li>
  16 + <li><a href="#">牛仔夹克户</a></li>
  17 + <li><a href="#">牛仔夹克户</a></li>
  18 + <li><a href="#">牛仔夹克户</a></li>
  19 + <li><a href="#">牛仔夹克户</a></li>
  20 + <li><a href="#">牛仔夹克户</a></li>
  21 + </ul>
  22 + </div>
  23 + </div>
  24 + <img class="thumb" src="//img12.static.yhbimg.com/adpic/2017/05/03/18/0228ed1fb3baf7c9198bfd65024812908a.jpg?imageView2/2/interlace/1/q/75">
  25 + </div>
  26 +
  27 + {{# product}}
  28 + {{> product/standard-content}}
  29 + {{/ product}}
  30 + </div>
  31 +
  32 + <div class="right-content">
  33 + <div class="hot-block">
  34 + <p class="title">热门关键词</p>
  35 + <p class="hot-key">
  36 + <a href="#">鞋履</a>
  37 + <a href="#">鞋履</a>
  38 + <a href="#">鞋履</a>
  39 + <a href="#">鞋履</a>
  40 + <a href="#">鞋履</a>
  41 + <a href="#">鞋履</a>
  42 + <a href="#">鞋履</a>
  43 + <a href="#">鞋履</a>
  44 + </p>
  45 + </div>
  46 + <div class="hot-block">
  47 + <p class="title">热门品牌</p>
  48 +
  49 + {{# hotBrands}}
  50 + <a href="#" class="brand-item" target="_blank" title="{{brand_name_cn}}">
  51 + <img src="{{image2 brand_ico w=138 h=70}}" alt="{{brand_name_cn}} {{brand_keyword}}">
  52 + </a>
  53 + {{/ hotBrands}}
  54 + </div>
  55 + </div>
  56 + </div>
  57 +
  58 + {{> product/latest-walk goodsInfo=@root.recommendKeywordsInfo}}
  59 +</div>
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 @import "new-arrive"; 16 @import "new-arrive";
17 @import "good-slide"; 17 @import "good-slide";
18 @import "../variables"; 18 @import "../variables";
  19 +@import "seo/index";
19 20
20 .product-page { 21 .product-page {
21 .list-left { 22 .list-left {
  1 +.seo-hot-page {
  2 + width: 1150px;
  3 + margin: 0 auto;
  4 +
  5 + .left-content {
  6 + float: left;
  7 + width: 970px;
  8 + }
  9 +
  10 + .hot-sort {
  11 + width: 100%;
  12 + position: relative;
  13 +
  14 + .sort-intro {
  15 + width: 488px;
  16 + height: 300px;
  17 + line-height: 300px;
  18 + border: 1px solid #eaeceb;
  19 + box-sizing: border-box;
  20 + }
  21 +
  22 + .inline {
  23 + width: 100%;
  24 + padding: 0 50px;
  25 + line-height: 1;
  26 + text-align: center;
  27 + display: inline-block;
  28 + box-sizing: border-box;
  29 + vertical-align: middle;
  30 + }
  31 +
  32 + .name {
  33 + font-size: 30px;
  34 + font-weight: 700;
  35 + text-align: center;
  36 +
  37 + .en {
  38 + width: 100%;
  39 + font-size: 14px;
  40 + display: block;
  41 + }
  42 + }
  43 +
  44 + .desc {
  45 + margin-top: 15px;
  46 + color: #666;
  47 + font-size: 12px;
  48 + line-height: 1.5;
  49 + }
  50 +
  51 + .key {
  52 + margin-top: 30px;
  53 +
  54 + > li {
  55 + width: 33.33%;
  56 + text-align: center;
  57 + float: left;
  58 + font-size: 12px;
  59 + line-height: 20px;
  60 + text-decoration: underline;
  61 + }
  62 +
  63 + a {
  64 + color: #069;
  65 + }
  66 + }
  67 +
  68 + .thumb {
  69 + width: 480px;
  70 + height: 300px;
  71 + position: absolute;
  72 + top: 0;
  73 + right: 0;
  74 + }
  75 + }
  76 +
  77 + .right-content {
  78 + float: right;
  79 + width: 160px;
  80 +
  81 + $border-color: #dfdfdf;
  82 +
  83 + .hot-block {
  84 + font-size: 12px;
  85 + border: 1px solid $border-color;
  86 + margin-bottom: 20px;
  87 +
  88 + .title {
  89 + line-height: 40px;
  90 + font-weight: bold;
  91 + background-color: #eaeceb;
  92 + padding-left: 10px;
  93 + }
  94 +
  95 + .hot-key {
  96 + line-height: 26px;
  97 + padding: 12px 6px 12px 10px;
  98 + border-top: 1px solid $border-color;
  99 +
  100 + > a {
  101 + margin-right: 4px;
  102 + display: inline-block;
  103 + }
  104 + }
  105 +
  106 + .brand-item {
  107 + height: 100px;
  108 + padding: 15px 10px;
  109 + display: block;
  110 + box-sizing: border-box;
  111 + border-top: 1px solid $border-color;
  112 +
  113 + img {
  114 + width: 100%;
  115 + height: 100%;
  116 + display: block;
  117 + }
  118 + }
  119 + }
  120 + }
  121 +}