;(function(){function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i0?n.lockStock:0;return _objectSpread({},n);});}if(!skuStockList.length)return skuStockList;// 处理默认显示 var index=0;if(this.defaultRadio){var i=skuStockList.findIndex(function(n){return n.id==_this.defaultRadio;});index=i>-1?i:0;}this.radio=skuStockList[index].id;this.skuStockList=skuStockList;// this.getProductAddCartCount(skuStockList[index].id) },onAddCart:function onAddCart(){var _this2=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(){var selectItem,item,body,_yield$request$post,code,data;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:selectItem=_this2.selectItem;item=_this2.item;body={price:selectItem.price,//添加到购物车的价格 productSkuId:selectItem.id,quantity:_this2.total,// 数量 productId:item.id,hidden:_this2.showType==='cart'?0:1,promoterId:_this2.$route.query.promoterId?_this2.$route.query.promoterId:undefined};// console.log(body) _context.prev=3;_context.next=6;return request.post('/api-mall-portal/cart/add',{data:body});case 6:_yield$request$post=_context.sent;code=_yield$request$post.code;data=_yield$request$post.data;if(code===200){// this.getProductAddCartCount(selectItem.id, true) if(_this2.showType==='cart'){_this2.onGetCartCount();_this2.$nextTick(function(){setTimeout(function(){Toast({icon:'success',message:'添加商品成功'});},500);});}else{_this2.$router.push({path:'/cartConfirm',query:{cartIds:data.id}});}getCartCount();}_context.next=14;break;case 12:_context.prev=12;_context.t0=_context["catch"](3);case 14:case"end":return _context.stop();}}},_callee,null,[[3,12]]);}))();},// 获取购物车当前产品的数量 getProductAddCartCount:function getProductAddCartCount(id){var _arguments=arguments,_this3=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee2(){var isRest,res;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:isRest=_arguments.length>1&&_arguments[1]!==undefined?_arguments[1]:false;id=id?id:_this3.selectItem.id;if(!(_this3.totalData.hasOwnProperty(id)&&!isRest)){_context2.next=5;break;}_this3.setProductStock(_this3.totalData[id]);return _context2.abrupt("return");case 5:if(id){_context2.next=7;break;}return _context2.abrupt("return");case 7:_context2.prev=7;_context2.next=10;return request.get("/api-mall-portal/product/cart/".concat(id));case 10:res=_context2.sent;_this3.setProductStock(res.data||0);_this3.totalData[id]=res.data||0;_context2.next=17;break;case 15:_context2.prev=15;_context2.t0=_context2["catch"](7);case 17:case"end":return _context2.stop();}}},_callee2,null,[[7,15]]);}))();},// 更新产品规格的库存 setProductStock:function setProductStock(n){// 根据当前用户的购物车,当前产品规格的数量,限制库存 for(var i=0;i