Authored by 邱骏

新增一个参数modeType

@@ -85,6 +85,7 @@ const select = (req, res, next) => { @@ -85,6 +85,7 @@ const select = (req, res, next) => {
85 let shoppingKey = req.cookies._SPK || '', 85 let shoppingKey = req.cookies._SPK || '',
86 uid = req.user && req.user.uid; 86 uid = req.user && req.user.uid;
87 let skuList = req.body.skuList, 87 let skuList = req.body.skuList,
  88 + modeType = req.body.modeType,
88 cartType = req.cookies.cartType || 'ordinary'; 89 cartType = req.cookies.cartType || 'ordinary';
89 90
90 if (!skuList || !skuList.length) { 91 if (!skuList || !skuList.length) {
@@ -97,7 +98,7 @@ const select = (req, res, next) => { @@ -97,7 +98,7 @@ const select = (req, res, next) => {
97 // shoppingKey = 'dc9d09e2ffd8607f2cfd8b9c95962923'; 98 // shoppingKey = 'dc9d09e2ffd8607f2cfd8b9c95962923';
98 // uid = 20422448; 99 // uid = 20422448;
99 100
100 - return req.ctx(cartModel).selectGood(uid, skuList, shoppingKey, cartType).then(data => { 101 + return req.ctx(cartModel).selectGood(uid, skuList, shoppingKey, cartType, modeType).then(data => {
101 if (data) { 102 if (data) {
102 if (data.code !== 500) { 103 if (data.code !== 500) {
103 res.json({ 104 res.json({
@@ -38,15 +38,17 @@ class cartModel extends global.yoho.BaseModel { @@ -38,15 +38,17 @@ class cartModel extends global.yoho.BaseModel {
38 * @param int $uid 用户ID 38 * @param int $uid 用户ID
39 * @param string $sku 商品sku列表 39 * @param string $sku 商品sku列表
40 * @param string $shoppingKey 未登录用户唯一识别码 40 * @param string $shoppingKey 未登录用户唯一识别码
  41 + * @param modeType 新增参数 0或者不传表示普通模式,1表示编辑模式,编辑模式接口不返回500错误
41 * @return array 购物车接口返回的数据 42 * @return array 购物车接口返回的数据
42 */ 43 */
43 - selectGood(uid, sku, shoppingKey, cartType) { 44 + selectGood(uid, sku, shoppingKey, cartType, modeType) {
44 return this.get({data: { 45 return this.get({data: {
45 method: 'app.Shopping.selectedAndQryCart', 46 method: 'app.Shopping.selectedAndQryCart',
46 product_sku_list: sku, 47 product_sku_list: sku,
47 uid: uid, 48 uid: uid,
48 shopping_key: shoppingKey, 49 shopping_key: shoppingKey,
49 - is_support_mlp: 'Y' 50 + is_support_mlp: 'Y',
  51 + mode_type: modeType ? modeType : 0
50 }}).then((data) => { 52 }}).then((data) => {
51 if (data.code === 200) { 53 if (data.code === 200) {
52 return cartProcess.processData(data, cartType); 54 return cartProcess.processData(data, cartType);
@@ -10,6 +10,7 @@ let $ = require('yoho-jquery'), @@ -10,6 +10,7 @@ let $ = require('yoho-jquery'),
10 tip = require('js/plugin/tip'), 10 tip = require('js/plugin/tip'),
11 chosePanel = require('js/common/chose-panel-new'), 11 chosePanel = require('js/common/chose-panel-new'),
12 loading = require('js/plugin/loading'), 12 loading = require('js/plugin/loading'),
  13 + isModify = false,
13 dialog = require('js/plugin/dialog'); 14 dialog = require('js/plugin/dialog');
14 15
15 let goodObj = { 16 let goodObj = {
@@ -198,6 +199,7 @@ let goodObj = { @@ -198,6 +199,7 @@ let goodObj = {
198 return; 199 return;
199 } 200 }
200 self.handle.posting = true; 201 self.handle.posting = true;
  202 + let modeType = isModify ? 1 : 0;
201 let skuData = self.getSelectGoodData(eles, selectAll); 203 let skuData = self.getSelectGoodData(eles, selectAll);
202 204
203 205
@@ -206,7 +208,8 @@ let goodObj = { @@ -206,7 +208,8 @@ let goodObj = {
206 type: 'post', 208 type: 'post',
207 url: '/cart/index/new/select', 209 url: '/cart/index/new/select',
208 data: { 210 data: {
209 - skuList: JSON.stringify(skuData) 211 + skuList: JSON.stringify(skuData),
  212 + modeType: modeType
210 }, 213 },
211 complete: () => { 214 complete: () => {
212 self.handle.posting = false; 215 self.handle.posting = false;
@@ -334,7 +337,7 @@ let goodObj = { @@ -334,7 +337,7 @@ let goodObj = {
334 } else { 337 } else {
335 goodInfo.selected = $this.hasClass('checked') ? 'N' : 'Y'; 338 goodInfo.selected = $this.hasClass('checked') ? 'N' : 'Y';
336 } 339 }
337 - if ($this.hasClass('presale')) { 340 + if ($this.hasClass('presale') && isModify) {
338 goodInfo.selected = 'N'; 341 goodInfo.selected = 'N';
339 } 342 }
340 goodInfo.product_sku = id; 343 goodInfo.product_sku = id;
@@ -350,6 +353,7 @@ let goodObj = { @@ -350,6 +353,7 @@ let goodObj = {
350 if (batch_no) { 353 if (batch_no) {
351 goodInfo.batch_no = batch_no; 354 goodInfo.batch_no = batch_no;
352 } 355 }
  356 + isModify = false;
353 return goodInfo; 357 return goodInfo;
354 })); 358 }));
355 359
@@ -396,6 +400,7 @@ let goodObj = { @@ -396,6 +400,7 @@ let goodObj = {
396 }).done(function(res) { 400 }).done(function(res) {
397 if (res && res.code === 200) { 401 if (res && res.code === 200) {
398 $(e.delegateTarget).data('id', result.sku.skuId); 402 $(e.delegateTarget).data('id', result.sku.skuId);
  403 + isModify = true;
399 if (!$(e.delegateTarget).find('.chk.select').hasClass('checked')) { 404 if (!$(e.delegateTarget).find('.chk.select').hasClass('checked')) {
400 self.selectGood($(e.delegateTarget).find('.chk.select')); 405 self.selectGood($(e.delegateTarget).find('.chk.select'));
401 } else { 406 } else {
@@ -475,6 +480,7 @@ let goodObj = { @@ -475,6 +480,7 @@ let goodObj = {
475 goodNum = parseInt($(e.delegateTarget).find('.good-num').val(), 10); 480 goodNum = parseInt($(e.delegateTarget).find('.good-num').val(), 10);
476 let max = parseInt($(e.delegateTarget).find('.good-num').data('max'), 10); 481 let max = parseInt($(e.delegateTarget).find('.good-num').data('max'), 10);
477 482
  483 + isModify = true;
478 if (!$(e.delegateTarget).find('.chk.select').hasClass('checked') && goodNum <= max) { 484 if (!$(e.delegateTarget).find('.chk.select').hasClass('checked') && goodNum <= max) {
479 self.handle.posting = false; 485 self.handle.posting = false;
480 self.selectGood($(e.delegateTarget).find('.chk.select')); 486 self.selectGood($(e.delegateTarget).find('.chk.select'));