index-legacy.2abaa616.js 7.9 KB

1
  1. !function(){function t(t,e,r,o,n,i,a){try{var c=t[i](a),d=c.value}catch(s){return void r(s)}c.done?e(d):Promise.resolve(d).then(o,n)}function e(e){return function(){var r=this,o=arguments;return new Promise((function(n,i){var a=e.apply(r,o);function c(e){t(a,n,i,c,d,"next",e)}function d(e){t(a,n,i,c,d,"throw",e)}c(void 0)}))}}function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function o(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?r(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var i=document.createElement("style");i.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(i),System.register(["./index-legacy.fba2875c.js","./index-legacy.7dcec7b3.js","./index-legacy.d92f7da7.js","./index-legacy.23cbc114.js","./index-legacy.32d1c54d.js","./index-legacy.009d5444.js","./index-legacy.78361179.js","./icon-sell-out-legacy.ae9d997a.js","./shop-mall-legacy.73aea14c.js"],(function(t){"use strict";var r,n,i,a,c,d,s,u,l,f,p,m,g,h,_,v;return{setters:[function(t){r=t.d,n=t.w,i=t.T,a=t.j,c=t.z,d=t.by,s=t.B,u=t.Z},function(t){l=t.C},function(t){f=t.I},function(t){p=t.R,m=t.a},function(){},function(t){g=t.S},function(t){h=t.T},function(t){_=t.i},function(t){v=t.g}],execute:function(){var y={addGoodsCart:"_addGoodsCart_17hfd_1",goodsSection:"_goodsSection_17hfd_16",sellOut:"_sellOut_17hfd_23",goodsImg:"_goodsImg_17hfd_35",goodsPrice:"_goodsPrice_17hfd_41",goodsStore:"_goodsStore_17hfd_50",title:"_title_17hfd_55","radio-group":"_radio-group_17hfd_60",radio:"_radio_17hfd_60"};t("A",r({name:"add-goods-cart",props:{show:{type:Boolean,default:!1},item:{type:Object,default:{}},defaultRadio:{type:Number,default:0},showType:{type:String,default:"cart"},onGetCartCount:{type:Function,default:function(t){}}},watch:{show:function(t){t&&(this.totalData={},this.total=1,this.radio="",this.setList())}},data:function(){return{radio:"",total:1,totalData:{},skuStockList:[]}},computed:{selectItem:function(){var t=this.radio,e=this.skuStockList.find((function(e){return e.id==t}));if(e){var r=e.stock-e.lockStock;return o(o({},e),{},{stock:r})}return{stock:0}}},mounted:function(){this.setList()},methods:{setList:function(){var t=this,e=[],r=JSON.parse(JSON.stringify(this.item));if(Array.isArray(r.skuStockList)&&(e=r.skuStockList.map((function(t){if(t.pic=t.pic||r.pic,t.cartNum=0,t.spData){var e=JSON.parse(t.spData),n="";e.forEach((function(t){n+="".concat(t.value)})),t.spDataJson=n}else t.spDataJson="默认";return t.lockStock=t.lockStock>0?t.lockStock:0,o({},t)}))),!e.length)return e;var n=0;if(this.defaultRadio){var i=e.findIndex((function(e){return e.id==t.defaultRadio}));n=i>-1?i:0}this.radio=e[n].id,this.skuStockList=e},onAddCart:function(){var t=this;return e(regeneratorRuntime.mark((function e(){var r,o,a,c,d,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.selectItem,o=t.item,a={price:r.price,productSkuId:r.id,quantity:t.total,productId:o.id,hidden:"cart"===t.showType?0:1,promoterId:t.$route.query.promoterId?t.$route.query.promoterId:void 0},e.prev=3,e.next=6,n.post("/api-mall-portal/cart/add",{data:a});case 6:c=e.sent,d=c.code,s=c.data,200===d&&("cart"===t.showType?(t.onGetCartCount(),t.$nextTick((function(){setTimeout((function(){i({icon:"success",message:"添加商品成功"})}),500)}))):t.$router.push({path:"/cartConfirm",query:{cartIds:s.id}}),v()),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(3);case 14:case"end":return e.stop()}}),e,null,[[3,12]])})))()},getProductAddCartCount:function(t){var r=arguments,o=this;return e(regeneratorRuntime.mark((function e(){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.length>1&&void 0!==r[1]&&r[1],t=t||o.selectItem.id,!o.totalData.hasOwnProperty(t)||i){e.next=5;break}return o.setProductStock(o.totalData[t]),e.abrupt("return");case 5:if(t){e.next=7;break}return e.abrupt("return");case 7:return e.prev=7,e.next=10,n.get("/api-mall-portal/product/cart/".concat(t));case 10:a=e.sent,o.setProductStock(a.data||0),o.totalData[t]=a.data||0,e.next=17;break;case 15:e.prev=15,e.t0=e.catch(7);case 17:case"end":return e.stop()}}),e,null,[[7,15]])})))()},setProductStock:function(t){for(var e=0;e<this.skuStockList.length;e++)this.skuStockList[e].id===this.radio&&(this.skuStockList[e].cartNum=t)}},render:function(){var t=this;return a("div",{class:y.addGoodsCart},[a(l,{titleStyle:{paddingLeft:"12px"}},{icon:function(){return a("div",{class:y.goodsSection},[a(f,{src:t.selectItem.pic,class:y.goodsImg,fit:"cover"},null),t.selectItem.stock<=0&&a("div",{class:y.sellOut},[a(f,{src:_,fit:"cover",class:y.sellOutImg},null)])])},title:function(){return a("div",{class:y.goodsInfo},[a("p",{class:y.goodsPrice},[a("span",null,[c("¥")]),d(t.selectItem.price)]),a("p",{class:y.goodsStore},[c("库存:"),t.selectItem.stock])])}}),a(l,null,{title:function(){return a("div",{class:y.title},[c("规格")])},label:function(){var e,r;return a(p,{class:y["radio-group"],modelValue:t.radio},"function"==typeof(r=e=t.skuStockList.map((function(e){var r=e.id===t.radio,o=r?"primary":"default";return a(m,{class:y.radio,name:e.id,onClick:function(){t.radio!=e.id&&(t.radio=e.id)}},{default:function(){return[a(h,{size:"large",plain:r,type:o},{default:function(){return[e.spDataJson]}})]}})})))||"[object Object]"===Object.prototype.toString.call(r)&&!u(r)?e:{default:function(){return[e]}})}}),a(l,{title:"购买数量",style:{margin:"12px 0"},border:!1,titleClass:y.title,center:!0},{default:function(){return[a(g,{modelValue:t.total,"onUpdate:modelValue":function(e){return t.total=e},inputWidth:"50px",theme:"round",buttonSize:"24px",max:t.selectItem.stock>200?200:t.selectItem.stock,min:1,disabled:t.selectItem.stock<=0,integer:!0},null)]}}),a("div",{class:["btnGroup"],style:{marginBottom:"8px"}},[a(s,{block:!0,round:!0,type:"primary",text:"确定",disabled:this.selectItem.stock<=0,onClick:function(){return t.onAddCart()}},null)])])}}))}}}))}();