Merge branch 'gray'
Showing
19 changed files
with
156 additions
and
359 deletions
@@ -156,7 +156,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -156,7 +156,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
156 | 156 | ||
157 | return { | 157 | return { |
158 | 1: helpers.urlFormat('', {from: 'search', query: row.brand_name}, 'search'), | 158 | 1: helpers.urlFormat('', {from: 'search', query: row.brand_name}, 'search'), |
159 | - 2: helpers.urlFormat('/product/shop', {domain: row.brand_domain}), | 159 | + 2: `/shop/${row.brand_domain}-${row.shop_id}.html`, |
160 | 3: helpers.urlFormat('/product/global/list/', {brand: row.global_brand_id}) | 160 | 3: helpers.urlFormat('/product/global/list/', {brand: row.global_brand_id}) |
161 | }[key]; | 161 | }[key]; |
162 | } | 162 | } |
@@ -71,12 +71,12 @@ module.exports = { | @@ -71,12 +71,12 @@ module.exports = { | ||
71 | }); | 71 | }); |
72 | 72 | ||
73 | // mip-link | 73 | // mip-link |
74 | - $('a').each(function() { | ||
75 | - let $this = $(this); | ||
76 | - let mipLink = `<mip-link href="${$this.attr('href')}" class="${$this.attr('class') || ''}" title="${$this.attr('title') || ''}">${$this.html()}</mip-link>`; // eslint-disable-line | ||
77 | - | ||
78 | - $this.replaceWith(mipLink); | ||
79 | - }); | 74 | + // $('a').each(function() { |
75 | + // let $this = $(this); | ||
76 | + // let mipLink = `<mip-link href="${$this.attr('href')}" class="${$this.attr('class') || ''}" | ||
77 | + // title="${$this.attr('title') || ''}">${$this.html()}</mip-link>`; // eslint-disable-line | ||
78 | + // $this.replaceWith(mipLink); | ||
79 | + // }); | ||
80 | 80 | ||
81 | // style | 81 | // style |
82 | $('style').each(function() { | 82 | $('style').each(function() { |
@@ -2,12 +2,12 @@ | @@ -2,12 +2,12 @@ | ||
2 | {{# guang}} | 2 | {{# guang}} |
3 | {{# author}} | 3 | {{# author}} |
4 | <div class="editor-info" data-id={{id}}> | 4 | <div class="editor-info" data-id={{id}}> |
5 | - <mip-link href="{{url}}"> | 5 | + <a href="{{url}}"> |
6 | <mip-img class="pic" width="45" height="45" src={{image2 avatar mode=2 q=60}}> | 6 | <mip-img class="pic" width="45" height="45" src={{image2 avatar mode=2 q=60}}> |
7 | </mip-img> | 7 | </mip-img> |
8 | <div class="name">{{name}}</div> | 8 | <div class="name">{{name}}</div> |
9 | <div class="intro">{{intro}}</div> | 9 | <div class="intro">{{intro}}</div> |
10 | - </mip-link> | 10 | + </a> |
11 | </div> | 11 | </div> |
12 | {{/ author}} | 12 | {{/ author}} |
13 | {{# detail}} | 13 | {{# detail}} |
@@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
39 | <div class="focus-small"></div> | 39 | <div class="focus-small"></div> |
40 | </div> | 40 | </div> |
41 | </div> | 41 | </div> |
42 | - <div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><mip-link href="{{href}}">{{tagName}}</mip-link></div> | 42 | + <div class="lable-info-box{{#if isApp}} lable-infobox-borderadius{{/if}}"><a href="{{href}}">{{tagName}}</a></div> |
43 | <div class="lable-btn add-to-cart" data-skn="{{product_skn}}"> | 43 | <div class="lable-btn add-to-cart" data-skn="{{product_skn}}"> |
44 | </div> | 44 | </div> |
45 | </div> | 45 | </div> |
@@ -65,7 +65,7 @@ | @@ -65,7 +65,7 @@ | ||
65 | {{#each relatedReco.goods}} | 65 | {{#each relatedReco.goods}} |
66 | {{#if url}} | 66 | {{#if url}} |
67 | <div class="good-item"> | 67 | <div class="good-item"> |
68 | - <mip-link href="{{url}}"> | 68 | + <a href="{{url}}"> |
69 | {{#if default_images}} | 69 | {{#if default_images}} |
70 | <div class="pic"> | 70 | <div class="pic"> |
71 | <mip-img class="pic-mip" width="76" height="102" src="{{image2 default_images w=152 h=204}}"> | 71 | <mip-img class="pic-mip" width="76" height="102" src="{{image2 default_images w=152 h=204}}"> |
@@ -78,7 +78,7 @@ | @@ -78,7 +78,7 @@ | ||
78 | <p class="price">¥{{sales_price}}</p> | 78 | <p class="price">¥{{sales_price}}</p> |
79 | {{/if}} | 79 | {{/if}} |
80 | </div> | 80 | </div> |
81 | - </mip-link> | 81 | + </a> |
82 | </div> | 82 | </div> |
83 | {{/if}} | 83 | {{/if}} |
84 | {{/each}} | 84 | {{/each}} |
@@ -89,17 +89,17 @@ | @@ -89,17 +89,17 @@ | ||
89 | {{/ detail}} | 89 | {{/ detail}} |
90 | {{#detail.content}} | 90 | {{#detail.content}} |
91 | {{#if moreLink}} | 91 | {{#if moreLink}} |
92 | - <mip-link class="more-goods" href="{{moreLink}}">更多商品</mip-link> | 92 | + <a class="more-goods" href="{{moreLink}}">更多商品</a> |
93 | {{/if}} | 93 | {{/if}} |
94 | {{#if recommendProducts}} | 94 | {{#if recommendProducts}} |
95 | <div class="recommend-goods"> | 95 | <div class="recommend-goods"> |
96 | <div class="good-scroll"> | 96 | <div class="good-scroll"> |
97 | {{#each recommendProducts}} | 97 | {{#each recommendProducts}} |
98 | <div class="good-item"> | 98 | <div class="good-item"> |
99 | - <mip-link href="{{href}}"> | 99 | + <a href="{{href}}"> |
100 | <mip-img class="pic" width="100" height="134" src="{{image2 pic_url w=152 h=204}}"> | 100 | <mip-img class="pic" width="100" height="134" src="{{image2 pic_url w=152 h=204}}"> |
101 | </mip-img> | 101 | </mip-img> |
102 | - </mip-link> | 102 | + </a> |
103 | <p class="price">¥{{price}}</p> | 103 | <p class="price">¥{{price}}</p> |
104 | </div> | 104 | </div> |
105 | {{/each}} | 105 | {{/each}} |
@@ -113,13 +113,13 @@ | @@ -113,13 +113,13 @@ | ||
113 | <div class="brand-c"> | 113 | <div class="brand-c"> |
114 | {{# relatedBrand}} | 114 | {{# relatedBrand}} |
115 | <div class="brand-item"> | 115 | <div class="brand-item"> |
116 | - <mip-link href="{{url}}"> | 116 | + <a href="{{url}}"> |
117 | <div class="pic"> | 117 | <div class="pic"> |
118 | <mip-img class="pic-mip" width="75" height="75" src="{{thumb}}"> | 118 | <mip-img class="pic-mip" width="75" height="75" src="{{thumb}}"> |
119 | </mip-img> | 119 | </mip-img> |
120 | </div> | 120 | </div> |
121 | <p>{{name}}</p> | 121 | <p>{{name}}</p> |
122 | - </mip-link> | 122 | + </a> |
123 | </div> | 123 | </div> |
124 | {{/ relatedBrand}} | 124 | {{/ relatedBrand}} |
125 | </div> | 125 | </div> |
@@ -129,7 +129,7 @@ | @@ -129,7 +129,7 @@ | ||
129 | <div class="related-info"> | 129 | <div class="related-info"> |
130 | {{# relatedInfo}} | 130 | {{# relatedInfo}} |
131 | <div class="info-item"> | 131 | <div class="info-item"> |
132 | - <mip-link href="{{url}}"> | 132 | + <a data-type="mip" data-title="{{title}}" href="//m.yohobuy.com/mip/guang/info/{{id}}.html"> |
133 | <div class="pic"> | 133 | <div class="pic"> |
134 | <mip-img class="pic-mip" width="117" height="73" src="{{thumb}}"> | 134 | <mip-img class="pic-mip" width="117" height="73" src="{{thumb}}"> |
135 | </mip-img> | 135 | </mip-img> |
@@ -138,7 +138,7 @@ | @@ -138,7 +138,7 @@ | ||
138 | <p class="title">{{title}}</p> | 138 | <p class="title">{{title}}</p> |
139 | <p class="time">{{publishTime}}</p> | 139 | <p class="time">{{publishTime}}</p> |
140 | </div> | 140 | </div> |
141 | - </mip-link> | 141 | + </a> |
142 | </div> | 142 | </div> |
143 | {{/ relatedInfo}} | 143 | {{/ relatedInfo}} |
144 | </div> | 144 | </div> |
@@ -146,7 +146,7 @@ | @@ -146,7 +146,7 @@ | ||
146 | {{#if relatedTag}} | 146 | {{#if relatedTag}} |
147 | <div class="brand-tag"> | 147 | <div class="brand-tag"> |
148 | {{# relatedTag}} | 148 | {{# relatedTag}} |
149 | - <mip-link href="//guang.m.yohobuy.com/tags/index?query={{name}}" class="tag">{{name}}</mip-link> | 149 | + <a href="//guang.m.yohobuy.com/tags/index?query={{name}}" class="tag">{{name}}</a> |
150 | {{/ relatedTag}} | 150 | {{/ relatedTag}} |
151 | </div> | 151 | </div> |
152 | {{/if}} | 152 | {{/if}} |
@@ -62,7 +62,7 @@ const newDetail = { | @@ -62,7 +62,7 @@ const newDetail = { | ||
62 | pageHeader: headerData, | 62 | pageHeader: headerData, |
63 | result: result, | 63 | result: result, |
64 | page: 'new-detail', | 64 | page: 'new-detail', |
65 | - title: result.goodsName + result.sortName + '正品 | YOHO!BUY 有货', | 65 | + title: `${result.brandName}|${result.sortName}|${result.goodsName}|YOHO!BUY 有货`, |
66 | keywords: result.brandName + result.sortName + ',' + result.brandName + '官网专卖店,' + | 66 | keywords: result.brandName + result.sortName + ',' + result.brandName + '官网专卖店,' + |
67 | result.brandName + '官方授权店,' + result.brandName + '正品,' + result.brandName + '打折,' + | 67 | result.brandName + '官方授权店,' + result.brandName + '正品,' + result.brandName + '打折,' + |
68 | result.brandName + '折扣店,' + | 68 | result.brandName + '折扣店,' + |
@@ -20,15 +20,61 @@ const co = require('bluebird').coroutine; | @@ -20,15 +20,61 @@ const co = require('bluebird').coroutine; | ||
20 | const shop = { | 20 | const shop = { |
21 | 21 | ||
22 | /** | 22 | /** |
23 | + * 老路由处理,查数据,拼链接 | ||
24 | + */ | ||
25 | + redirect(req, res, next) { | ||
26 | + let shopId = _.parseInt(stringProcess.paramsFilter(req.query.shop_id)); | ||
27 | + let domain = stringProcess.paramsFilter(req.query.domain); | ||
28 | + let brandId = _.parseInt(stringProcess.paramsFilter(req.query.brand_id)); | ||
29 | + | ||
30 | + co(function* () { | ||
31 | + if (shopId && domain) { | ||
32 | + return res.redirect(301, `//m.yohobuy.com/shop/${domain}-${shopId}.html`); | ||
33 | + } | ||
34 | + | ||
35 | + if (shopId) { | ||
36 | + let shopInfoApi = (yield req.ctx(shopModel).getShopInfo(shopId)) || {}; | ||
37 | + | ||
38 | + return res.redirect(301, `//m.yohobuy.com/shop/${_.get(shopInfoApi, 'data.shop_domain', 'id')}-${shopId}.html`); // eslint-disable-line | ||
39 | + } | ||
40 | + | ||
41 | + if (domain) { | ||
42 | + let domainInfo = (yield req.ctx(shopModel).getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息 | ||
43 | + | ||
44 | + if (domainInfo.shopId && domainInfo.type === '2') { | ||
45 | + return res.redirect(301, `//m.yohobuy.com/shop/${domain}-${_.get(domainInfo, 'shopId')}.html`); | ||
46 | + } else { | ||
47 | + return res.redirect(301, helpers.urlFormat('/product/index/brand', { | ||
48 | + brand_id: _.get(domainInfo, 'id') | ||
49 | + })); | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + if (brandId) { | ||
54 | + return res.redirect(301, helpers.urlFormat('/product/index/brand', { brand_id: brandId })); | ||
55 | + } | ||
56 | + })().catch(next); | ||
57 | + }, | ||
58 | + | ||
59 | + /** | ||
60 | + * 新路由承接页,参数解析 | ||
61 | + */ | ||
62 | + resolveParams(req, res, next) { | ||
63 | + let pathParams = _.last(_.split(req.path.replace('.html', ''), '/')); | ||
64 | + | ||
65 | + req.query.shop_id = _.last(_.split(pathParams, '-')); | ||
66 | + shop.entry(req, res, next); | ||
67 | + }, | ||
68 | + | ||
69 | + /** | ||
23 | * 店铺统一入口 | 70 | * 店铺统一入口 |
24 | */ | 71 | */ |
25 | entry(req, res, next) { | 72 | entry(req, res, next) { |
26 | const shopId = _.parseInt(stringProcess.paramsFilter(req.query.shop_id)); | 73 | const shopId = _.parseInt(stringProcess.paramsFilter(req.query.shop_id)); |
27 | const brandId = _.parseInt(stringProcess.paramsFilter(req.query.brand_id)); | 74 | const brandId = _.parseInt(stringProcess.paramsFilter(req.query.brand_id)); |
28 | 75 | ||
29 | - const { | ||
30 | - domain | ||
31 | - } = req.query; | 76 | + const domain = req.query.domain; |
77 | + | ||
32 | const uid = req.user.uid; | 78 | const uid = req.user.uid; |
33 | 79 | ||
34 | req.shopInfo = {}; | 80 | req.shopInfo = {}; |
@@ -561,9 +561,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -561,9 +561,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
561 | let storeUrl = ''; | 561 | let storeUrl = ''; |
562 | 562 | ||
563 | if (origin.shop_id) { | 563 | if (origin.shop_id) { |
564 | - storeUrl = helpers.urlFormat('/product/shop', { | ||
565 | - shop_id: origin.shop_id | ||
566 | - }); | 564 | + storeUrl = `/shop/${_.get(origin, 'brand_info.brand_domain')}-${_.get(origin, 'shop_id')}.html`; |
567 | } | 565 | } |
568 | 566 | ||
569 | // 悬浮的购物车信息 | 567 | // 悬浮的购物车信息 |
@@ -167,7 +167,9 @@ router.get('/index/category', list.shopCategory); | @@ -167,7 +167,9 @@ router.get('/index/category', list.shopCategory); | ||
167 | router.get('/index/getBrandCouponsList', list.getBrandCouponsList); | 167 | router.get('/index/getBrandCouponsList', list.getBrandCouponsList); |
168 | 168 | ||
169 | // 店铺重构 | 169 | // 店铺重构 |
170 | -router.get('/shop', newShop.entry); // 统一店铺入口 | 170 | +router.get('/shop', newShop.redirect); // 老路由重定向前置处理 |
171 | +router.get('/shop/:domain-:shop_id.html', newShop.resolveParams); // 新入口 | ||
172 | + | ||
171 | router.get('/index/brand', newShop.entry); // 旧的路由,走到新的 controller | 173 | router.get('/index/brand', newShop.entry); // 旧的路由,走到新的 controller |
172 | router.get('/index/brandFav', newShop.brandFav); | 174 | router.get('/index/brandFav', newShop.brandFav); |
173 | router.get('/new/shop/hotlist', newShop.shopHotList); | 175 | router.get('/new/shop/hotlist', newShop.shopHotList); |
@@ -66,6 +66,11 @@ module.exports = () => { | @@ -66,6 +66,11 @@ module.exports = () => { | ||
66 | req.url = `/product/search${req.path}`; | 66 | req.url = `/product/search${req.path}`; |
67 | } | 67 | } |
68 | 68 | ||
69 | + if (/^\/shop/.test(req.url)) { | ||
70 | + // SEO 店铺路由重写 新路由 | ||
71 | + req.url = `/product/${req.url}`; | ||
72 | + } | ||
73 | + | ||
69 | next(); | 74 | next(); |
70 | }; | 75 | }; |
71 | }; | 76 | }; |
@@ -25,7 +25,7 @@ function yohoSession(opts) { | @@ -25,7 +25,7 @@ function yohoSession(opts) { | ||
25 | res.emit('sessionError'); | 25 | res.emit('sessionError'); |
26 | req.sessionError = true; | 26 | req.sessionError = true; |
27 | 27 | ||
28 | - req.sessionID = uuid.v4(); | 28 | + req.sessionID = req.sessionID || uuid.v4(); |
29 | req.session = new memcachedSession.Session(req, req[opts.backSession].sessionBack); | 29 | req.session = new memcachedSession.Session(req, req[opts.backSession].sessionBack); |
30 | req.session.cookie = new memcachedSession.Cookie({ | 30 | req.session.cookie = new memcachedSession.Cookie({ |
31 | domain: 'yohobuy.com', | 31 | domain: 'yohobuy.com', |
@@ -18,7 +18,6 @@ | @@ -18,7 +18,6 @@ | ||
18 | <script src="https://mipcache.bdstatic.com/static/v1/mip.js"></script> | 18 | <script src="https://mipcache.bdstatic.com/static/v1/mip.js"></script> |
19 | <script src="https://mipcache.bdstatic.com/static/v1/mip-stats-baidu/mip-stats-baidu.js"></script> | 19 | <script src="https://mipcache.bdstatic.com/static/v1/mip-stats-baidu/mip-stats-baidu.js"></script> |
20 | <script src="https://mipcache.bdstatic.com/static/v1/mip-anim/mip-anim.js"></script> | 20 | <script src="https://mipcache.bdstatic.com/static/v1/mip-anim/mip-anim.js"></script> |
21 | -<script src="https://mipcache.bdstatic.com/static/v1/mip-link/mip-link.js"></script> | ||
22 | <script src="https://mipcache.bdstatic.com/static/v1/mip-audio/mip-audio.js"></script> | 21 | <script src="https://mipcache.bdstatic.com/static/v1/mip-audio/mip-audio.js"></script> |
23 | </body> | 22 | </body> |
24 | </html> | 23 | </html> |
@@ -79,6 +79,15 @@ | @@ -79,6 +79,15 @@ | ||
79 | var s = document.getElementsByTagName("script")[0]; | 79 | var s = document.getElementsByTagName("script")[0]; |
80 | s.parentNode.insertBefore(hm, s); | 80 | s.parentNode.insertBefore(hm, s); |
81 | })(); --}} | 81 | })(); --}} |
82 | + | ||
83 | + <!-- Google Tag Manager --> | ||
84 | + (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
85 | + new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
86 | + j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
87 | + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
88 | + })(window,document,'script','dataLayer','GTM-W958MG'); | ||
89 | + <!-- End Google Tag Manager --> | ||
90 | + | ||
82 | }, 1000); | 91 | }, 1000); |
83 | }()); | 92 | }()); |
84 | 93 |
@@ -53,11 +53,11 @@ | @@ -53,11 +53,11 @@ | ||
53 | {{/ tags}} | 53 | {{/ tags}} |
54 | </div> | 54 | </div> |
55 | <div class="good-detail-img"> | 55 | <div class="good-detail-img"> |
56 | - <a class="good-thumb" href="{{url}}"> | 56 | + <a class="good-thumb" href="{{url}}" title="{{seoTitle}}"> |
57 | {{#if @root._noLazy}} | 57 | {{#if @root._noLazy}} |
58 | - <img src="{{image2 default_images w=235 h=314 q=60}}"/> | 58 | + <img src="{{image2 default_images w=235 h=314 q=60}}" alt="{{seoTitle}}"/> |
59 | {{else}} | 59 | {{else}} |
60 | - <img class="lazy" data-original="{{image2 default_images w=235 h=314 q=60}}"/> | 60 | + <img class="lazy" data-original="{{image2 default_images w=235 h=314 q=60}}" alt="{{seoTitle}}"/> |
61 | {{/if}} | 61 | {{/if}} |
62 | </a> | 62 | </a> |
63 | {{# is_soon_sold_out}} | 63 | {{# is_soon_sold_out}} |
@@ -79,7 +79,7 @@ | @@ -79,7 +79,7 @@ | ||
79 | </div> | 79 | </div> |
80 | <div class="good-detail-text"> | 80 | <div class="good-detail-text"> |
81 | <div class="name"> | 81 | <div class="name"> |
82 | - <a href="{{url}}">{{product_name}}</a> | 82 | + <a href="{{url}}" title="{{seoTitle}}">{{product_name}}</a> |
83 | </div> | 83 | </div> |
84 | <div class="price"> | 84 | <div class="price"> |
85 | {{#if @root.saleViplogin}} | 85 | {{#if @root.saleViplogin}} |
@@ -16,6 +16,7 @@ module.exports = merge(baseConfig, { | @@ -16,6 +16,7 @@ module.exports = merge(baseConfig, { | ||
16 | output: { | 16 | output: { |
17 | publicPath: devInfo.publicPath | 17 | publicPath: devInfo.publicPath |
18 | }, | 18 | }, |
19 | + devtool: 'cheap-module-source-map', | ||
19 | plugins: [ | 20 | plugins: [ |
20 | new ExtractTextPlugin('[name].css'), | 21 | new ExtractTextPlugin('[name].css'), |
21 | new webpack.HotModuleReplacementPlugin(), | 22 | new webpack.HotModuleReplacementPlugin(), |
@@ -70,10 +70,11 @@ if (/MicroMessenger/i.test(navigator.userAgent)) { | @@ -70,10 +70,11 @@ if (/MicroMessenger/i.test(navigator.userAgent)) { | ||
70 | cache: true, | 70 | cache: true, |
71 | success: function() { | 71 | success: function() { |
72 | $.ajax({ | 72 | $.ajax({ |
73 | - url: '/activity/wechat/share', | 73 | + url: location.protocol + '//m.yohobuy.com/activity/wechat/share', |
74 | data: { | 74 | data: { |
75 | url: location.href | 75 | url: location.href |
76 | }, | 76 | }, |
77 | + dataType: 'jsonp', | ||
77 | success: function(res) { | 78 | success: function(res) { |
78 | if (window.wx) { | 79 | if (window.wx) { |
79 | window.wx.config({ | 80 | window.wx.config({ |
1 | +const tip = require('plugin/tip'); | ||
2 | + | ||
1 | $(window).on('seckill', function() { | 3 | $(window).on('seckill', function() { |
2 | $('.btn-c').before('<a href="https://union.yoho.cn/union/app-downloads.html" class="seckill-download-app">下载APP购买</a>'); | 4 | $('.btn-c').before('<a href="https://union.yoho.cn/union/app-downloads.html" class="seckill-download-app">下载APP购买</a>'); |
3 | $('.btn-c').remove(); | 5 | $('.btn-c').remove(); |
4 | }); | 6 | }); |
5 | 7 | ||
6 | -// 调用秒杀js | ||
7 | -// $(window).on('seckill', function(event, detailData) { | ||
8 | - | ||
9 | -// /** | ||
10 | -// * [秒抢页面js] | ||
11 | -// * author: 李靖<jing.li@yoho.cn> | ||
12 | -// * date: 2016/09/08 | ||
13 | -// */ | ||
14 | - | ||
15 | -// let $ = require('yoho-jquery'), | ||
16 | -// tip = require('plugin/tip'); | ||
17 | - | ||
18 | -// let seckillObj = {}; | ||
19 | - | ||
20 | -// let offsetTime = 0; | ||
21 | - | ||
22 | -// let nowTime = 0; | ||
23 | - | ||
24 | -// let startTime = 0; | ||
25 | - | ||
26 | -// let endTime = 0, | ||
27 | -// diffTime = 0; // 误差时间 | ||
28 | - | ||
29 | -// let dateText = 0, | ||
30 | -// newDate = 0, | ||
31 | -// newMonth = 0, | ||
32 | -// newDay = 0, | ||
33 | -// newHour = 0, | ||
34 | -// newMinus = 0; | ||
35 | - | ||
36 | - | ||
37 | -// let secKillPrice = 0; | ||
38 | - | ||
39 | -// // 隐藏折扣信息 | ||
40 | -// $('.good-detail-page').addClass('hide-discount'); | ||
41 | - | ||
42 | -// require('common'); | ||
43 | - | ||
44 | -// seckillObj = { | ||
45 | -// el: { | ||
46 | -// iScroll: null, | ||
47 | -// currentTick: null | ||
48 | -// }, | ||
49 | - | ||
50 | -// startTick: function(status, offTime) { | ||
51 | -// let that = this, | ||
52 | -// $el = this.el, | ||
53 | -// day = parseInt(offTime / (60 * 60 * 24), 10), | ||
54 | -// hour = parseInt(offTime % (60 * 60 * 24) / (60 * 60), 10), | ||
55 | -// minute = parseInt(offTime % (60 * 60) / 60, 10), | ||
56 | -// second = offTime % 60; | ||
57 | - | ||
58 | -// let $elem = status === 0 ? $('.seckill-count-num') : $('.end-time'); | ||
59 | - | ||
60 | -// if (offTime >= -1) { | ||
61 | -// if (day <= 0) { | ||
62 | -// $('.day-c').addClass('hide'); | ||
63 | -// } | ||
64 | -// $elem.find('.tick.day').text(that.formatNumber(day)); | ||
65 | -// $elem.find('.tick.hour').text(that.formatNumber(hour)); | ||
66 | -// $elem.find('.tick.minute').text(that.formatNumber(minute)); | ||
67 | -// $elem.find('.tick.second').text(that.formatNumber(second)); | ||
68 | - | ||
69 | -// if (offTime <= -1) { // 结束倒计时刷新状态 | ||
70 | -// window.location.reload(); | ||
71 | -// } else { | ||
72 | -// $el.currentTick = setTimeout(function() { | ||
73 | -// that.startTick(status, --offTime); | ||
74 | -// }, 1000); | ||
75 | -// } | ||
76 | -// } | ||
77 | - | ||
78 | -// }, | ||
79 | -// formatNumber: (number) => { | ||
80 | -// if (number < 0) { | ||
81 | -// return '00'; | ||
82 | -// } else if (number < 10) { | ||
83 | -// return '0' + number; | ||
84 | -// } else { | ||
85 | -// return number; | ||
86 | -// } | ||
87 | -// }, | ||
88 | -// }; | ||
89 | - | ||
90 | -// $( | ||
91 | -// function() { | ||
92 | -// $('#goodsDiscount').hide(); // 隐藏折扣楼层 | ||
93 | -// $('.cart-bar').hide(); | ||
94 | -// $('.current-price').hide(); | ||
95 | -// let ajaxUrl = '/product/seckillDetail/seckillData/' + $('#productSkn').val(); | ||
96 | -// let timestamp = Date.parse(new Date()); | ||
97 | - | ||
98 | -// $.ajax({ | ||
99 | -// type: 'GET', | ||
100 | -// url: ajaxUrl + '?tamp=' + timestamp, | ||
101 | -// success: function(data) { | ||
102 | - | ||
103 | -// // 秒杀是否结束 | ||
104 | -// if (data === '' || data.status === 0 || data.status === 3) { | ||
105 | -// window.location.replace('/product/' + $('#productSkn').val() + '.html'); // 商品url改版 | ||
106 | - | ||
107 | -// // $('.sold-out').hide(); | ||
108 | -// // $('.cart-bar a:first').append('<a href="javascript:;" class="sold-out">已售罄</a>'); | ||
109 | -// // $('.addto-cart').hide(); | ||
110 | -// // $('.cart-bar').show(); | ||
111 | -// // $('.current-price').show(); | ||
112 | -// } else { | ||
113 | - | ||
114 | -// // 秒杀开始前 | ||
115 | -// if (data.status === 1) { | ||
116 | -// $('.cart-bar').before( | ||
117 | -// '<div class="seckill-count">' + | ||
118 | -// '<div class="seckill-count-bg"></div>' + | ||
119 | -// '<div class="seckill-count-num">距秒杀开始:' + | ||
120 | -// '<span class="day-c"><i class="tick day">00</i>天</span>' + | ||
121 | -// '<i class="tick hour">00</i>时' + | ||
122 | -// '<i class="tick minute">00</i>分' + | ||
123 | -// '<i class="tick second">00</i>秒' + | ||
124 | -// '</div>' + | ||
125 | -// '</div>' | ||
126 | -// ); | ||
127 | -// $('.current-price').text('¥' + data.secKillPrice).show(); | ||
128 | -// $('.price-date').eq(0).append( | ||
129 | -// '<div class="seckill-time notStart">' + | ||
130 | -// '<span class="seckill-time-pic">秒杀预告</span>' + | ||
131 | -// '<span class="seckill-time-c">月日</span>' + | ||
132 | -// '</div>' | ||
133 | -// ); | ||
134 | -// $('.sold-out').hide(); | ||
135 | -// $('.btn-c').append('<a href="javascript:;" class="sold-out">即将开抢</a>'); | ||
136 | -// $('.addto-cart').hide(); | ||
137 | -// $('.cart-bar').show(); | ||
138 | -// $('.current-price').show(); | ||
139 | -// timeInit(data); // eslint-disable-line | ||
140 | -// } | ||
141 | - | ||
142 | -// // 秒杀进行中 | ||
143 | -// if (data.status === 2) { | ||
144 | -// $('#addtoCart').off('touchstart'); | ||
145 | - | ||
146 | -// // 插入倒计时 | ||
147 | -// addTimeout($('.price-date').eq(0)); // eslint-disable-line | ||
148 | - | ||
149 | -// let chosePanel = require('common/chose-panel-new'); | ||
150 | -// let seckillData = data.secKillSku; | ||
151 | - | ||
152 | -// detailData.cartInfo.skus.forEach( | ||
153 | -// function(val) { | ||
154 | -// seckillData.forEach( | ||
155 | -// function(item) { | ||
156 | -// if (val.skuId === item.productSku) { | ||
157 | -// val.storage = item.storageNum; | ||
158 | -// } | ||
159 | -// } | ||
160 | -// ); | ||
161 | -// } | ||
162 | -// ); | ||
163 | - | ||
164 | -// $('#addtoCart').on('touchstart', function() { | ||
165 | -// $('.cart-bar').hide(); | ||
166 | -// chosePanel.show({ | ||
167 | -// data: detailData, | ||
168 | -// disableNum: true | ||
169 | -// }).then(result => { | ||
170 | -// $('.cart-bar').show(); | ||
171 | -// if (result && result.sku) { | ||
172 | -// window.location.href = '/cart/index/seckill?skn=' + | ||
173 | -// $('#productSkn').val() + '&sku=' + result.sku.skuId; | ||
174 | -// } | ||
175 | -// }, () => { | ||
176 | -// $('.cart-bar').show(); | ||
177 | -// }); | ||
178 | -// $('.text-info').append($('.seckill-time').clone()); | ||
179 | -// $('.chose-items .num').find('.clearfix').append( | ||
180 | -// '<span class="limit-num-text">限购1件</span>' | ||
181 | -// ); | ||
182 | -// $('.sale-price').text('¥' + secKillPrice).show(); | ||
183 | -// return false; | ||
184 | -// }); | ||
185 | - | ||
186 | - | ||
187 | -// secKillPrice = toDecimal2(data.secKillPrice); // eslint-disable-line | ||
188 | -// $('.current-price').text('¥' + secKillPrice).show(); | ||
189 | -// $('.left-num').hide(); | ||
190 | -// $('.btn-plus').removeClass('btn-plus'); | ||
191 | -// $('.addto-cart').text('立即购买'); | ||
192 | -// $('#chose-btn-sure').text('立即购买').addClass('isSecKill'); | ||
193 | -// $('.cart-bar').show(); | ||
194 | -// let seckillNum = 0; | ||
195 | - | ||
196 | -// for (let i = 0; i < data.secKillSku.length; i++) { | ||
197 | -// seckillNum = seckillNum + data.secKillSku[i].storageNum; | ||
198 | -// } | ||
199 | -// if (seckillNum === 0) { | ||
200 | -// $('.sold-out').hide(); | ||
201 | -// $('.btn-c').append('<a href="javascript:;" class="sold-out">已售罄</a>'); | ||
202 | -// $('.addto-cart').hide(); | ||
203 | -// } | ||
204 | -// $('.current-price').show(); | ||
205 | -// timeInit(data); // eslint-disable-line | ||
206 | -// } | ||
207 | - | ||
208 | -// } | ||
209 | -// }, | ||
210 | -// error: function() { | ||
211 | -// tip.show('网络异常~'); | ||
212 | -// } | ||
213 | -// }); | ||
214 | - | ||
215 | -// } | ||
216 | -// ); | ||
217 | - | ||
218 | -// // function seckHide() { | ||
219 | -// // $('.chose-panel .size-list ul').each( | ||
220 | -// // function() { | ||
221 | -// // hideNum = 0; | ||
222 | -// // $(this).find('li').each( | ||
223 | -// // function() { | ||
224 | -// // if ($(this).hasClass('hide')) { | ||
225 | -// // oneIndex = $(this).index() + 1; | ||
226 | -// // twoIndex = $(this).parent('ul').index() - 2; | ||
227 | -// // $('.color-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').hide(); | ||
228 | -// // } else { | ||
229 | -// // hideNum++; | ||
230 | -// // } | ||
231 | -// // } | ||
232 | -// // ); | ||
233 | -// // if (hideNum === 0) { | ||
234 | -// // hideIndex = $(this).index() - 2; | ||
235 | -// // $('.color-list ul:first li:eq(' + hideIndex + ')').hide(); | ||
236 | -// // } | ||
237 | -// // } | ||
238 | -// // ); | ||
239 | - | ||
240 | -// // $('.chose-panel .color-list ul').each( | ||
241 | -// // function() { | ||
242 | -// // hideNum = 0; | ||
243 | -// // $(this).find('li').each( | ||
244 | -// // function() { | ||
245 | -// // if ($(this).hasClass('hide')) { | ||
246 | -// // oneIndex = $(this).index() + 1; | ||
247 | -// // twoIndex = $(this).parent('ul').index() - 2; | ||
248 | -// // $('.size-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').hide(); | ||
249 | -// // } else { | ||
250 | -// // hideNum++; | ||
251 | -// // } | ||
252 | -// // } | ||
253 | -// // ); | ||
254 | -// // if (hideNum === 0) { | ||
255 | -// // hideIndex = $(this).index() - 2; | ||
256 | -// // $('.size-list ul:first li:eq(' + hideIndex + ')').hide(); | ||
257 | -// // } | ||
258 | -// // } | ||
259 | -// // ); | ||
260 | -// // } | ||
261 | - | ||
262 | -// function addTimeout(obj) { | ||
263 | -// obj.append( | ||
264 | -// '<div class="seckill-time seckill-time-border">' + | ||
265 | -// '<span>距结束 </span>' + | ||
266 | -// '<span class="end-time">' + | ||
267 | -// '<i class="tick day hide">00</i>' + | ||
268 | -// '<i class="tick hour">00</i>:' + | ||
269 | -// '<i class="tick minute">00</i>:' + | ||
270 | -// '<i class="tick second">00</i>' + | ||
271 | -// '</span>' + | ||
272 | -// '</div>' | ||
273 | -// ); | ||
274 | -// } | ||
275 | - | ||
276 | -// // 强制保留2位小数点 | ||
277 | -// function toDecimal2(num) { | ||
278 | -// let f = parseFloat(num); | ||
279 | - | ||
280 | -// if (isNaN(f)) { | ||
281 | -// return false; | ||
282 | -// } | ||
283 | -// f = Math.round(num * 100) / 100; | ||
284 | -// let s = f.toString(); | ||
285 | -// let rs = s.indexOf('.'); | ||
286 | - | ||
287 | -// if (rs < 0) { | ||
288 | -// rs = s.length; | ||
289 | -// s += '.'; | ||
290 | -// } | ||
291 | -// while (s.length <= rs + 2) { | ||
292 | -// s += '0'; | ||
293 | -// } | ||
294 | -// return s; | ||
295 | -// } | ||
296 | - | ||
297 | -// function timeInit(data) { | ||
298 | -// let status = 0; | ||
299 | - | ||
300 | -// startTime = data.startTime; | ||
301 | -// endTime = data.endTime; | ||
302 | -// diffTime = data.currentTime; | ||
303 | -// nowTime = diffTime; | ||
304 | -// if (startTime > nowTime) { | ||
305 | -// offsetTime = startTime - nowTime; | ||
306 | -// } else if (nowTime > startTime && nowTime < endTime) { | ||
307 | -// offsetTime = endTime - nowTime; | ||
308 | -// status = 1; | ||
309 | -// } | 8 | +$(function() { |
9 | + $('#goodsDiscount').hide(); // 隐藏折扣楼层 | ||
10 | + $('.current-price').hide(); | ||
11 | + let ajaxUrl = '/product/seckillDetail/seckillData/' + $('#productSkn').val(); | ||
12 | + let timestamp = Date.parse(new Date()); | ||
13 | + | ||
14 | + $.ajax({ | ||
15 | + type: 'GET', | ||
16 | + url: ajaxUrl + '?tamp=' + timestamp, | ||
17 | + success: function(data) { | ||
18 | + let secKillPrice = toDecimal2(data.secKillPrice); // eslint-disable-line | ||
19 | + | ||
20 | + if (secKillPrice) { | ||
21 | + $('.current-price').before('<h1 class="seckill-price" style="display: inline-block;"></h1>').hide(); | ||
22 | + $('.current-price').remove(); | ||
23 | + $('.seckill-price').text('¥' + secKillPrice).show(); | ||
24 | + } else { | ||
25 | + $('.current-price').show(); | ||
26 | + } | ||
27 | + }, | ||
28 | + error: function() { | ||
29 | + tip.show('网络异常~'); | ||
30 | + } | ||
31 | + }); | ||
32 | +}); | ||
310 | 33 | ||
311 | -// dateText = Number(data.startTime * 1000); | ||
312 | -// newDate = new Date(dateText); | ||
313 | -// newMonth = newDate.getMonth() + 1; | ||
314 | -// newDay = newDate.getDate(); | ||
315 | -// newHour = newDate.getHours(); | ||
316 | -// newMinus = newDate.getMinutes(); | ||
317 | -// if (newMinus === 0) { | ||
318 | -// newMinus = '00'; | ||
319 | -// } | ||
320 | -// $('.notStart').find('.seckill-time-c').text(newMonth + '月' + newDay + '日' + newHour + ':' + newMinus); | ||
321 | -// seckillObj.startTick(status, offsetTime); | ||
322 | -// } | ||
323 | -// }); | 34 | +// 强制保留2位小数点 |
35 | +function toDecimal2(num) { | ||
36 | + let f = parseFloat(num); | ||
37 | + | ||
38 | + if (isNaN(f)) { | ||
39 | + return false; | ||
40 | + } | ||
41 | + f = Math.round(num * 100) / 100; | ||
42 | + let s = f.toString(); | ||
43 | + let rs = s.indexOf('.'); | ||
44 | + | ||
45 | + if (rs < 0) { | ||
46 | + rs = s.length; | ||
47 | + s += '.'; | ||
48 | + } | ||
49 | + while (s.length <= rs + 2) { | ||
50 | + s += '0'; | ||
51 | + } | ||
52 | + return s; | ||
53 | +} | ||
324 | 54 | ||
325 | // 调用新商品详情页js | 55 | // 调用新商品详情页js |
326 | require('./new-detail'); | 56 | require('./new-detail'); |
327 | - |
@@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
2 | * @Author: Targaryen | 2 | * @Author: Targaryen |
3 | * @Date: 2017-06-20 15:48:39 | 3 | * @Date: 2017-06-20 15:48:39 |
4 | * @Last Modified by: Targaryen | 4 | * @Last Modified by: Targaryen |
5 | - * @Last Modified time: 2017-06-20 16:04:05 | ||
6 | */ | 5 | */ |
7 | const _ = require('lodash'); | 6 | const _ = require('lodash'); |
8 | const helpers = global.yoho.helpers; | 7 | const helpers = global.yoho.helpers; |
@@ -129,7 +128,7 @@ class DetailProcess { | @@ -129,7 +128,7 @@ class DetailProcess { | ||
129 | // 底部简介URL链接 | 128 | // 底部简介URL链接 |
130 | dest.introUrl = '/product/detail/intro/' + origin.product_skn; | 129 | dest.introUrl = '/product/detail/intro/' + origin.product_skn; |
131 | dest.brandName = _.get(origin, 'brand_info.brand_name', ''); | 130 | dest.brandName = _.get(origin, 'brand_info.brand_name', ''); |
132 | - dest.sortName = _.get(origin, 'middle_sort_name', ''); | 131 | + dest.sortName = _.get(origin, 'small_sort_name', ''); |
133 | 132 | ||
134 | return dest; | 133 | return dest; |
135 | } | 134 | } |
@@ -149,9 +148,7 @@ class DetailProcess { | @@ -149,9 +148,7 @@ class DetailProcess { | ||
149 | }; | 148 | }; |
150 | 149 | ||
151 | if (value.shop_id) { | 150 | if (value.shop_id) { |
152 | - shopInfo.url = helpers.urlFormat('/product/shop', { | ||
153 | - shop_id: value.shop_id | ||
154 | - }); | 151 | + shopInfo.url = `/shop/${value.brand_domain}-${value.shop_id}.html`; |
155 | } else { | 152 | } else { |
156 | shopInfo.url = helpers.urlFormat('', null, value.brand_domain); | 153 | shopInfo.url = helpers.urlFormat('', null, value.brand_domain); |
157 | } | 154 | } |
@@ -2,6 +2,11 @@ | @@ -2,6 +2,11 @@ | ||
2 | require('../app'); | 2 | require('../app'); |
3 | const _ = require('lodash'); | 3 | const _ = require('lodash'); |
4 | const helpers = global.yoho.helpers; | 4 | const helpers = global.yoho.helpers; |
5 | +const GENDER = { | ||
6 | + 1: '男', | ||
7 | + 2: '女', | ||
8 | + 3: '男|女' | ||
9 | +}; | ||
5 | 10 | ||
6 | /** | 11 | /** |
7 | * 根据性别来决定 默认图片获取字段 如果是 2、3 | 12 | * 根据性别来决定 默认图片获取字段 如果是 2、3 |
@@ -228,6 +233,10 @@ exports.processProductList = (list, options) => { | @@ -228,6 +233,10 @@ exports.processProductList = (list, options) => { | ||
228 | product.similar = true; | 233 | product.similar = true; |
229 | } | 234 | } |
230 | 235 | ||
236 | + let seoGender = product.gender ? GENDER[product.gender] + '|' : ''; | ||
237 | + | ||
238 | + product.seoTitle = `${product.brand_name}|${seoGender}${product.small_sort_name}|${product.product_name}|YOHO!BUY有货`; // eslint-disable-line | ||
239 | + | ||
231 | pruductList.push(product); | 240 | pruductList.push(product); |
232 | }); | 241 | }); |
233 | 242 |
-
Please register or login to post a comment