index-legacy.92a99538.js 6.2 KB

1
  1. !function(){function t(t,e,n,r,i,c,a){try{var o=t[c](a),u=o.value}catch(s){return void n(s)}o.done?e(u):Promise.resolve(u).then(r,i)}function e(e){return function(){var n=this,r=arguments;return new Promise((function(i,c){var a=e.apply(n,r);function o(e){t(a,i,c,o,u,"next",e)}function u(e){t(a,i,c,o,u,"throw",e)}o(void 0)}))}}System.register(["./index-legacy.81a64bb6.js","./index.module-legacy.2b6ca4e3.js","./index-legacy.b2528a15.js","./index-legacy.987f23f1.js","./index-legacy.7d3d7cf1.js","./index-legacy.da3785ef.js","./index-legacy.ca42ae97.js","./index-legacy.edff980f.js","./index-legacy.bf813766.js","./index-legacy.7755cfa7.js","./cart-legacy.446e099c.js","./icon-sell-out-legacy.ae9d997a.js","./shop-mall-legacy.cc5cb0f7.js","./index-legacy.a493c461.js","./index-legacy.f75b8290.js","./use-height-legacy.2a153aaf.js"],(function(t){"use strict";var n,r,i,c,a,o,u,s,l,f,d,h,m,p,g,v,y,k,x,b,C,I;return{setters:[function(t){n=t.C},function(t){r=t.s},function(t){i=t.d,c=t.e,a=t.T,o=t.D,u=t.p,s=t.i,l=t.by,f=t.C,d=t.A,h=t.F,m=t.$},function(t){p=t.C},function(){},function(t){g=t.S},function(t){v=t.I},function(){},function(t){y=t.C},function(t){k=t.S},function(t){x=t.f},function(t){b=t.i},function(t){C=t.g},function(t){I=t.C},function(){},function(){}],execute:function(){t("default",i({name:"cart",data:function(){return{loading:!0,dataShow:!1,isManage:!1,cartList:[],selectItems:[]}},computed:{checkAll:function(){var t=this.selectItems.length,e=this.cartList.length;return!!e&&t===e},len:function(){return this.selectItems.length},totalPrice:function(){var t=0,e=this.selectItems;return this.cartList.forEach((function(n){e.includes(n.id)&&"number"==typeof n.price&&(t+=n.price*n.quantity)})),100*t}},mounted:function(){this.getCartList()},methods:{getCartList:function(){var t=this;return e(regeneratorRuntime.mark((function e(){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.loading=!0,t.cartList=[],e.prev=2,e.next=5,c.get("/api-mall-portal/cart/list");case 5:n=e.sent,r=n.code,i=n.data,200===r&&(t.cartList=i.map((function(t){return t.stock=t.stock-t.lockStock,t.stock=t.stock<=0?0:t.stock,t}))),e.next=13;break;case 11:e.prev=11,e.t0=e.catch(2);case 13:t.dataShow=!0,t.loading=!1;case 15:case"end":return e.stop()}}),e,null,[[2,11]])})))()},setCheckAll:function(){var t=this,e=[];this.checkAll||this.cartList.forEach((function(n){(t.isManage||n.stock>0)&&e.push(n.id)})),this.selectItems=e},setCartItem:function(t){return e(regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c.get("/api-mall-portal/cart/update/quantity",{params:{id:t.id,quantity:t.quantity}});case 3:n=e.sent,n.code,r=n.data,t.stock=r,t.quantity>r&&(t.quantity=r,setTimeout((function(){a("库存不足")}),500)),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(0);case 12:case"end":return e.stop()}}),e,null,[[0,10]])})))()},onChecked:function(t){var e=this.selectItems;e.includes(t)?e.splice(e.indexOf(t),1):e.push(t),this.selectItems=e},onDeleteCartItem:function(){var t=this;return e(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:o.confirm({message:"是否确认删除选中的商品?"}).then(e(regeneratorRuntime.mark((function e(){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.selectItems.join(","),e.prev=1,e.next=4,c.post("/api-mall-portal/cart/delete?ids="+n);case 4:r=e.sent,i=r.code,r.data,200===i&&(t.getCartList(),t.selectItems=[],t.isManage=!1,C()),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(1);case 12:case"end":return e.stop()}}),e,null,[[1,10]])}))));case 1:case"end":return n.stop()}}),n)})))()},generateConfirmOrder:function(){var t=this;return e(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.$router.push({path:"/cartConfirm",query:{cartIds:t.selectItems.join(",")}});case 1:case"end":return e.stop()}}),e)})))()},gotoShopMall:function(){u({api:"back"})}},render:function(){var t,e,i=this;return s(h,null,[this.dataShow?s("div",null,[s(n,{onClickRight:function(){i.isManage=!i.isManage,i.isManage||i.cartList.forEach((function(t){t.stock<=0&&(i.selectItems=i.selectItems.filter((function(e){return e!=t.id})))}))}},{right:function(){return s("span",{style:{color:"#333",fontSize:"14px"}},[i.isManage?"完成":"管理"])}}),s("div",{class:r.cartBox},[this.cartList.length?s(I,{modelValue:this.selectItems,"onUpdate:modelValue":function(t){return i.selectItems=t}},(e=t=this.cartList.map((function(t){return s("div",{class:r.cartItem},[s(p,{name:t.id,disabled:t.stock<=0&&!i.isManage},{default:function(){return[s(y,{price:l(t.price),desc:x(t.productAttr),title:t.productName,thumb:t.productPic},{num:function(){return s(k,{modelValue:t.quantity,"onUpdate:modelValue":function(e){return t.quantity=e},onClick:function(t){t.stopPropagation()},onChange:function(){t.quantity&&i.setCartItem(t)},inputWidth:"50px",buttonSize:"24px",min:1,max:t.stock>200?200:t.stock,integer:!0},null)},thumb:function(){return s("div",null,[s(v,{src:t.productPic},null),t.stock<=0&&s("div",{class:r.sellOut},[s(v,{src:b,fit:"cover",class:r.sellOutImg},null)])])}})]}})])})),"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!m(e)?t:{default:function(){return[t]}})):null,!this.loading&&!this.cartList.length&&s(f,{tips:"购物车空空如也",buttonText:"去商城逛逛",onClick:function(){return i.gotoShopMall()}},null),s("div",{style:{height:"var(--van-submit-bar-height)"}},null),this.isManage?s("div",{class:r.delete},[s(g,{buttonText:"删除",buttonColor:"var(--van-primary)",disabled:0===this.len,onSubmit:function(){return i.onDeleteCartItem()}},{default:function(){return[s(p,{modelValue:i.checkAll,onClick:function(t){return i.setCheckAll()}},{default:function(){return[d("全选")]}})]}})]):s("div",{class:r.submit},[s(g,{price:this.totalPrice,buttonText:"结算(".concat(this.len,")"),buttonColor:"var(--van-primary)",disabled:0===this.len,onSubmit:function(){return i.generateConfirmOrder()}},{default:function(){return[s(p,{modelValue:i.checkAll,onClick:function(t){return i.setCheckAll()}},{default:function(){return[d("全选")]}})]}})])])]):null])}}))}}}))}();