index-legacy.58fddd8b.js 6.1 KB

1
  1. !function(){function t(t,e,n,r,i,c,a){try{var o=t[c](a),s=o.value}catch(u){return void n(u)}o.done?e(s):Promise.resolve(s).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,s,"next",e)}function s(e){t(a,i,c,o,s,"throw",e)}o(void 0)}))}}System.register(["./ResizeObserver.es-legacy.44b91b4c.js","./index-legacy.6ac2a941.js","./index.module-legacy.2b6ca4e3.js","./index-legacy.39123961.js","./index-legacy.23131301.js","./index-legacy.9b90921b.js","./index-legacy.4be048cf.js","./index-legacy.9d25098b.js","./index-legacy.1f288a46.js","./index-legacy.a203f53b.js","./cart-legacy.561f8e41.js","./icon-sell-out-legacy.ae9d997a.js","./shop-mall-legacy.8b9a3c37.js","./index-legacy.b257cee5.js"],(function(t){"use strict";var n,r,i,c,a,o,s,u,l,f,d,h,m,p,g,v,b,k,y,x,C,I;return{setters:[function(t){n=t.d,r=t.y,i=t.T,c=t.D,a=t.n,o=t.j,s=t.bC,u=t.C,l=t.A,f=t.F,d=t.$},function(t){h=t.C},function(t){m=t.s},function(t){p=t.C},function(){},function(t){g=t.S},function(t){v=t.I},function(){},function(t){b=t.C},function(t){k=t.S},function(t){y=t.f},function(t){x=t.i},function(t){C=t.g},function(t){I=t.C}],execute:function(){t("default",n({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,i,c;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,r.get("/api-mall-portal/cart/list");case 5:n=e.sent,i=n.code,c=n.data,200===i&&(t.cartList=c.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,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r.get("/api-mall-portal/cart/update/quantity",{params:{id:t.id,quantity:t.quantity}});case 3:n=e.sent,n.code,c=n.data,t.stock=c,t.quantity>c&&(t.quantity=c,setTimeout((function(){i("库存不足")}),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:c.confirm({message:"是否确认删除选中的商品?"}).then(e(regeneratorRuntime.mark((function e(){var n,i,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.selectItems.join(","),e.prev=1,e.next=4,r.post("/api-mall-portal/cart/delete?ids="+n);case 4:i=e.sent,c=i.code,i.data,200===c&&(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(){a({api:"back"})}},render:function(){var t,e,n=this;return o(f,null,[this.dataShow?o("div",null,[o(h,{onClickRight:function(){n.isManage=!n.isManage,n.isManage||n.cartList.forEach((function(t){t.stock<=0&&(n.selectItems=n.selectItems.filter((function(e){return e!=t.id})))}))}},{right:function(){return o("span",{style:{color:"#333",fontSize:"14px"}},[n.isManage?"完成":"管理"])}}),o("div",{class:m.cartBox},[this.cartList.length?o(I,{modelValue:this.selectItems,"onUpdate:modelValue":function(t){return n.selectItems=t}},(e=t=this.cartList.map((function(t){return o("div",{class:m.cartItem},[o(p,{name:t.id,disabled:t.stock<=0&&!n.isManage},{default:function(){return[o(b,{price:s(t.price),desc:y(t.productAttr),title:t.productName,thumb:t.productPic},{num:function(){return o(k,{modelValue:t.quantity,"onUpdate:modelValue":function(e){return t.quantity=e},onClick:function(t){t.stopPropagation()},onChange:function(){t.quantity&&n.setCartItem(t)},inputWidth:"50px",buttonSize:"24px",min:1,max:t.stock>200?200:t.stock,integer:!0},null)},thumb:function(){return o("div",null,[o(v,{src:t.productPic},null),t.stock<=0&&o("div",{class:m.sellOut},[o(v,{src:x,fit:"cover",class:m.sellOutImg},null)])])}})]}})])})),"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!d(e)?t:{default:function(){return[t]}})):null,!this.loading&&!this.cartList.length&&o(u,{tips:"购物车空空如也",buttonText:"去商城逛逛",onClick:function(){return n.gotoShopMall()}},null),o("div",{style:{height:"var(--van-submit-bar-height)"}},null),this.isManage?o("div",{class:m.delete},[o(g,{buttonText:"删除",buttonColor:"var(--van-primary)",disabled:0===this.len,onSubmit:function(){return n.onDeleteCartItem()}},{default:function(){return[o(p,{modelValue:n.checkAll,onClick:function(t){return n.setCheckAll()}},{default:function(){return[l("全选")]}})]}})]):o("div",{class:m.submit},[o(g,{price:this.totalPrice,buttonText:"结算(".concat(this.len,")"),buttonColor:"var(--van-primary)",disabled:0===this.len,onSubmit:function(){return n.generateConfirmOrder()}},{default:function(){return[o(p,{modelValue:n.checkAll,onClick:function(t){return n.setCheckAll()}},{default:function(){return[l("全选")]}})]}})])])]):null])}}))}}}))}();