1234567891011121314 |
- ;(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;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var __vite_style__=document.createElement('style');__vite_style__.innerHTML="._addGoodsCart_17hfd_1{padding-top:.32rem;--van-stepper-button-round-theme-color: var(--van-primary)}._addGoodsCart_17hfd_1 .van-stepper__input{background:#f7f8f9!important;border-radius:.16rem;margin:0 .21333rem}._addGoodsCart_17hfd_1 .van-stepper__minus--disabled{opacity:.6!important;color:#333!important;background:#f7f8f9!important;border-color:#f7f8f9!important}._goodsSection_17hfd_16{position:relative;width:2.66667rem;height:2.66667rem;border-radius:.21333rem;overflow:hidden}._goodsSection_17hfd_16 ._sellOut_17hfd_23{display:flex;align-items:center;justify-content:center;position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.2);padding:.53333rem}._goodsImg_17hfd_35{width:2.66667rem;height:2.66667rem;background:linear-gradient(180deg,#f0f0f0 0%,#d7d7d7 100%);overflow:hidden}._goodsPrice_17hfd_41{padding-top:.21333rem;font-size:.48rem;color:#ff4e19;line-height:.58667rem}._goodsPrice_17hfd_41 span{font-size:.42667rem}._goodsStore_17hfd_50{font-size:.37333rem;color:#999;line-height:.53333rem}._title_17hfd_55{font-size:.42667rem;color:#333;line-height:.58667rem}._radio-group_17hfd_60{display:flex;flex-wrap:wrap;margin-top:.37333rem}._radio_17hfd_60{margin-right:.26667rem;margin-bottom:.21333rem}._radio_17hfd_60 .van-radio__icon{display:none}._radio_17hfd_60 .van-tag--large{height:.85333rem;font-size:.42667rem;text-align:center;display:flex;align-items:center;justify-content:center}._radio_17hfd_60 .van-tag{box-sizing:border-box}._radio_17hfd_60 .van-tag--default{color:#999}._radio_17hfd_60 .van-tag--primary{background-color:#f7f8f9}._radio_17hfd_60 .van-radio__label{margin-left:0}\n";document.head.appendChild(__vite_style__);System.register(['./index-legacy.4b2d517a.js','./vendor-legacy.73abbe39.js','./index-legacy.f25f109a2.js','./index-legacy.f25f109a4.js','./index-legacy.637f35563.js','./index-legacy.f25f109a8.js','./index-legacy.0533982c.js','./index-legacy.f25f109a9.js','./shop-mall-legacy.9b596ca0.js'],function(exports){'use strict';var request,moneyFormat,defineComponent,Toast,createVNode,Cell,Image,createTextVNode,RadioGroup,Radio,Tag,isVNode,Stepper,Button,iconSellOut,getCartCount;return{setters:[function(module){request=module.r;moneyFormat=module.m;},function(module){defineComponent=module.d;Toast=module.T;createVNode=module.b;Cell=module.p;Image=module.I;createTextVNode=module.j;RadioGroup=module.H;Radio=module.J;Tag=module.X;isVNode=module.v;Stepper=module.Y;Button=module.B;},function(){},function(){},function(){},function(){},function(module){iconSellOut=module.i;},function(){},function(module){getCartCount=module.g;}],execute:function execute(){var addGoodsCart="_addGoodsCart_17hfd_1";var goodsSection="_goodsSection_17hfd_16";var sellOut="_sellOut_17hfd_23";var goodsImg="_goodsImg_17hfd_35";var goodsPrice="_goodsPrice_17hfd_41";var goodsStore="_goodsStore_17hfd_50";var title="_title_17hfd_55";var radio="_radio_17hfd_60";var styles={addGoodsCart:addGoodsCart,goodsSection:goodsSection,sellOut:sellOut,goodsImg:goodsImg,goodsPrice:goodsPrice,goodsStore:goodsStore,title:title,"radio-group":"_radio-group_17hfd_60",radio:radio};function _isSlot(s){return typeof s==='function'||Object.prototype.toString.call(s)==='[object Object]'&&!isVNode(s);}var AddGoodsCart=exports('A',defineComponent({name:'add-goods-cart',props:{show:{type:Boolean,default:false},item:{type:Object,default:{}},defaultRadio:{type:Number,default:0},showType:{type:String,default:'cart'},onGetCartCount:{type:Function,default:function _default(n){}}},watch:{show:function show(val){// 添加购物车显示
- if(val){this.totalData={};this.total=1;this.radio='';this.setList();}}},data:function data(){return{radio:'',total:1,totalData:{},skuStockList:[]};},computed:{selectItem:function selectItem(){var radio=this.radio;var select=this.skuStockList.find(function(n){return n.id==radio;});if(select){var stock=select.stock-select.lockStock;//- select.cartNum
- return _objectSpread(_objectSpread({},select),{},{stock:stock});}return{stock:0};}},mounted:function mounted(){this.setList();},methods:{setList:function setList(){var _this=this;// 处理规格
- var skuStockList=[];var item=JSON.parse(JSON.stringify(this.item));if(Array.isArray(item.skuStockList)){skuStockList=item.skuStockList.map(function(n){n.pic=n.pic||item.pic;n.cartNum=0;if(n.spData){var spData=JSON.parse(n.spData);var str='';spData.forEach(function(sp){str+="".concat(sp.value);});n.spDataJson=str;}else{n.spDataJson='默认';}n.lockStock=n.lockStock>0?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<this.skuStockList.length;i++){if(this.skuStockList[i].id===this.radio){this.skuStockList[i].cartNum=n;}}}},render:function render(){var _this4=this;return createVNode("div",{"class":styles.addGoodsCart},[createVNode(Cell,{"titleStyle":{paddingLeft:'12px'}},{icon:function icon(){return createVNode("div",{"class":styles.goodsSection},[createVNode(Image,{"src":_this4.selectItem.pic,"class":styles.goodsImg,"fit":"cover"},null),_this4.selectItem.stock<=0&&createVNode("div",{"class":styles.sellOut},[createVNode(Image,{"src":iconSellOut,"fit":"cover","class":styles.sellOutImg},null)])]);},title:function title(){return createVNode("div",{"class":styles.goodsInfo},[createVNode("p",{"class":styles.goodsPrice},[createVNode("span",null,[createTextVNode("\uFFE5")]),moneyFormat(_this4.selectItem.price)]),createVNode("p",{"class":styles.goodsStore},[createTextVNode("\u5E93\u5B58\uFF1A"),_this4.selectItem.stock])]);}}),createVNode(Cell,null,{title:function title(){return createVNode("div",{"class":styles.title},[createTextVNode("\u89C4\u683C")]);},label:function label(){var _slot;return createVNode(RadioGroup,{"class":styles['radio-group'],"modelValue":_this4.radio},_isSlot(_slot=_this4.skuStockList.map(function(item){var isActive=item.id===_this4.radio;var type=isActive?'primary':'default';return createVNode(Radio,{"class":styles.radio,"name":item.id,"onClick":function onClick(){if(_this4.radio==item.id)return;_this4.radio=item.id;// this.getProductAddCartCount(item.id)
- }},{default:function _default(){return[createVNode(Tag,{"size":"large","plain":isActive,"type":type},{default:function _default(){return[item.spDataJson];}})];}});}))?_slot:{default:function _default(){return[_slot];}});}}),createVNode(Cell,{"title":"购买数量","style":{margin:'12px 0'},"border":false,"titleClass":styles.title,"center":true},{default:function _default(){return[createVNode(Stepper,{"modelValue":_this4.total,"onUpdate:modelValue":function onUpdateModelValue($event){return _this4.total=$event;},"inputWidth":"50px","theme":"round","buttonSize":"24px","max":_this4.selectItem.stock>200?200:_this4.selectItem.stock,"min":1,"disabled":_this4.selectItem.stock<=0,"integer":true},null)];}}),createVNode("div",{"class":['btnGroup'],"style":{marginBottom:'8px'}},[createVNode(Button,{"block":true,"round":true,"type":"primary","text":"确定","disabled":this.selectItem.stock<=0,"onClick":function onClick(){return _this4.onAddCart();}},null)])]);}}));}};});})();
|