Authored by 邱骏

新增一个参数modeType

... ... @@ -85,6 +85,7 @@ const select = (req, res, next) => {
let shoppingKey = req.cookies._SPK || '',
uid = req.user && req.user.uid;
let skuList = req.body.skuList,
modeType = req.body.modeType,
cartType = req.cookies.cartType || 'ordinary';
if (!skuList || !skuList.length) {
... ... @@ -97,7 +98,7 @@ const select = (req, res, next) => {
// shoppingKey = 'dc9d09e2ffd8607f2cfd8b9c95962923';
// uid = 20422448;
return req.ctx(cartModel).selectGood(uid, skuList, shoppingKey, cartType).then(data => {
return req.ctx(cartModel).selectGood(uid, skuList, shoppingKey, cartType, modeType).then(data => {
if (data) {
if (data.code !== 500) {
res.json({
... ...
... ... @@ -38,15 +38,17 @@ class cartModel extends global.yoho.BaseModel {
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @param modeType 新增参数 0或者不传表示普通模式,1表示编辑模式,编辑模式接口不返回500错误
* @return array 购物车接口返回的数据
*/
selectGood(uid, sku, shoppingKey, cartType) {
selectGood(uid, sku, shoppingKey, cartType, modeType) {
return this.get({data: {
method: 'app.Shopping.selectedAndQryCart',
product_sku_list: sku,
uid: uid,
shopping_key: shoppingKey,
is_support_mlp: 'Y'
is_support_mlp: 'Y',
mode_type: modeType ? modeType : 0
}}).then((data) => {
if (data.code === 200) {
return cartProcess.processData(data, cartType);
... ...
... ... @@ -10,6 +10,7 @@ let $ = require('yoho-jquery'),
tip = require('js/plugin/tip'),
chosePanel = require('js/common/chose-panel-new'),
loading = require('js/plugin/loading'),
isModify = false,
dialog = require('js/plugin/dialog');
let goodObj = {
... ... @@ -198,6 +199,7 @@ let goodObj = {
return;
}
self.handle.posting = true;
let modeType = isModify ? 1 : 0;
let skuData = self.getSelectGoodData(eles, selectAll);
... ... @@ -206,7 +208,8 @@ let goodObj = {
type: 'post',
url: '/cart/index/new/select',
data: {
skuList: JSON.stringify(skuData)
skuList: JSON.stringify(skuData),
modeType: modeType
},
complete: () => {
self.handle.posting = false;
... ... @@ -334,7 +337,7 @@ let goodObj = {
} else {
goodInfo.selected = $this.hasClass('checked') ? 'N' : 'Y';
}
if ($this.hasClass('presale')) {
if ($this.hasClass('presale') && isModify) {
goodInfo.selected = 'N';
}
goodInfo.product_sku = id;
... ... @@ -350,6 +353,7 @@ let goodObj = {
if (batch_no) {
goodInfo.batch_no = batch_no;
}
isModify = false;
return goodInfo;
}));
... ... @@ -396,6 +400,7 @@ let goodObj = {
}).done(function(res) {
if (res && res.code === 200) {
$(e.delegateTarget).data('id', result.sku.skuId);
isModify = true;
if (!$(e.delegateTarget).find('.chk.select').hasClass('checked')) {
self.selectGood($(e.delegateTarget).find('.chk.select'));
} else {
... ... @@ -475,6 +480,7 @@ let goodObj = {
goodNum = parseInt($(e.delegateTarget).find('.good-num').val(), 10);
let max = parseInt($(e.delegateTarget).find('.good-num').data('max'), 10);
isModify = true;
if (!$(e.delegateTarget).find('.chk.select').hasClass('checked') && goodNum <= max) {
self.handle.posting = false;
self.selectGood($(e.delegateTarget).find('.chk.select'));
... ...