Showing
5 changed files
with
57 additions
and
42 deletions
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | const mRoot = '../models'; | 8 | const mRoot = '../models'; |
9 | -const _ = require('lodash'); | ||
10 | const plusstarModel = require(`${mRoot}/plusstar`); | 9 | const plusstarModel = require(`${mRoot}/plusstar`); |
11 | 10 | ||
12 | /** | 11 | /** |
@@ -32,7 +31,7 @@ exports.resourcesTemplate = (req, res, next) => { | @@ -32,7 +31,7 @@ exports.resourcesTemplate = (req, res, next) => { | ||
32 | content_code: code | 31 | content_code: code |
33 | }).then(result => { | 32 | }).then(result => { |
34 | res.render('plusstar/resources-template', { | 33 | res.render('plusstar/resources-template', { |
35 | - page: 'plusstar-resources-template', | 34 | + layout: false, |
36 | result: result, | 35 | result: result, |
37 | title: '潮流优选' | 36 | title: '潮流优选' |
38 | }); | 37 | }); |
@@ -42,7 +42,8 @@ const getProductBatch = (productSkn) => { | @@ -42,7 +42,8 @@ const getProductBatch = (productSkn) => { | ||
42 | productSkn = _.isArray(productSkn) ? productSkn : [productSkn]; | 42 | productSkn = _.isArray(productSkn) ? productSkn : [productSkn]; |
43 | return api.get('', { | 43 | return api.get('', { |
44 | method: 'h5.product.batch', | 44 | method: 'h5.product.batch', |
45 | - productSkn: productSkn.join(',') | 45 | + productSkn: productSkn.join(','), |
46 | + app_type: 1 | ||
46 | }).then(result => { | 47 | }).then(result => { |
47 | return result && result.data ? productProcess.processProductList(result.data.product_list) : []; | 48 | return result && result.data ? productProcess.processProductList(result.data.product_list) : []; |
48 | }); | 49 | }); |
@@ -57,7 +58,8 @@ const getResources = (params) => { | @@ -57,7 +58,8 @@ const getResources = (params) => { | ||
57 | params = params || {}; | 58 | params = params || {}; |
58 | 59 | ||
59 | return serviceAPI.get( | 60 | return serviceAPI.get( |
60 | - 'operations/api/v5/resource/get', params | 61 | + 'operations/api/v5/resource/get', |
62 | + params | ||
61 | ).then(result => { | 63 | ).then(result => { |
62 | let data = { | 64 | let data = { |
63 | goods: {}, | 65 | goods: {}, |
@@ -129,6 +131,10 @@ const getResources = (params) => { | @@ -129,6 +131,10 @@ const getResources = (params) => { | ||
129 | } | 131 | } |
130 | }); | 132 | }); |
131 | 133 | ||
134 | + if (_.isEmpty(data.goods.productSkns)) { | ||
135 | + return data; | ||
136 | + } | ||
137 | + | ||
132 | return getProductBatch(data.goods.productSkns || []).then(res => { | 138 | return getProductBatch(data.goods.productSkns || []).then(res => { |
133 | data.goods.data = res; | 139 | data.goods.data = res; |
134 | return data; | 140 | return data; |
@@ -16,16 +16,18 @@ | @@ -16,16 +16,18 @@ | ||
16 | </div> | 16 | </div> |
17 | {{/each}} | 17 | {{/each}} |
18 | 18 | ||
19 | - <div class="focus-left-right"> | ||
20 | - {{#each result.focus2.data}} | ||
21 | - <a href="{{url}}" title="{{title}}"> | ||
22 | - <img class="lazy" data-original="{{image src 250 250}}"> | ||
23 | - </a> | ||
24 | - {{/each}} | ||
25 | - </div> | 19 | + {{#if result.focus2.data}} |
20 | + <div class="focus-left-right"> | ||
21 | + {{#each result.focus2.data}} | ||
22 | + <a href="{{url}}" title="{{title}}"> | ||
23 | + <img class="lazy" data-original="{{image src 250 250}}"> | ||
24 | + </a> | ||
25 | + {{/each}} | ||
26 | + </div> | ||
27 | + {{/if}} | ||
26 | <!--/focus-left-right--> | 28 | <!--/focus-left-right--> |
27 | - | ||
28 | - {{#if result.recommend}} | 29 | + |
30 | + {{#if result.recommend.title}} | ||
29 | <div class="header-title"> | 31 | <div class="header-title"> |
30 | {{result.recommend.title.name}} | 32 | {{result.recommend.title.name}} |
31 | <a class="more" href="{{result.recommend.title.moreUrl}}"> | 33 | <a class="more" href="{{result.recommend.title.moreUrl}}"> |
@@ -41,7 +43,7 @@ | @@ -41,7 +43,7 @@ | ||
41 | </div> | 43 | </div> |
42 | {{/if}} | 44 | {{/if}} |
43 | 45 | ||
44 | - {{#if result.goods}} | 46 | + {{#if result.goods.title}} |
45 | <div class="header-title"> | 47 | <div class="header-title"> |
46 | {{result.goods.title.name}} | 48 | {{result.goods.title.name}} |
47 | <a class="more" href="{{result.goods.title.moreUrl}}"> | 49 | <a class="more" href="{{result.goods.title.moreUrl}}"> |
1 | var $ = require('yoho-jquery'), | 1 | var $ = require('yoho-jquery'), |
2 | tip = require('../plugin/tip'), | 2 | tip = require('../plugin/tip'), |
3 | + Swiper = require('yoho-swiper'), | ||
3 | loading = require('../plugin/loading'), | 4 | loading = require('../plugin/loading'), |
4 | lazyLoad = require('yoho-jquery-lazyload'); | 5 | lazyLoad = require('yoho-jquery-lazyload'); |
5 | 6 | ||
@@ -12,14 +13,20 @@ plusstar = { | @@ -12,14 +13,20 @@ plusstar = { | ||
12 | init: function() { | 13 | init: function() { |
13 | var that = this, $liDom; | 14 | var that = this, $liDom; |
14 | 15 | ||
15 | - //事情委托机制 | ||
16 | - $('.plusstar-page .tab-nav ul').bind('click', function(even) { | 16 | + // 事情委托机制 |
17 | + $('.plusstar-page .tab-nav ul').bind('click', function(event) { | ||
17 | $liDom = $(event.target).closest('li'); | 18 | $liDom = $(event.target).closest('li'); |
19 | + | ||
20 | + if ($liDom.hasClass('focus')) { | ||
21 | + return true; | ||
22 | + } | ||
23 | + | ||
18 | $(this).find('li').removeClass('focus'); | 24 | $(this).find('li').removeClass('focus'); |
19 | $liDom.addClass('focus'); | 25 | $liDom.addClass('focus'); |
20 | that.tabNav($liDom.data('code')); | 26 | that.tabNav($liDom.data('code')); |
21 | }); | 27 | }); |
22 | 28 | ||
29 | + // start -- 默认选中 | ||
23 | switch (window.cookie('_Channel')) { | 30 | switch (window.cookie('_Channel')) { |
24 | case 'girls': | 31 | case 'girls': |
25 | $liDom = $('.plusstar-page .tab-nav ul li:eq(1)'); | 32 | $liDom = $('.plusstar-page .tab-nav ul li:eq(1)'); |
@@ -31,9 +38,15 @@ plusstar = { | @@ -31,9 +38,15 @@ plusstar = { | ||
31 | $liDom = $('.plusstar-page .tab-nav ul li:eq(0)'); | 38 | $liDom = $('.plusstar-page .tab-nav ul li:eq(0)'); |
32 | break; | 39 | break; |
33 | } | 40 | } |
41 | + $('.plusstar-page .tab-nav ul').find('li').removeClass('focus'); | ||
42 | + $liDom.addClass('focus'); | ||
34 | that.tabNav($liDom.data('code')); | 43 | that.tabNav($liDom.data('code')); |
44 | + | ||
45 | + // ent -- 默认选中 | ||
35 | }, | 46 | }, |
36 | tabNav: function(code) { | 47 | tabNav: function(code) { |
48 | + var that = this; | ||
49 | + | ||
37 | loading.showLoadingMask(); | 50 | loading.showLoadingMask(); |
38 | $.ajax({ | 51 | $.ajax({ |
39 | type: 'GET', | 52 | type: 'GET', |
@@ -43,22 +56,41 @@ plusstar = { | @@ -43,22 +56,41 @@ plusstar = { | ||
43 | }, | 56 | }, |
44 | dataType: 'html', | 57 | dataType: 'html', |
45 | success: function(data) { | 58 | success: function(data) { |
59 | + $('.plusstar-resources').html(data); | ||
60 | + | ||
46 | if (data === '') { | 61 | if (data === '') { |
47 | tip.show('没有更多内容了'); | 62 | tip.show('没有更多内容了'); |
63 | + return true; | ||
48 | } | 64 | } |
49 | 65 | ||
50 | - $('.plusstar-resources').html(data); | 66 | + that.resInit(); |
51 | 67 | ||
52 | loading.hideLoadingMask(); | 68 | loading.hideLoadingMask(); |
53 | lazyLoad($('img.lazy')); | 69 | lazyLoad($('img.lazy')); |
54 | }, | 70 | }, |
55 | error: function() { | 71 | error: function() { |
56 | tip.show('网络断开连接了~'); | 72 | tip.show('网络断开连接了~'); |
73 | + loading.hideLoadingMask(); | ||
57 | } | 74 | } |
58 | }); | 75 | }); |
76 | + }, | ||
77 | + resInit: function() { | ||
78 | + // 头部banner轮播 | ||
79 | + if ($('.banner-swiper').find('li').size() > 1) { | ||
80 | + new Swiper('.banner-swiper', { | ||
81 | + lazyLoading: true, | ||
82 | + lazyLoadingInPrevNext: true, | ||
83 | + loop: true, | ||
84 | + autoplay: 3000, | ||
85 | + autoplayDisableOnInteraction: false, | ||
86 | + paginationClickable: true, | ||
87 | + slideElement: 'li', | ||
88 | + pagination: '.banner-top .pagination-inner' | ||
89 | + }); | ||
90 | + } | ||
59 | } | 91 | } |
60 | }; | 92 | }; |
61 | 93 | ||
62 | $(function() { | 94 | $(function() { |
63 | plusstar.init(); | 95 | plusstar.init(); |
64 | -}); | ||
96 | +}); |
1 | -var $ = require('yoho-jquery'), | ||
2 | - Swiper = require('yoho-swiper'); | ||
3 | - | ||
4 | -var plusstarResources = { | ||
5 | - init: function() { | ||
6 | - // 头部banner轮播 | ||
7 | - if ($('.banner-swiper').find('li').size() > 1) { | ||
8 | - new Swiper('.banner-swiper', { | ||
9 | - lazyLoading: true, | ||
10 | - lazyLoadingInPrevNext: true, | ||
11 | - loop: true, | ||
12 | - autoplay: 3000, | ||
13 | - autoplayDisableOnInteraction: false, | ||
14 | - paginationClickable: true, | ||
15 | - slideElement: 'li', | ||
16 | - pagination: '.banner-top .pagination-inner' | ||
17 | - }); | ||
18 | - } | ||
19 | - } | ||
20 | -}; | ||
21 | - | ||
22 | -$(function() { | ||
23 | - plusstarResources.init(); | ||
24 | -}); |
-
Please register or login to post a comment