Showing
12 changed files
with
172 additions
and
75 deletions
@@ -259,17 +259,3 @@ exports.consultsubmit = (req, res, next) => { | @@ -259,17 +259,3 @@ exports.consultsubmit = (req, res, next) => { | ||
259 | return res.json(data); | 259 | return res.json(data); |
260 | }).catch(next); | 260 | }).catch(next); |
261 | }; | 261 | }; |
262 | - | ||
263 | -exports.getSeckillData = (req, res) => { | ||
264 | - | ||
265 | - detailModel.getSeckillData({ | ||
266 | - | ||
267 | - productskn: req.params.productskn | ||
268 | - | ||
269 | - }, req).then(result => { | ||
270 | - | ||
271 | - return res.json(result); | ||
272 | - | ||
273 | - }); | ||
274 | - | ||
275 | -}; |
@@ -60,7 +60,7 @@ exports.index = (req, res, next) => { | @@ -60,7 +60,7 @@ exports.index = (req, res, next) => { | ||
60 | res.render('detail/detail', { | 60 | res.render('detail/detail', { |
61 | pageHeader: headerData, | 61 | pageHeader: headerData, |
62 | result: result, | 62 | result: result, |
63 | - page: 'detail', | 63 | + page: 'seckill-detail', |
64 | title: result.goodsName, | 64 | title: result.goodsName, |
65 | pageFooter: true | 65 | pageFooter: true |
66 | }); | 66 | }); |
@@ -94,7 +94,7 @@ exports.indexSkn = (req, res, next) => { | @@ -94,7 +94,7 @@ exports.indexSkn = (req, res, next) => { | ||
94 | res.render('detail/detail', { | 94 | res.render('detail/detail', { |
95 | pageHeader: headerData, | 95 | pageHeader: headerData, |
96 | result: result, | 96 | result: result, |
97 | - page: 'detail', | 97 | + page: 'seckill-detail', |
98 | title: result.goodsName, | 98 | title: result.goodsName, |
99 | pageFooter: true | 99 | pageFooter: true |
100 | }); | 100 | }); |
@@ -104,28 +104,12 @@ function fetchProductList(activityInfo, uid) { | @@ -104,28 +104,12 @@ function fetchProductList(activityInfo, uid) { | ||
104 | }); | 104 | }); |
105 | } | 105 | } |
106 | 106 | ||
107 | -let _helpers = { | ||
108 | - statusClass: (nav) => { | ||
109 | - if (nav.over) { | ||
110 | - return 'over'; | ||
111 | - } else if (nav.now) { | ||
112 | - return 'now'; | ||
113 | - } else if (nav.wait) { | ||
114 | - return 'wait'; | ||
115 | - } else { | ||
116 | - return ''; | ||
117 | - } | ||
118 | - }, | ||
119 | - readaleTime: (unixStamp) => { | ||
120 | - return moment.unix(unixStamp).format('MM月DD日 HH:mm'); | ||
121 | - } | ||
122 | -}; | ||
123 | - | ||
124 | 107 | ||
125 | /** | 108 | /** |
126 | * [秒杀列表页面] | 109 | * [秒杀列表页面] |
127 | */ | 110 | */ |
128 | const index = (req, res, next) => { | 111 | const index = (req, res, next) => { |
112 | + let focusTime = Number.parseInt(req.query.t, 10) || 0; | ||
129 | let headerData = headerModel.setNav({ | 113 | let headerData = headerModel.setNav({ |
130 | navTitle: '秒杀活动', | 114 | navTitle: '秒杀活动', |
131 | navBtn: true, | 115 | navBtn: true, |
@@ -145,6 +129,9 @@ const index = (req, res, next) => { | @@ -145,6 +129,9 @@ const index = (req, res, next) => { | ||
145 | 129 | ||
146 | return seckillModel.queryActivity().then((resultActivity) => { | 130 | return seckillModel.queryActivity().then((resultActivity) => { |
147 | // console.log(resultActivity) | 131 | // console.log(resultActivity) |
132 | + let focusIndex = false; | ||
133 | + let nowTime = Date.parse(new Date()); | ||
134 | + | ||
148 | if (resultActivity.code !== 200) { | 135 | if (resultActivity.code !== 200) { |
149 | return next(); | 136 | return next(); |
150 | } | 137 | } |
@@ -162,7 +149,17 @@ const index = (req, res, next) => { | @@ -162,7 +149,17 @@ const index = (req, res, next) => { | ||
162 | } | 149 | } |
163 | 150 | ||
164 | result.activitys = resultActivity.data.secKillProductVoList.sort((a, b) => a.startTime - b.startTime); // orderBy startTime ASC | 151 | result.activitys = resultActivity.data.secKillProductVoList.sort((a, b) => a.startTime - b.startTime); // orderBy startTime ASC |
165 | - let nowTime = Date.parse(new Date()); | 152 | + |
153 | + if (focusTime) { | ||
154 | + focusTime = moment(focusTime, 'YYYYMMDDHHmmss').unix(); | ||
155 | + focusIndex = result.activitys.findIndex(activity=> activity.startTime === focusTime); | ||
156 | + console.log(focusIndex) | ||
157 | + if (focusIndex !== -1) { | ||
158 | + result.activitys[focusIndex].focus = true; | ||
159 | + focusIndex = true; | ||
160 | + } | ||
161 | + } | ||
162 | + | ||
166 | 163 | ||
167 | result.activitys.forEach((activity, i) => { | 164 | result.activitys.forEach((activity, i) => { |
168 | let date, | 165 | let date, |
@@ -181,7 +178,7 @@ const index = (req, res, next) => { | @@ -181,7 +178,7 @@ const index = (req, res, next) => { | ||
181 | 178 | ||
182 | if (nowTime < nextTime) { // 下一个时间段与当前时间来区别是否正在抢购 | 179 | if (nowTime < nextTime) { // 下一个时间段与当前时间来区别是否正在抢购 |
183 | activity.now = true; | 180 | activity.now = true; |
184 | - activity.focus = true; | 181 | + focusIndex || (activity.focus = true); |
185 | } else { | 182 | } else { |
186 | activity.over = true; | 183 | activity.over = true; |
187 | } | 184 | } |
@@ -970,34 +970,6 @@ const _getCommonConsult = () => { | @@ -970,34 +970,6 @@ const _getCommonConsult = () => { | ||
970 | }); | 970 | }); |
971 | }; | 971 | }; |
972 | 972 | ||
973 | -/** | ||
974 | - * 获取秒杀列表 | ||
975 | - */ | ||
976 | -const getSeckillData = (param) => { | ||
977 | - let params = { | ||
978 | - method: 'app.seckill.data', | ||
979 | - product_skn: param.productskn | ||
980 | - }; | ||
981 | - | ||
982 | - return api.get('', params, { | ||
983 | - code: 200 | ||
984 | - }) | ||
985 | - | ||
986 | - // mock | ||
987 | - .catch() | ||
988 | - .then(result => { | ||
989 | - let data = {}; | ||
990 | - | ||
991 | - if (result.data) { | ||
992 | - data = result.data; | ||
993 | - } else { | ||
994 | - data.status = 0; | ||
995 | - } | ||
996 | - | ||
997 | - return data; | ||
998 | - }); | ||
999 | -}; | ||
1000 | - | ||
1001 | let getProductData = (data) => { | 973 | let getProductData = (data) => { |
1002 | let finalResult = {}; | 974 | let finalResult = {}; |
1003 | 975 | ||
@@ -1102,6 +1074,5 @@ let _productInfoBySkns = (skns) => { | @@ -1102,6 +1074,5 @@ let _productInfoBySkns = (skns) => { | ||
1102 | module.exports = { | 1074 | module.exports = { |
1103 | getProductData, | 1075 | getProductData, |
1104 | getUserProfile: _getUserProfile, | 1076 | getUserProfile: _getUserProfile, |
1105 | - getSeckillData, | ||
1106 | productInfoBySkns: _productInfoBySkns | 1077 | productInfoBySkns: _productInfoBySkns |
1107 | }; | 1078 | }; |
@@ -623,7 +623,6 @@ let getProductData = (data) => { | @@ -623,7 +623,6 @@ let getProductData = (data) => { | ||
623 | finalResult.enterStore = info[0]; | 623 | finalResult.enterStore = info[0]; |
624 | finalResult.isStudent = data.isStudent; | 624 | finalResult.isStudent = data.isStudent; |
625 | Object.assign(finalResult.feedbacks, info[2]); | 625 | Object.assign(finalResult.feedbacks, info[2]); |
626 | - Object.assign(finalResult, {isSecKill: result.isSecKill}); | ||
627 | finalResult.goodsPrice.previousPrice = '¥' + result.marketPrice; | 626 | finalResult.goodsPrice.previousPrice = '¥' + result.marketPrice; |
628 | 627 | ||
629 | /* 预售商品不能购买 */ | 628 | /* 预售商品不能购买 */ |
@@ -28,8 +28,6 @@ const queryProductList = (activityId) => { | @@ -28,8 +28,6 @@ const queryProductList = (activityId) => { | ||
28 | return api.get('', { | 28 | return api.get('', { |
29 | method: 'app.seckill.queryProductList', | 29 | method: 'app.seckill.queryProductList', |
30 | activityId: activityId | 30 | activityId: activityId |
31 | - }, { | ||
32 | - cache: true | ||
33 | }); | 31 | }); |
34 | }; | 32 | }; |
35 | 33 |
@@ -232,7 +232,5 @@ | @@ -232,7 +232,5 @@ | ||
232 | <input type="hidden" id="showPannel" value="1"> | 232 | <input type="hidden" id="showPannel" value="1"> |
233 | {{/if}} | 233 | {{/if}} |
234 | 234 | ||
235 | - <input type="hidden" id="isSecKill" value = "{{isSecKill}}"> | ||
236 | - | ||
237 | </div> | 235 | </div> |
238 | {{/ result}} | 236 | {{/ result}} |
@@ -20,6 +20,7 @@ module.exports = { | @@ -20,6 +20,7 @@ module.exports = { | ||
20 | service: 'http://service.yoho.cn/', | 20 | service: 'http://service.yoho.cn/', |
21 | liveApi: 'http://api.live.yoho.cn/', | 21 | liveApi: 'http://api.live.yoho.cn/', |
22 | singleApi: 'http://single.yoho.cn/' | 22 | singleApi: 'http://single.yoho.cn/' |
23 | + | ||
23 | // service: 'http://service-test1.yohops.com:9999/', | 24 | // service: 'http://service-test1.yohops.com:9999/', |
24 | 25 | ||
25 | // api: 'http://api.yoho.cn/', | 26 | // api: 'http://api.yoho.cn/', |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <img class="lazy" data-original="{{image defaultImages 235 314}}" alt=""> | 3 | <img class="lazy" data-original="{{image defaultImages 235 314}}" alt=""> |
4 | </div> | 4 | </div> |
5 | <div class="item-info"> | 5 | <div class="item-info"> |
6 | - <div class="item-title"> | 6 | + <div class="item-title line-clamp-2"> |
7 | {{productName}} | 7 | {{productName}} |
8 | </div> | 8 | </div> |
9 | {{#if wait}} | 9 | {{#if wait}} |
@@ -23,10 +23,6 @@ var dialog = require('../plugin/dialog'); | @@ -23,10 +23,6 @@ var dialog = require('../plugin/dialog'); | ||
23 | 23 | ||
24 | require('../common'); | 24 | require('../common'); |
25 | 25 | ||
26 | -if ($('#isSecKill').val() === 'Y') { | ||
27 | - require('./tick'); | ||
28 | -} | ||
29 | - | ||
30 | // add extra marign-bottom for footer to show the yoho copyright | 26 | // add extra marign-bottom for footer to show the yoho copyright |
31 | function showFooter() { | 27 | function showFooter() { |
32 | var $cartBar = $('.cart-bar'); | 28 | var $cartBar = $('.cart-bar'); |
public/js/product/seckill-detail.page.js
0 → 100644
1 | +/** | ||
2 | + * 商品详情 | ||
3 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
4 | + * @date: 2015/10/20 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'), | ||
7 | + Swiper = require('yoho-swiper'), | ||
8 | + Hammer = require('yoho-hammer'), | ||
9 | + lazyLoad = require('yoho-jquery-lazyload'); | ||
10 | + | ||
11 | +var $discountFolder = $('.goods-discount .discount-folder'), | ||
12 | + $discountArrow = $('.goods-discount .first-item span'); | ||
13 | + | ||
14 | +var goodsDiscountEl = document.getElementById('goodsDiscount'), | ||
15 | + goodsDiscountHammer = goodsDiscountEl && new Hammer(goodsDiscountEl), | ||
16 | + $discountFirstItem = $(goodsDiscountEl).find('.first-item'); | ||
17 | + | ||
18 | +var $cart = $('.cart-bar'); | ||
19 | + | ||
20 | +var appUrl = $('input[name="limitCodeUrl"]').val(); | ||
21 | + | ||
22 | +var dialog = require('../plugin/dialog'); | ||
23 | + | ||
24 | +require('../common'); | ||
25 | + | ||
26 | +require('./tick'); | ||
27 | + | ||
28 | +// add extra marign-bottom for footer to show the yoho copyright | ||
29 | +function showFooter() { | ||
30 | + var $cartBar = $('.cart-bar'); | ||
31 | + | ||
32 | + var timer = setInterval(function() { | ||
33 | + if ($cartBar) { | ||
34 | + window.reMarginFooter('.cart-bar'); | ||
35 | + clearInterval(timer); | ||
36 | + } else { | ||
37 | + $cartBar = $('.cart-bar'); | ||
38 | + } | ||
39 | + }, 200); | ||
40 | +} | ||
41 | + | ||
42 | +showFooter(); | ||
43 | + | ||
44 | +lazyLoad($('img.lazy')); | ||
45 | + | ||
46 | +if ($('#goodsDiscount h1').length < 1) { | ||
47 | + $('.dropdown').remove(); | ||
48 | +} | ||
49 | + | ||
50 | +// 顶部swiper | ||
51 | +new Swiper('.banner-swiper', { | ||
52 | + lazyLoading: true, | ||
53 | + lazyLoadingInPrevNext: true, | ||
54 | + paginationClickable: true, | ||
55 | + pagination: '.banner-top .pagination-inner', | ||
56 | + nextButton: '.my-swiper-button-next', | ||
57 | + prevButton: '.my-swiper-button-prev', | ||
58 | + spaceBetween: 3 | ||
59 | +}); | ||
60 | + | ||
61 | +// 初始化goods-discount | ||
62 | +if ($discountFolder.children().length === 0) { | ||
63 | + $discountFolder.css('display', 'none'); | ||
64 | + $discountArrow.html(''); | ||
65 | +} | ||
66 | + | ||
67 | +// goods-discount下拉按钮点击事件 | ||
68 | +if (goodsDiscountHammer && $discountFolder.children().length > 0) { | ||
69 | + goodsDiscountHammer.on('tap', function() { | ||
70 | + if ($discountFolder.is(':hidden')) { | ||
71 | + $discountFirstItem.removeClass('short-text'); | ||
72 | + $discountArrow.removeClass('icon-down').addClass('icon-up').html(''); | ||
73 | + $discountFolder.slideDown(); | ||
74 | + } else { | ||
75 | + $discountFirstItem.addClass('short-text'); | ||
76 | + $discountArrow.removeClass('icon-up').addClass('icon-down').html(''); | ||
77 | + $discountFolder.slideUp(); | ||
78 | + } | ||
79 | + }); | ||
80 | +} | ||
81 | + | ||
82 | +$('#limit-sale').on('touchend', function(e) { | ||
83 | + var loginUrl = $('#loginUrl').val(), | ||
84 | + time, | ||
85 | + ifr; | ||
86 | + | ||
87 | + e.stopPropagation(); | ||
88 | + | ||
89 | + if (loginUrl) { | ||
90 | + window.location = loginUrl; | ||
91 | + } else { | ||
92 | + dialog.showDialog({ | ||
93 | + dialogText: '进入有货APP,获取限购码', | ||
94 | + hasFooter: { | ||
95 | + rightBtnText: '打开Yoho!Buy有货APP' | ||
96 | + } | ||
97 | + }, function() { | ||
98 | + ifr = document.createElement('iframe'); | ||
99 | + ifr.src = appUrl; | ||
100 | + ifr.style.display = 'none'; | ||
101 | + document.body.appendChild(ifr); | ||
102 | + window.location.href = appUrl; | ||
103 | + | ||
104 | + time = Date.now(); | ||
105 | + window.setTimeout(function() { | ||
106 | + document.body.removeChild(ifr); | ||
107 | + if (Date.now() - time < 3200) { | ||
108 | + window.location.href = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho'; | ||
109 | + } | ||
110 | + }, 3000); | ||
111 | + | ||
112 | + }, null, true); | ||
113 | + | ||
114 | + $('.dialog-wrapper').off('touchstart').on('touchstart', function(para) { | ||
115 | + para.stopPropagation(); | ||
116 | + if ($(para.target).hasClass('dialog-wrapper')) { | ||
117 | + dialog.hideDialog(); | ||
118 | + } | ||
119 | + }); | ||
120 | + } | ||
121 | +}); | ||
122 | + | ||
123 | +require('./detail/like'); | ||
124 | +require('./detail/desc'); | ||
125 | +require('./detail/comments-consults'); | ||
126 | +require('./detail/consultform'); | ||
127 | +require('./detail/recommend-for-you-product-desc'); | ||
128 | + | ||
129 | +// 购物车商品数量 | ||
130 | +$.ajax({ | ||
131 | + type: 'GET', | ||
132 | + url: '/cart/index/count', | ||
133 | + success: function(data) { | ||
134 | + var count; | ||
135 | + | ||
136 | + if (data.code === 200) { | ||
137 | + count = data.data.cart_goods_count || 0; | ||
138 | + if (count === 0) { | ||
139 | + return false; | ||
140 | + } | ||
141 | + if (count > 99) { | ||
142 | + count = '99+'; | ||
143 | + } | ||
144 | + $cart.find('.num-tag').html(count).removeClass('hide'); | ||
145 | + } | ||
146 | + } | ||
147 | +}); | ||
148 | + | ||
149 | +if ($('.good-detail-page').length > 0) { | ||
150 | + $('#yoho-footer').css('border-top', '1px solid #e0e0e0'); | ||
151 | +} |
@@ -380,7 +380,7 @@ seckillObj = { | @@ -380,7 +380,7 @@ seckillObj = { | ||
380 | var $xhr; | 380 | var $xhr; |
381 | 381 | ||
382 | loading.show(); | 382 | loading.show(); |
383 | - $xhr = $.get('/product/seckill') | 383 | + $xhr = $.get(location.href) |
384 | .done(function(result) { | 384 | .done(function(result) { |
385 | self.$container.html( | 385 | self.$container.html( |
386 | self.pageTemplate($.extend(result, { | 386 | self.pageTemplate($.extend(result, { |
-
Please register or login to post a comment