1 |
- !function(){function t(t,e,n,r,c,i,a){try{var o=t[i](a),u=o.value}catch(s){return void n(s)}o.done?e(u):Promise.resolve(u).then(r,c)}function e(e){return function(){var n=this,r=arguments;return new Promise((function(c,i){var a=e.apply(n,r);function o(e){t(a,c,i,o,u,"next",e)}function u(e){t(a,c,i,o,u,"throw",e)}o(void 0)}))}}System.register(["./index-legacy.fba2875c.js","./index-legacy.e7460ea1.js","./index.module-legacy.2b6ca4e3.js","./index-legacy.45490234.js","./index-legacy.32d1c54d.js","./index-legacy.fc62badd.js","./index-legacy.d92f7da7.js","./index-legacy.78361179.js","./index-legacy.aa1e9cdc.js","./index-legacy.009d5444.js","./cart-legacy.df78b0a7.js","./icon-sell-out-legacy.ae9d997a.js","./shop-mall-legacy.73aea14c.js","./index-legacy.94e5c17b.js","./index-legacy.40eca993.js","./use-height-legacy.233a2ec8.js"],(function(t){"use strict";var n,r,c,i,a,o,u,s,l,f,d,h,m,p,g,v,y,k,x,b,C,j;return{setters:[function(t){n=t.d,r=t.w,c=t.T,i=t.D,a=t.n,o=t.j,u=t.by,s=t.C,l=t.z,f=t.F,d=t.Z},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){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){j=t.C},function(){},function(){}],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,c,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,r.get("/api-mall-portal/cart/list");case 5:n=e.sent,c=n.code,i=n.data,200===c&&(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,i;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,i=n.data,t.stock=i,t.quantity>i&&(t.quantity=i,setTimeout((function(){c("库存不足")}),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:i.confirm({message:"是否确认删除选中的商品?"}).then(e(regeneratorRuntime.mark((function e(){var n,c,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,r.post("/api-mall-portal/cart/delete?ids="+n);case 4:c=e.sent,i=c.code,c.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(){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(j,{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(y,{price:u(t.price),desc:x(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:b,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(s,{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])}}))}}}))}();
|