Authored by lijing

秒杀详情页

@@ -981,7 +981,6 @@ const getSeckillData = (param) => { @@ -981,7 +981,6 @@ const getSeckillData = (param) => {
981 method: 'app.seckill.data', 981 method: 'app.seckill.data',
982 product_skn: param.productskn 982 product_skn: param.productskn
983 }; 983 };
984 -  
985 return api.get('', params, { 984 return api.get('', params, {
986 code: 200 985 code: 200
987 }) 986 })
@@ -994,44 +993,6 @@ const getSeckillData = (param) => { @@ -994,44 +993,6 @@ const getSeckillData = (param) => {
994 if (result.data) { 993 if (result.data) {
995 data = result.data; 994 data = result.data;
996 } 995 }
997 - data = {  
998 - 'activityId': 226,  
999 - 'currentTime': 1476265949,  
1000 - 'endTime': 1476343557,  
1001 - 'formatSecKillPrice': '¥5.00',  
1002 - 'id': 512,  
1003 - 'orderBy': 1,  
1004 - 'productSkn': 51165112,  
1005 - 'remindFlag': false,  
1006 - 'secKillPrice': 5646545,  
1007 - 'secKillSku': [  
1008 - {  
1009 - 'activityId': 226,  
1010 - 'id': 199,  
1011 - 'productSkn': 51165112,  
1012 - 'productSku': 555,  
1013 - 'storageNum': 2  
1014 - },  
1015 - {  
1016 - 'activityId': 226,  
1017 - 'id': 200,  
1018 - 'productSkn': 51165112,  
1019 - 'productSku': 222,  
1020 - 'storageNum': 2  
1021 - },  
1022 - {  
1023 - 'activityId': 226,  
1024 - 'id': 200,  
1025 - 'productSkn': 51165112,  
1026 - 'productSku': 444,  
1027 - 'storageNum': 2  
1028 - }  
1029 - ],  
1030 - 'secKillStatus': 0,  
1031 - 'startTime': 1476261000,  
1032 - 'status': 2,  
1033 - 'storageSum': 2  
1034 - };  
1035 return data; 996 return data;
1036 }); 997 });
1037 }; 998 };
@@ -1070,64 +1031,6 @@ let getProductData = (data) => { @@ -1070,64 +1031,6 @@ let getProductData = (data) => {
1070 return {}; 1031 return {};
1071 } 1032 }
1072 result = result.data; 1033 result = result.data;
1073 - result.goodsList[1] = {  
1074 - status: 1,  
1075 - colorCode: '47ba17',  
1076 - colorId: 10,  
1077 - colorImage: 'http://img10.static.yhbimg.com/goodsimg/2015/11/02/06/01361c1986f1dd2eaff70e1f85a35bfacd.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/70',  
1078 - colorName: '白色',  
1079 - colorValue: '',  
1080 - goodsId: 385777,  
1081 - imagesList: [{ imageUrl: 'http://img10.static.yhbimg.com/goodsimg/2015/11/02/06/01361c1986f1dd2eaff70e1f85a35bfacd.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/70' }],  
1082 - isDefault: 'N',  
1083 - productSkc: 297246,  
1084 - sizeList:  
1085 - [  
1086 - {  
1087 - status: 1,  
1088 - allStorageNumber: 0,  
1089 - orderBy: 1,  
1090 - productSku: 444,  
1091 - sizeId: 199,  
1092 - sizeName: 'F',  
1093 - storageNumber: 136,  
1094 - storeStorageNumber: 0  
1095 - },  
1096 - {  
1097 - status: 1,  
1098 - allStorageNumber: 0,  
1099 - orderBy: 1,  
1100 - productSku: 555,  
1101 - sizeId: 200,  
1102 - sizeName: 'A',  
1103 - storageNumber: 136,  
1104 - storeStorageNumber: 0  
1105 - }  
1106 - ]  
1107 - };  
1108 - result.goodsList[0].sizeList = [  
1109 - {  
1110 - status: 1,  
1111 - allStorageNumber: 1,  
1112 - orderBy: 1,  
1113 - productSku: 111,  
1114 - sizeId: 199,  
1115 - sizeName: 'F',  
1116 - storageNumber: 1,  
1117 - storeStorageNumber: 1  
1118 - },  
1119 - {  
1120 - status: 1,  
1121 - allStorageNumber: 1,  
1122 - orderBy: 1,  
1123 - productSku: 222,  
1124 - sizeId: 200,  
1125 - sizeName: 'A',  
1126 - storageNumber: 1,  
1127 - storeStorageNumber: 1  
1128 - }  
1129 -  
1130 - ];  
1131 return Promise.all([ 1034 return Promise.all([
1132 _getShopsInfo(_.get(result, 'brandInfo.brandId', 0)), 1035 _getShopsInfo(_.get(result, 'brandInfo.brandId', 0)),
1133 _getPromotionInfo(result.productSkn), 1036 _getPromotionInfo(result.productSkn),
@@ -1137,13 +1040,12 @@ let getProductData = (data) => { @@ -1137,13 +1040,12 @@ let getProductData = (data) => {
1137 _getCommonConsult(), 1040 _getCommonConsult(),
1138 comment.getConsults(result.productId, 1, 2) 1041 comment.getConsults(result.productId, 1, 2)
1139 ]).then((info) => { 1042 ]).then((info) => {
1140 -  
1141 result.promotionBoList = info[1]; 1043 result.promotionBoList = info[1];
1142 finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua); 1044 finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua);
1143 finalResult.enterStore = info[0]; 1045 finalResult.enterStore = info[0];
1144 finalResult.isStudent = data.isStudent; 1046 finalResult.isStudent = data.isStudent;
1145 -  
1146 Object.assign(finalResult.feedbacks, info[2]); 1047 Object.assign(finalResult.feedbacks, info[2]);
  1048 + Object.assign(finalResult, {isSecKill: result.isSecKill});
1147 1049
1148 /* 如果有咨询,显示咨询,否则显示常见问题 */ 1050 /* 如果有咨询,显示咨询,否则显示常见问题 */
1149 1051
@@ -226,5 +226,7 @@ @@ -226,5 +226,7 @@
226 <input type="hidden" id="showPannel" value="1"> 226 <input type="hidden" id="showPannel" value="1">
227 {{/if}} 227 {{/if}}
228 228
  229 + <input type="hidden" id="isSecKill" value = "{{isSecKill}}">
  230 +
229 </div> 231 </div>
230 {{/ result}} 232 {{/ result}}
@@ -226,7 +226,11 @@ function updateConformButtonClassAndText() { @@ -226,7 +226,11 @@ function updateConformButtonClassAndText() {
226 } else { 226 } else {
227 $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车'); 227 $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车');
228 } 228 }
229 - $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '立即结算'); 229 + if ($chosed.closest('.zero-stock').length === 2) {
  230 + $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
  231 + } else {
  232 + $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '立即结算');
  233 + }
230 } 234 }
231 235
232 } 236 }
@@ -23,7 +23,7 @@ var dialog = require('../plugin/dialog'); @@ -23,7 +23,7 @@ var dialog = require('../plugin/dialog');
23 23
24 require('../common'); 24 require('../common');
25 25
26 -if (window.queryString.seckill) { 26 +if ($('#isSecKill').val() === 'Y') {
27 require('./tick'); 27 require('./tick');
28 } 28 }
29 29
@@ -5,8 +5,9 @@ @@ -5,8 +5,9 @@
5 */ 5 */
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 - tip = require('../plugin/tip'),  
9 - seckillObj = {}; 8 + tip = require('../plugin/tip');
  9 +
  10 +var seckillObj = {};
10 11
11 var timeObj = ''; 12 var timeObj = '';
12 13
@@ -25,6 +26,8 @@ var dateText = 0, @@ -25,6 +26,8 @@ var dateText = 0,
25 newHour = 0, 26 newHour = 0,
26 newMinus = 0; 27 newMinus = 0;
27 28
  29 +var skuFlag;
  30 +
28 require('../common'); 31 require('../common');
29 32
30 seckillObj = { 33 seckillObj = {
@@ -61,6 +64,7 @@ $( @@ -61,6 +64,7 @@ $(
61 $('.cart-bar').hide(); 64 $('.cart-bar').hide();
62 $('.current-price').hide(); 65 $('.current-price').hide();
63 var ajaxUrl = '/product/detail/seckillData/' + $('#productSkn').val(); 66 var ajaxUrl = '/product/detail/seckillData/' + $('#productSkn').val();
  67 +
64 $.ajax({ 68 $.ajax({
65 type: 'GET', 69 type: 'GET',
66 url: ajaxUrl, 70 url: ajaxUrl,
@@ -97,31 +101,27 @@ $( @@ -97,31 +101,27 @@ $(
97 101
98 // 秒杀进行中 102 // 秒杀进行中
99 if (data.status === 2) { 103 if (data.status === 2) {
100 - if (seckillNum == 0) {  
101 - var thisSkn = $('#productSkn').val();  
102 -  
103 - // window.location.href = '/product/show_' + thisSkn + '.html';  
104 - }  
105 $('.chose-panel .size-list').find('li[data-skuid != \'\']').each( 104 $('.chose-panel .size-list').find('li[data-skuid != \'\']').each(
106 function() { 105 function() {
107 - var skuFlag = 0; 106 + skuFlag = 0;
108 for (var i = 0; i < data.secKillSku.length; i++) { 107 for (var i = 0; i < data.secKillSku.length; i++) {
109 -  
110 - if (data.secKillSku[i].productSku == $(this).attr('data-skuid')) { 108 + if (data.secKillSku[i].productSku === $(this).attr('data-skuid')) {
111 skuFlag++; 109 skuFlag++;
112 } else { 110 } else {
113 111
114 // alert("没有匹配"); 112 // alert("没有匹配");
115 } 113 }
116 -  
117 } 114 }
118 if (skuFlag === 0) { 115 if (skuFlag === 0) {
119 - $(this).addClass('zero-stock'); 116 + $(this).addClass('zero-stock').attr('data-num', '0');
  117 + var oneIndex = $(this).index() + 1;
  118 + var twoIndex = $(this).parent('ul').index() - 2;
  119 +
  120 + $('.chose-panel .color-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').addClass('zero-stock');
120 } 121 }
121 } 122 }
122 ); 123 );
123 124
124 - // $("li[data-skuid=111]").addClass("zero-stock");  
125 $('.price-date').append( 125 $('.price-date').append(
126 '<div class="seckill-time seckill-time-border">' + 126 '<div class="seckill-time seckill-time-border">' +
127 '<span>距结束&nbsp</span>' + 127 '<span>距结束&nbsp</span>' +
@@ -153,6 +153,7 @@ $( @@ -153,6 +153,7 @@ $(
153 $('#chose-btn-sure').text('立即抢购').addClass('isSecKill'); 153 $('#chose-btn-sure').text('立即抢购').addClass('isSecKill');
154 $('.cart-bar').show(); 154 $('.cart-bar').show();
155 var seckillNum = 0; 155 var seckillNum = 0;
  156 +
156 for (var i = 0; i < data.secKillSku.length; i++) { 157 for (var i = 0; i < data.secKillSku.length; i++) {
157 seckillNum = seckillNum + data.secKillSku[i].storageNum; 158 seckillNum = seckillNum + data.secKillSku[i].storageNum;
158 } 159 }