Merge remote-tracking branch 'origin/feature/seckill' into feature/seckill
Showing
10 changed files
with
538 additions
and
82 deletions
@@ -259,3 +259,17 @@ exports.consultsubmit = (req, res, next) => { | @@ -259,3 +259,17 @@ 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 | +}; |
@@ -975,6 +975,72 @@ const _getCommonConsult = () => { | @@ -975,6 +975,72 @@ const _getCommonConsult = () => { | ||
975 | }); | 975 | }); |
976 | }; | 976 | }; |
977 | 977 | ||
978 | +/** | ||
979 | + * 获取秒杀列表 | ||
980 | + */ | ||
981 | +const getSeckillData = (productSkn) => { | ||
982 | + let params = { | ||
983 | + method: 'app.seckill.data', | ||
984 | + product_skn: productSkn | ||
985 | + }; | ||
986 | + | ||
987 | + return api.get('', params, { | ||
988 | + code: 200 | ||
989 | + }).then(result => { | ||
990 | + let data = {}; | ||
991 | + | ||
992 | + if (result.data) { | ||
993 | + data = result.data; | ||
994 | + } | ||
995 | + | ||
996 | + data = { | ||
997 | + activityId: 4, | ||
998 | + startTime: 1465194254, | ||
999 | + endTime: 1475294254, | ||
1000 | + formatSecKillPrice: '¥133.00', | ||
1001 | + id: 4, | ||
1002 | + orderBy: 0, | ||
1003 | + productSkn: 512581470, | ||
1004 | + secKillPrice: 50, | ||
1005 | + secKillSku: [ | ||
1006 | + { | ||
1007 | + activityId: 4, | ||
1008 | + id: 1, | ||
1009 | + productSkn: 512581470, | ||
1010 | + productSku: 1381111, | ||
1011 | + storageNum: 1 | ||
1012 | + }, | ||
1013 | + { | ||
1014 | + activityId: 4, | ||
1015 | + id: 2, | ||
1016 | + productSkn: 512581470, | ||
1017 | + productSku: 1382222, | ||
1018 | + storageNum: 2 | ||
1019 | + }, | ||
1020 | + { | ||
1021 | + activityId: 4, | ||
1022 | + id: 2, | ||
1023 | + productSkn: 512581470, | ||
1024 | + productSku: 1383333, | ||
1025 | + storageNum: 3 | ||
1026 | + }, | ||
1027 | + { | ||
1028 | + activityId: 4, | ||
1029 | + id: 2, | ||
1030 | + productSkn: 512581470, | ||
1031 | + productSku: 1384444, | ||
1032 | + storageNum: 0 | ||
1033 | + } | ||
1034 | + ], | ||
1035 | + secKillStatus: 0, | ||
1036 | + status: 2, | ||
1037 | + storageSum: 0 | ||
1038 | + }; | ||
1039 | + | ||
1040 | + return data; | ||
1041 | + }); | ||
1042 | +}; | ||
1043 | + | ||
978 | let getProductData = (data) => { | 1044 | let getProductData = (data) => { |
979 | let finalResult; | 1045 | let finalResult; |
980 | let params = { | 1046 | let params = { |
@@ -996,6 +1062,7 @@ let getProductData = (data) => { | @@ -996,6 +1062,7 @@ let getProductData = (data) => { | ||
996 | } | 1062 | } |
997 | 1063 | ||
998 | return _getUserProfile(params.uid).then((user) => { | 1064 | return _getUserProfile(params.uid).then((user) => { |
1065 | + | ||
999 | data.vipLevel = (user.data && user.data.vip_info && user.data.vip_info.cur_level) || '0'; | 1066 | data.vipLevel = (user.data && user.data.vip_info && user.data.vip_info.cur_level) || '0'; |
1000 | data.isStudent = (user.data && user.data.vip_info && user.data.vip_info.is_student) ? true : false; | 1067 | data.isStudent = (user.data && user.data.vip_info && user.data.vip_info.is_student) ? true : false; |
1001 | params.is_student = data.isStudent ? 1 : 0; | 1068 | params.is_student = data.isStudent ? 1 : 0; |
@@ -1015,8 +1082,50 @@ let getProductData = (data) => { | @@ -1015,8 +1082,50 @@ let getProductData = (data) => { | ||
1015 | productId: result.productId | 1082 | productId: result.productId |
1016 | }), | 1083 | }), |
1017 | _getCommonConsult(), | 1084 | _getCommonConsult(), |
1018 | - comment.getConsults(result.productId, 1, 2) | 1085 | + comment.getConsults(result.productId, 1, 2), |
1086 | + getSeckillData(result.productSkn) | ||
1019 | ]).then((info) => { | 1087 | ]).then((info) => { |
1088 | + | ||
1089 | + // 根据app.product.data接口是否返回isSecKill,判断是否是秒杀 | ||
1090 | + // let isSecKills = result.isSecKill === 'Y' ? true : false; | ||
1091 | + let isSecKills = true;// TODO | ||
1092 | + | ||
1093 | + let gList = result.goodsList; | ||
1094 | + | ||
1095 | + // 统计非秒杀库存数 | ||
1096 | + let commonNum = 0; | ||
1097 | + | ||
1098 | + gList.forEach(row => { | ||
1099 | + row.sizeList.forEach(val => { | ||
1100 | + commonNum = commonNum + val.storageNumber; | ||
1101 | + }); | ||
1102 | + }); | ||
1103 | + | ||
1104 | + // 统计秒杀库存数 | ||
1105 | + let leftCount = 0; | ||
1106 | + | ||
1107 | + info[5].secKillSku.forEach(val => { | ||
1108 | + leftCount = leftCount + val.storageNum; | ||
1109 | + }); | ||
1110 | + | ||
1111 | + // 如果秒杀库存不为0,将商品库存链接至秒杀库存 | ||
1112 | + let i = 0; | ||
1113 | + | ||
1114 | + if (isSecKills && info[5] && leftCount) { | ||
1115 | + gList.forEach(row => { | ||
1116 | + row.sizeList.forEach(val => { | ||
1117 | + val.storageNumber = info[5].secKillSku[i].storageNum; | ||
1118 | + val.productSku = info[5].secKillSku[i].productSku; | ||
1119 | + i++; | ||
1120 | + }); | ||
1121 | + }); | ||
1122 | + } | ||
1123 | + | ||
1124 | + // 秒杀详情页弹出层价格 | ||
1125 | + if (isSecKills && leftCount && info[5]) { | ||
1126 | + result.formatMarketPrice = info[5].formatSecKillPrice; | ||
1127 | + } | ||
1128 | + | ||
1020 | result.promotionBoList = info[1]; | 1129 | result.promotionBoList = info[1]; |
1021 | finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua); | 1130 | finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua); |
1022 | finalResult.enterStore = info[0]; | 1131 | finalResult.enterStore = info[0]; |
@@ -1024,7 +1133,35 @@ let getProductData = (data) => { | @@ -1024,7 +1133,35 @@ let getProductData = (data) => { | ||
1024 | 1133 | ||
1025 | Object.assign(finalResult.feedbacks, info[2]); | 1134 | Object.assign(finalResult.feedbacks, info[2]); |
1026 | 1135 | ||
1027 | - /* 如果有咨询,显示咨询,否则显示常见问题 */ | 1136 | + // 秒杀详情页 |
1137 | + | ||
1138 | + if (isSecKills && leftCount && info[5]) { | ||
1139 | + | ||
1140 | + let end = info[5].status === 3 ? true : false; | ||
1141 | + | ||
1142 | + if (!end) { | ||
1143 | + | ||
1144 | + let notStart = info[5].status === 1 ? true : false; | ||
1145 | + | ||
1146 | + let startIng = info[5].status === 2 ? true : false; | ||
1147 | + | ||
1148 | + Object.assign(finalResult, { | ||
1149 | + isSecKill: { | ||
1150 | + notStart: notStart, | ||
1151 | + startIng: startIng, | ||
1152 | + end: end, | ||
1153 | + productSkn: data.productSkn, | ||
1154 | + secKillPrice: info[5].formatSecKillPrice, | ||
1155 | + noneLeft: leftCount === 0 && commonNum === 0 ? true : false | ||
1156 | + } | ||
1157 | + }); | ||
1158 | + | ||
1159 | + } | ||
1160 | + | ||
1161 | + } | ||
1162 | + | ||
1163 | + /* 如果有咨询,显示咨询,否则显示常见问题 */ | ||
1164 | + | ||
1028 | if (info[4].total) { | 1165 | if (info[4].total) { |
1029 | finalResult.feedbacks.consultsNum = parseInt(info[4].total, 10); | 1166 | finalResult.feedbacks.consultsNum = parseInt(info[4].total, 10); |
1030 | 1167 | ||
@@ -1040,6 +1177,7 @@ let getProductData = (data) => { | @@ -1040,6 +1177,7 @@ let getProductData = (data) => { | ||
1040 | consults: _.take(info[3], 2) | 1177 | consults: _.take(info[3], 2) |
1041 | }); | 1178 | }); |
1042 | } | 1179 | } |
1180 | + | ||
1043 | return finalResult; | 1181 | return finalResult; |
1044 | }); | 1182 | }); |
1045 | 1183 | ||
@@ -1049,5 +1187,6 @@ let getProductData = (data) => { | @@ -1049,5 +1187,6 @@ let getProductData = (data) => { | ||
1049 | 1187 | ||
1050 | module.exports = { | 1188 | module.exports = { |
1051 | getProductData, | 1189 | getProductData, |
1052 | - getUserProfile: _getUserProfile | 1190 | + getUserProfile: _getUserProfile, |
1191 | + getSeckillData | ||
1053 | }; | 1192 | }; |
@@ -39,6 +39,7 @@ router.get('/detail/consults', detail.consults); // 商品咨询页 | @@ -39,6 +39,7 @@ router.get('/detail/consults', detail.consults); // 商品咨询页 | ||
39 | router.get('/detail/consultform', auth, detail.consultform); // 商品咨询表单页 | 39 | router.get('/detail/consultform', auth, detail.consultform); // 商品咨询表单页 |
40 | router.get('/detail/comments', detail.comments); // 商品评价 | 40 | router.get('/detail/comments', detail.comments); // 商品评价 |
41 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 | 41 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 |
42 | +router.get('/detail/seckillData/:productskn', detail.getSeckillData); // 秒杀数据接口 | ||
42 | 43 | ||
43 | router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口 | 44 | router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口 |
44 | router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口 | 45 | router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口 |
@@ -61,6 +62,7 @@ router.get('/recommend-for-you/userCenter', recommendForYou.userCenter); | @@ -61,6 +62,7 @@ router.get('/recommend-for-you/userCenter', recommendForYou.userCenter); | ||
61 | router.get('/recommend-for-you/cart', recommendForYou.cart); | 62 | router.get('/recommend-for-you/cart', recommendForYou.cart); |
62 | 63 | ||
63 | router.get('/seckill', seckill.index); // 秒杀列表页 | 64 | router.get('/seckill', seckill.index); // 秒杀列表页 |
65 | +router.get(/\/seckill\/detail\/pro_([\d]+)_([\d]+)\/(.*)/, detail.getUser, detail.index); // 秒杀详情页 | ||
66 | +router.get(/\/seckill\/detail\/show_([\d]+)/, detail.getUser, detail.indexSkn); // 秒杀详情页 SKN 进入 | ||
64 | router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表根据活动id获取商品列表 | 67 | router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表根据活动id获取商品列表 |
65 | - | ||
66 | module.exports = router; | 68 | module.exports = router; |
@@ -38,7 +38,11 @@ | @@ -38,7 +38,11 @@ | ||
38 | <div class="price-date"> | 38 | <div class="price-date"> |
39 | {{# goodsPrice}} | 39 | {{# goodsPrice}} |
40 | <div class="goods-price"> | 40 | <div class="goods-price"> |
41 | + {{#if ../isSecKill}} | ||
42 | + <h1 class="current-price">{{../isSecKill/secKillPrice}}</h1> | ||
43 | + {{else}} | ||
41 | <h1 class="current-price">{{currentPrice}}</h1> | 44 | <h1 class="current-price">{{currentPrice}}</h1> |
45 | + {{/if}} | ||
42 | <h1 class="previous-price">{{previousPrice}}</h1> | 46 | <h1 class="previous-price">{{previousPrice}}</h1> |
43 | </div> | 47 | </div> |
44 | {{/ goodsPrice}} | 48 | {{/ goodsPrice}} |
@@ -63,6 +67,24 @@ | @@ -63,6 +67,24 @@ | ||
63 | <h1 >{{periodOfMarket}}</h1> | 67 | <h1 >{{periodOfMarket}}</h1> |
64 | </div> | 68 | </div> |
65 | {{/if}} | 69 | {{/if}} |
70 | + {{#isSecKill}} | ||
71 | + {{#if startIng}} | ||
72 | + <div class="seckill-time seckill-time-border"> | ||
73 | + <span>距结束 </span> | ||
74 | + <span class="end-time"> | ||
75 | + <i class="tick hour">00</i>: | ||
76 | + <i class="tick minute">00</i>: | ||
77 | + <i class="tick second">00</i> | ||
78 | + </span> | ||
79 | + </div> | ||
80 | + {{/if}} | ||
81 | + {{#if notStart}} | ||
82 | + <div class="seckill-time notStart"> | ||
83 | + <span class="seckill-time-pic">秒杀预告</span> | ||
84 | + <span class="seckill-time-c">月日</span> | ||
85 | + </div> | ||
86 | + {{/if}} | ||
87 | + {{/isSecKill}} | ||
66 | </div> | 88 | </div> |
67 | 89 | ||
68 | {{#if studentPrice}} | 90 | {{#if studentPrice}} |
@@ -158,40 +180,61 @@ | @@ -158,40 +180,61 @@ | ||
158 | <div id="productDesc"> </div> | 180 | <div id="productDesc"> </div> |
159 | {{> detail/recommend-for-you}} | 181 | {{> detail/recommend-for-you}} |
160 | {{> cart/chose-panel}} | 182 | {{> cart/chose-panel}} |
161 | - | 183 | + {{# isSecKill}} |
184 | + {{# notStart}} | ||
185 | + <div class="seckill-count"> | ||
186 | + <div class="seckill-count-bg"></div> | ||
187 | + <div class="seckill-count-num">距秒杀开始: | ||
188 | + <i class="tick hour">00</i>时 | ||
189 | + <i class="tick minute">00</i>分 | ||
190 | + <i class="tick second">00</i>秒 | ||
191 | + </div> | ||
192 | + </div> | ||
193 | + {{/notStart}} | ||
194 | + {{/isSecKill}} | ||
162 | {{#cartInfo}} | 195 | {{#cartInfo}} |
163 | <div class="cart-bar"> | 196 | <div class="cart-bar"> |
164 | <a href="{{cartUrl}}" class="num-incart iconfont"><span class="num-tag hide"></span></a> | 197 | <a href="{{cartUrl}}" class="num-incart iconfont"><span class="num-tag hide"></span></a> |
198 | + {{#if ../isSecKill/noneLeft}} | ||
199 | + <a href="javascript:;" class="sold-out">已售罄</a> | ||
200 | + {{else if ../isSecKill/startIng}} | ||
201 | + <a href="javascript:;" id="addtoCart" class="addto-cart">立即购买</a> | ||
202 | + {{else if ../isSecKill/notStart}} | ||
203 | + <a href="javascript:;" class="sold-out">即将开抢</a> | ||
204 | + {{else}} | ||
205 | + {{#if addToCartUrl}} | ||
206 | + <a id="addtoCart" href="javascript:;" class="addto-cart">{{#if ../tickets}}立即购买{{else}}加入购物车{{/if}}</a> | ||
207 | + {{/if}} | ||
165 | 208 | ||
166 | - {{#if addToCartUrl}} | ||
167 | - <a id="addtoCart" href="javascript:;" class="addto-cart">{{#if ../tickets}}立即购买{{else}}加入购物车{{/if}}</a> | ||
168 | - {{/if}} | 209 | + {{#if soldOut}} |
210 | + <a href="javascript:;" class="sold-out">已售罄</a> | ||
211 | + {{/if}} | ||
169 | 212 | ||
170 | - {{#if soldOut}} | ||
171 | - <a href="javascript:;" class="sold-out">已售罄</a> | ||
172 | - {{/if}} | 213 | + {{#if notForSale}} |
214 | + <a href="javascript:;" class="sold-out">非卖品</a> | ||
215 | + {{/if}} | ||
173 | 216 | ||
174 | - {{#if notForSale}} | ||
175 | - <a href="javascript:;" class="sold-out">非卖品</a> | ||
176 | - {{/if}} | 217 | + {{#if limitNotForSale}} |
218 | + <a href="javascript:;" class="sold-out limit">即将发售</a> | ||
219 | + {{/if}} | ||
177 | 220 | ||
178 | - {{#if limitNotForSale}} | ||
179 | - <a href="javascript:;" class="sold-out limit">即将发售</a> | ||
180 | - {{/if}} | 221 | + {{#if canBuyLimit}} |
222 | + <a href="javascript:;" id="addtoCart" class="addto-cart">立即购买</a> | ||
223 | + {{/if}} | ||
181 | 224 | ||
182 | - {{#if canBuyLimit}} | ||
183 | - <a href="javascript:;" id="addtoCart" class="addto-cart">立即购买</a> | ||
184 | - {{/if}} | 225 | + {{#if noLimitCode}} |
226 | + <a href="javascript:;" class="sold-out limit">立即购买</a> | ||
227 | + {{/if}} | ||
185 | 228 | ||
186 | - {{#if noLimitCode}} | ||
187 | - <a href="javascript:;" class="sold-out limit">立即购买</a> | ||
188 | - {{/if}} | ||
189 | - <input type="hidden" id="limitCodeUrl" name="limitCodeUrl" value="{{limitCodeUrl}}"> | ||
190 | - <input type="hidden" id="limitProductPay" name="limitProductPay" value="{{limitProductPay}}"> | ||
191 | - {{#limitProductCode}} | ||
192 | - <input type="hidden" id="limitProductCode" name="limitProductCode" value="{{.}}"> | ||
193 | - {{/limitProductCode}} | 229 | + <input type="hidden" id="limitCodeUrl" name="limitCodeUrl" value="{{limitCodeUrl}}"> |
194 | 230 | ||
231 | + <input type="hidden" id="limitProductPay" name="limitProductPay" value="{{limitProductPay}}"> | ||
232 | + | ||
233 | + {{#limitProductCode}} | ||
234 | + <input type="hidden" id="limitProductCode" name="limitProductCode" value="{{.}}"> | ||
235 | + {{/limitProductCode}} | ||
236 | + | ||
237 | + {{/if}} | ||
195 | <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}"></a> | 238 | <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}"></a> |
196 | </div> | 239 | </div> |
197 | {{/cartInfo}} | 240 | {{/cartInfo}} |
@@ -223,4 +266,7 @@ | @@ -223,4 +266,7 @@ | ||
223 | {{/if}} | 266 | {{/if}} |
224 | 267 | ||
225 | </div> | 268 | </div> |
269 | + {{# isSecKill}} | ||
270 | + <input type="hidden" class="productSkn-text" value={{productSkn}} /> | ||
271 | + {{/isSecKill}} | ||
226 | {{/ result}} | 272 | {{/ result}} |
@@ -14,6 +14,16 @@ | @@ -14,6 +14,16 @@ | ||
14 | <span class="market-price">{{price}}</span> | 14 | <span class="market-price">{{price}}</span> |
15 | {{/if}} | 15 | {{/if}} |
16 | </p> | 16 | </p> |
17 | + {{#if ../isSecKill/startIng}} | ||
18 | + <div class="seckill-time seckill-time-border seckill-chose"> | ||
19 | + <span>距结束 </span> | ||
20 | + <span class="end-time"> | ||
21 | + <i class="tick hour">00</i>: | ||
22 | + <i class="tick minute">00</i>: | ||
23 | + <i class="tick second">00</i> | ||
24 | + </span> | ||
25 | + </div> | ||
26 | + {{/if}} | ||
17 | </div> | 27 | </div> |
18 | </div> | 28 | </div> |
19 | <div class="chose-items"> | 29 | <div class="chose-items"> |
@@ -45,15 +55,26 @@ | @@ -45,15 +55,26 @@ | ||
45 | <div class="num"> | 55 | <div class="num"> |
46 | <span>数量</span> | 56 | <span>数量</span> |
47 | <div class="clearfix"> | 57 | <div class="clearfix"> |
48 | - <a class="btn btn-minus" href="javascript:void(0);"> | ||
49 | - <span class="iconfont {{#if promotionId}}disabled{{/if}}"></span> | ||
50 | - </a> | ||
51 | - <input id="good-num" class="good-num disabled" type="text" value="1" disabled="true"> | ||
52 | - <a class="btn btn-plus" href="javascript:void(0);"> | ||
53 | - <span class="iconfont {{#if promotionId}}disabled{{/if}}"></span> | ||
54 | - </a> | 58 | + {{#if ../isSecKill/startIng}} |
59 | + <a class="btn" href="javascript:void(0);"> | ||
60 | + <span class="iconfont {{#if promotionId}}disabled{{/if}}"></span> | ||
61 | + </a> | ||
62 | + <input id="good-num" class="good-num disabled" type="text" value="1" disabled="true"> | ||
63 | + <a class="btn" href="javascript:void(0);"> | ||
64 | + <span class="iconfont {{#if promotionId}}disabled{{/if}}"></span> | ||
65 | + </a> | ||
66 | + <span class="limit-num-text">限购1件</span> | ||
67 | + {{else}} | ||
68 | + <a class="btn btn-minus" href="javascript:void(0);"> | ||
69 | + <span class="iconfont {{#if promotionId}}disabled{{/if}}"></span> | ||
70 | + </a> | ||
71 | + <input id="good-num" class="good-num disabled" type="text" value="1" disabled="true"> | ||
72 | + <a class="btn btn-plus" href="javascript:void(0);"> | ||
73 | + <span class="iconfont {{#if promotionId}}disabled{{/if}}"></span> | ||
74 | + </a> | ||
75 | + {{/if}} | ||
55 | </div> | 76 | </div> |
56 | - <span class="left-num"></span> | 77 | + <span class="left-num {{#if ../isSecKill}}hide{{/if}}"></span> |
57 | <input id="left-num" type="hidden" value="0"> | 78 | <input id="left-num" type="hidden" value="0"> |
58 | <input id="limitNum" type="hidden" value="{{limit}}"> | 79 | <input id="limitNum" type="hidden" value="{{limit}}"> |
59 | </div> | 80 | </div> |
@@ -61,7 +82,20 @@ | @@ -61,7 +82,20 @@ | ||
61 | </div> | 82 | </div> |
62 | </div> | 83 | </div> |
63 | <div class="btn-wrap"> | 84 | <div class="btn-wrap"> |
64 | - <button id="chose-btn-sure" class="btn btn-sure">{{#if ../tickets}}立即购买{{else}}加入购物车{{/if}}</button> | 85 | + |
86 | + {{#if ../isSecKill/startIng}} | ||
87 | + <button id="chose-btn-sure" class="btn btn-sure go-pay isSecKill"> | ||
88 | + 立即抢购 | ||
89 | + </button> | ||
90 | + {{else}} | ||
91 | + <button id="chose-btn-sure" class="btn btn-sure go-pay"> | ||
92 | + {{#if ../tickets}} | ||
93 | + 立即购买 | ||
94 | + {{else}} | ||
95 | + 加入购物车 | ||
96 | + {{/if}} | ||
97 | + </button> | ||
98 | + {{/if}} | ||
65 | </div> | 99 | </div> |
66 | </div> | 100 | </div> |
67 | </div> | 101 | </div> |
@@ -58,6 +58,8 @@ var limitProductCode, | @@ -58,6 +58,8 @@ var limitProductCode, | ||
58 | // 限购商品的skn。只有限购商品时才会设置。 | 58 | // 限购商品的skn。只有限购商品时才会设置。 |
59 | skn; | 59 | skn; |
60 | 60 | ||
61 | +var isSecKills = $('.isSecKill').length;// 秒杀标记 | ||
62 | + | ||
61 | // 禁用数字编辑 | 63 | // 禁用数字编辑 |
62 | function disableNumEdit() { | 64 | function disableNumEdit() { |
63 | var $numBtn = $('.chose-panel').find('.num .btn>.iconfont'); | 65 | var $numBtn = $('.chose-panel').find('.num .btn>.iconfont'); |
@@ -203,15 +205,30 @@ function hide() { | @@ -203,15 +205,30 @@ function hide() { | ||
203 | } | 205 | } |
204 | 206 | ||
205 | // 修改加入购物车的文字和背景 | 207 | // 修改加入购物车的文字和背景 |
208 | + | ||
209 | +var isSeckill = $('.limit-num-text').length; | ||
210 | + | ||
206 | function updateConformButtonClassAndText() { | 211 | function updateConformButtonClassAndText() { |
207 | - $chosed = $allChoseItems.find('.chosed'); | ||
208 | - if ($chosed.closest('.zero-stock').length === 2) { | ||
209 | - $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄'); | ||
210 | - } else if (limitProductCode || ticketsLimit) { | ||
211 | - $('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买'); | 212 | + if (isSeckill > 0) { |
213 | + $chosed = $allChoseItems.find('.chosed'); | ||
214 | + if ($chosed.closest('.zero-stock').length === 2) { | ||
215 | + $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄'); | ||
216 | + } else if (limitProductCode || ticketsLimit) { | ||
217 | + $('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买'); | ||
218 | + } else { | ||
219 | + $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '立即结算'); | ||
220 | + } | ||
212 | } else { | 221 | } else { |
213 | - $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车'); | 222 | + $chosed = $allChoseItems.find('.chosed'); |
223 | + if ($chosed.closest('.zero-stock').length === 2) { | ||
224 | + $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄'); | ||
225 | + } else if (limitProductCode || ticketsLimit) { | ||
226 | + $('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买'); | ||
227 | + } else { | ||
228 | + $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车'); | ||
229 | + } | ||
214 | } | 230 | } |
231 | + | ||
215 | } | 232 | } |
216 | 233 | ||
217 | // 显示剩余件数 | 234 | // 显示剩余件数 |
@@ -549,8 +566,9 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -549,8 +566,9 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
549 | if (!ticketsLimit) { | 566 | if (!ticketsLimit) { |
550 | confirming = true; | 567 | confirming = true; |
551 | } | 568 | } |
552 | - | ||
553 | - loading.showLoadingMask(); | 569 | + if (!isSecKills) { |
570 | + loading.showLoadingMask(); | ||
571 | + } | ||
554 | 572 | ||
555 | // 立即购买门票 | 573 | // 立即购买门票 |
556 | if (ticketsLimit) { | 574 | if (ticketsLimit) { |
@@ -578,7 +596,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -578,7 +596,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
578 | productSku + '&skn=' + skn + '&buy_number=' + buyNumber; | 596 | productSku + '&skn=' + skn + '&buy_number=' + buyNumber; |
579 | 597 | ||
580 | removePannel(); | 598 | removePannel(); |
581 | - loading.showLoadingMask(); | 599 | + |
600 | + if (!isSecKills) { | ||
601 | + loading.showLoadingMask(); | ||
602 | + } | ||
582 | 603 | ||
583 | // 调用接口判断商品是否可以购买 | 604 | // 调用接口判断商品是否可以购买 |
584 | $.ajax({ | 605 | $.ajax({ |
@@ -615,47 +636,70 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | @@ -615,47 +636,70 @@ $yohoPage.on('touchstart', '.btn-minus', function() { | ||
615 | url = '/cart/index/add'; | 636 | url = '/cart/index/add'; |
616 | } | 637 | } |
617 | 638 | ||
618 | - $.ajax({ | ||
619 | - method: 'POST', | ||
620 | - url: url, | ||
621 | - data: cartGoodData | ||
622 | - }).done(function(res) { | ||
623 | - var cartNum; | ||
624 | - | ||
625 | - loading.hideLoadingMask(); | ||
626 | - if (res.code === 200 && !isEdit) { | ||
627 | - cartNum = res.data.goods_count; | ||
628 | - if (cartNum > 99) { | ||
629 | - cartNum = '99+'; | 639 | + if (!isSecKills) { |
640 | + $.ajax({ | ||
641 | + method: 'POST', | ||
642 | + url: url, | ||
643 | + data: cartGoodData | ||
644 | + }).done(function(res) { | ||
645 | + var cartNum; | ||
646 | + | ||
647 | + loading.hideLoadingMask(); | ||
648 | + if (res.code === 200 && !isEdit) { | ||
649 | + cartNum = res.data.goods_count; | ||
650 | + if (cartNum > 99) { | ||
651 | + cartNum = '99+'; | ||
652 | + } | ||
653 | + $('.num-tag').html(cartNum).removeClass('hide'); | ||
654 | + confirming = false; | ||
655 | + | ||
656 | + if (cbFn) { | ||
657 | + cbFn(); | ||
658 | + } | ||
630 | } | 659 | } |
631 | - $('.num-tag').html(cartNum).removeClass('hide'); | ||
632 | - confirming = false; | ||
633 | - | ||
634 | - if (cbFn) { | ||
635 | - cbFn(); | 660 | + if (res.message && !isEdit) { |
661 | + tip.show(res.message); | ||
636 | } | 662 | } |
637 | - } | ||
638 | - if (res.message && !isEdit) { | ||
639 | - tip.show(res.message); | ||
640 | - } | ||
641 | 663 | ||
642 | - hide(); | 664 | + hide(); |
643 | 665 | ||
644 | - if (isEdit) { | ||
645 | - loading.showLoadingMask(); | 666 | + if (isEdit) { |
667 | + loading.showLoadingMask(); | ||
646 | 668 | ||
647 | - // 延迟刷新,否则面板可能无法隐藏 | ||
648 | - setTimeout(function() { | 669 | + // 延迟刷新,否则面板可能无法隐藏 |
670 | + setTimeout(function() { | ||
671 | + | ||
672 | + // 获取当前页面商品类型:普通商品/预售商品 | ||
673 | + window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); | ||
674 | + }, 1); | ||
675 | + } | ||
676 | + }).fail(function() { | ||
677 | + tip.show('网络出了点问题~'); | ||
678 | + }).always(function() { | ||
679 | + confirming = false; | ||
680 | + }); | ||
681 | + | ||
682 | + } else { | ||
683 | + | ||
684 | + $('#chose-btn-sure').click( | ||
685 | + function() { | ||
686 | + var thisSkn = $('#productSkn').val(); | ||
687 | + var thisSku = ''; | ||
688 | + $('.size-row').each( | ||
689 | + function() { | ||
690 | + if ($(this).hasClass('hide')) { | ||
691 | + return false; | ||
692 | + } else { | ||
693 | + thisSku = $(this).find('.chosed').attr('data-skuid'); | ||
694 | + } | ||
695 | + } | ||
696 | + ); | ||
697 | + | ||
698 | + window.location.href = '/cart/seckill?skn=' + thisSkn + '&sku=' + thisSku; | ||
699 | + } | ||
700 | + ); | ||
701 | + } | ||
649 | 702 | ||
650 | - // 获取当前页面商品类型:普通商品/预售商品 | ||
651 | - window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); | ||
652 | - }, 1); | ||
653 | - } | ||
654 | - }).fail(function() { | ||
655 | - tip.show('网络出了点问题~'); | ||
656 | - }).always(function() { | ||
657 | - confirming = false; | ||
658 | - }); | ||
659 | } | 703 | } |
660 | 704 | ||
661 | }); | 705 | }); |
@@ -23,6 +23,8 @@ var dialog = require('../plugin/dialog'); | @@ -23,6 +23,8 @@ var dialog = require('../plugin/dialog'); | ||
23 | 23 | ||
24 | require('../common'); | 24 | require('../common'); |
25 | 25 | ||
26 | +require('./tick'); | ||
27 | + | ||
26 | // add extra marign-bottom for footer to show the yoho copyright | 28 | // add extra marign-bottom for footer to show the yoho copyright |
27 | function showFooter() { | 29 | function showFooter() { |
28 | var $cartBar = $('.cart-bar'); | 30 | var $cartBar = $('.cart-bar'); |
@@ -146,6 +146,7 @@ seckillObj = { | @@ -146,6 +146,7 @@ seckillObj = { | ||
146 | // 初始化倒计时并开始计时 | 146 | // 初始化倒计时并开始计时 |
147 | that.initTick(elem); | 147 | that.initTick(elem); |
148 | } | 148 | } |
149 | + | ||
149 | // 刷新商品列表 | 150 | // 刷新商品列表 |
150 | that.refreshProductList($(elem).find('input.activityId').val()); | 151 | that.refreshProductList($(elem).find('input.activityId').val()); |
151 | }, | 152 | }, |
@@ -178,12 +179,14 @@ seckillObj = { | @@ -178,12 +179,14 @@ seckillObj = { | ||
178 | $(this).addClass('wait'); | 179 | $(this).addClass('wait'); |
179 | } | 180 | } |
180 | }); | 181 | }); |
182 | + | ||
181 | // 刷新商品列表 | 183 | // 刷新商品列表 |
182 | var focusElem = $el.$navUl.find('>li.focus'); | 184 | var focusElem = $el.$navUl.find('>li.focus'); |
183 | if (focusElem.length) { | 185 | if (focusElem.length) { |
184 | that.refreshProductList(focusElem.find('input.activityId').val()); | 186 | that.refreshProductList(focusElem.find('input.activityId').val()); |
185 | } | 187 | } |
186 | }, | 188 | }, |
189 | + | ||
187 | /** | 190 | /** |
188 | * [异步加载商品列表] | 191 | * [异步加载商品列表] |
189 | */ | 192 | */ |
@@ -205,7 +208,7 @@ seckillObj = { | @@ -205,7 +208,7 @@ seckillObj = { | ||
205 | error: function(data) { | 208 | error: function(data) { |
206 | tip.show('网络断开连接了~'); | 209 | tip.show('网络断开连接了~'); |
207 | } | 210 | } |
208 | - }) | 211 | + }); |
209 | }, | 212 | }, |
210 | 213 | ||
211 | /** | 214 | /** |
public/js/product/tick.js
0 → 100644
1 | +/** | ||
2 | + * [秒抢页面js] | ||
3 | + * author: 陈峰<feng.chen@yoho.cn> | ||
4 | + * date: 2016/09/08 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho-jquery'), | ||
8 | + seckillObj = {}; | ||
9 | + | ||
10 | +var timeObj = ''; | ||
11 | + | ||
12 | +var offsetTime = 0; | ||
13 | + | ||
14 | +var nowTime = Date.parse(new Date()) / 1000; | ||
15 | + | ||
16 | +var startTime = 0; | ||
17 | + | ||
18 | +var endTime = 0; | ||
19 | + | ||
20 | +var dateText = 0, | ||
21 | + newDate = 0, | ||
22 | + newMonth = 0, | ||
23 | + newDay = 0, | ||
24 | + newHour = 0, | ||
25 | + newMinus = 0; | ||
26 | + | ||
27 | +require('../common'); | ||
28 | + | ||
29 | +seckillObj = { | ||
30 | + el: { | ||
31 | + iScroll: null, | ||
32 | + currentTick: null | ||
33 | + }, | ||
34 | + | ||
35 | + startTick: function(elem, offsetTime) { | ||
36 | + var that = this, | ||
37 | + $el = this.el, | ||
38 | + hour = parseInt(offsetTime / (60 * 60), 10), | ||
39 | + minute = parseInt(offsetTime % (60 * 60) / 60, 10), | ||
40 | + second = offsetTime % 60; | ||
41 | + | ||
42 | + if (offsetTime) { | ||
43 | + $(elem).find('.tick.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour)); | ||
44 | + $(elem).find('.tick.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute)); | ||
45 | + $(elem).find('.tick.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second)); | ||
46 | + if (offsetTime <= 0) { // 结束倒计时刷新状态 | ||
47 | + // that.refreshList(elem); | ||
48 | + } else { | ||
49 | + $el.currentTick = setTimeout(function() { | ||
50 | + that.startTick(elem, --offsetTime); | ||
51 | + }, 1000); | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + } | ||
56 | +}; | ||
57 | + | ||
58 | +$( | ||
59 | + function() { | ||
60 | + var ajaxUrl = '/product/detail/seckillData/' + $('.productSkn-text').val(); | ||
61 | + $.ajax({ | ||
62 | + type: 'GET', | ||
63 | + url: ajaxUrl, | ||
64 | + success: function(data) { | ||
65 | + | ||
66 | + startTime = data.startTime; | ||
67 | + | ||
68 | + endTime = data.endTime; | ||
69 | + | ||
70 | + if (startTime > nowTime) { | ||
71 | + offsetTime = startTime - nowTime; | ||
72 | + timeObj = $('.seckill-count-num'); | ||
73 | + } else if (nowTime > startTime && nowTime < endTime) { | ||
74 | + offsetTime = endTime - nowTime; | ||
75 | + timeObj = $('.end-time'); | ||
76 | + } | ||
77 | + dateText = Number(data.startTime * 1000); | ||
78 | + newDate = new Date(dateText); | ||
79 | + newMonth = newDate.getMonth() + 1; | ||
80 | + newDay = newDate.getDate(); | ||
81 | + newHour = newDate.getHours(); | ||
82 | + newMinus = newDate.getMinutes(); | ||
83 | + $('.notStart').find('.seckill-time-c').text(newMonth + '月' + newDay + '日' + newHour + ':' + newMinus); | ||
84 | + seckillObj.startTick(timeObj, offsetTime); | ||
85 | + }, | ||
86 | + error: function() { | ||
87 | + // alert('err'); | ||
88 | + } | ||
89 | + }); | ||
90 | + | ||
91 | + } | ||
92 | +); |
@@ -371,6 +371,52 @@ $basicBtnC: #eb0313; | @@ -371,6 +371,52 @@ $basicBtnC: #eb0313; | ||
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | + .seckill-time { | ||
375 | + float: right; | ||
376 | + color: #d0021b; | ||
377 | + font-size: 24px; | ||
378 | + | ||
379 | + span { | ||
380 | + display: inline-block; | ||
381 | + line-height: 88px; | ||
382 | + } | ||
383 | + | ||
384 | + .seckill-time-pic { | ||
385 | + background-color: #d0021b; | ||
386 | + color: #fff; | ||
387 | + line-height: 35px; | ||
388 | + font-size: 18px; | ||
389 | + padding: 0 10px; | ||
390 | + border-radius: 5px; | ||
391 | + } | ||
392 | + } | ||
393 | + | ||
394 | + .seckill-chose { | ||
395 | + position: absolute; | ||
396 | + bottom: 0px; | ||
397 | + right: 0px; | ||
398 | + } | ||
399 | + | ||
400 | + .limit-num-text { | ||
401 | + color: #d0021b; | ||
402 | + font-size: 30px; | ||
403 | + line-height: 80px; | ||
404 | + position: absolute; | ||
405 | + left: 380px; | ||
406 | + bottom: 0; | ||
407 | + } | ||
408 | + | ||
409 | + .seckill-time-border { | ||
410 | + border: solid 1px #d0021b; | ||
411 | + margin-top: 26px; | ||
412 | + border-radius: 19px; | ||
413 | + padding: 0 10px; | ||
414 | + | ||
415 | + span { | ||
416 | + line-height: 34px; | ||
417 | + } | ||
418 | + } | ||
419 | + | ||
374 | .vip-level { | 420 | .vip-level { |
375 | box-sizing: box-border; | 421 | box-sizing: box-border; |
376 | padding-right: 28px; | 422 | padding-right: 28px; |
@@ -711,7 +757,41 @@ $basicBtnC: #eb0313; | @@ -711,7 +757,41 @@ $basicBtnC: #eb0313; | ||
711 | } | 757 | } |
712 | } | 758 | } |
713 | } | 759 | } |
760 | + /* | ||
761 | + 秒杀倒计时栏 | ||
762 | + */ | ||
763 | + .seckill-count { | ||
764 | + position: relative; | ||
765 | + position: fixed; | ||
766 | + bottom: 120px; | ||
767 | + left: 50%; | ||
768 | + margin-left: -320px; | ||
769 | + z-index: 2; | ||
770 | + box-sizing: border-box; | ||
771 | + width: 640px; | ||
772 | + height: 70px; | ||
773 | + text-align: left; | ||
774 | + | ||
775 | + .seckill-count-bg { | ||
776 | + background-color: #000; | ||
777 | + opacity: 0.7; | ||
778 | + width: 640px; | ||
779 | + height: 70px; | ||
780 | + } | ||
714 | 781 | ||
782 | + .seckill-count-num { | ||
783 | + position: absolute; | ||
784 | + top: 0; | ||
785 | + left: 0; | ||
786 | + padding: 0 30px; | ||
787 | + color: white; | ||
788 | + width: 640px; | ||
789 | + height: 70px; | ||
790 | + line-height: 70px; | ||
791 | + box-sizing: border-box; | ||
792 | + font-size: 28px; | ||
793 | + } | ||
794 | + } | ||
715 | /* | 795 | /* |
716 | 底部固定栏 | 796 | 底部固定栏 |
717 | */ | 797 | */ |
-
Please register or login to post a comment