(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-32789f42"],{"36b0":function(t,e,s){},"8a08":function(t,e,s){"use strict";s.r(e);var i=function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticClass:"cart"},[t.cartList.length||t.invalidGoods.length?[s("nav",[s("li",[s("el-checkbox",{on:{change:t.allElection},model:{value:t.checkAll,callback:function(e){t.checkAll=e},expression:"checkAll"}})],1),s("li",[t._v("商品信息")]),s("li",[t._v("价格")]),s("li",[t._v("数量")]),s("li",[t._v("小计")]),s("li",[t._v("操作")])]),t._l(t.cartList,(function(e,i){return s("div",{key:i,staticClass:"list"},[s("div",{staticClass:"item"},t._l(e.cartList,(function(e,a){return s("ul",{key:a},[s("li",[s("el-checkbox",{on:{change:function(e){return t.singleElection(i,a)}},model:{value:e.checked,callback:function(s){t.$set(e,"checked",s)},expression:"item.checked"}})],1),s("li",{staticClass:"goods-info-wrap",on:{click:function(s){return t.$router.pushToTab({path:"/sku-"+e.sku_id})}}},[s("div",{staticClass:"img-wrap"},[s("img",{staticClass:"img-thumbnail",attrs:{src:t.$img(e.sku_image,{size:"mid"})},on:{error:function(e){return t.imageError(i,a)}}})]),s("div",{staticClass:"info-wrap"},[s("h5",[t._v(t._s(e.sku_name))]),e.sku_spec_format?t._l(e.sku_spec_format,(function(i,a){return s("span",{key:a},[t._v(" "+t._s(i.spec_name)+":"+t._s(i.spec_value_name)+" "+t._s(a=0&&e.data.length&&t.handleCartList(e.data),t.loading=!1})).catch((function(e){t.loading=!1}))},handleCartList:function(t){var e=this;this.invalidGoods=[],this.cartList=[];var s={};t.forEach((function(t,i){1==t.goods_state?(t.checked=!0,void 0!=s["site_"+t.site_id]?s["site_"+t.site_id].cartList.push(t):s["site_"+t.site_id]={siteId:t.site_id,siteName:t.site_name,checked:!0,cartList:[t]}):e.invalidGoods.push(t)})),this.invalidGoods.forEach((function(t){t.sku_spec_format?(t.sku_spec_format=JSON.parse(t.sku_spec_format),console.log(t.sku_spec_format)):t.sku_spec_format=[]})),Object.keys(s).forEach((function(t){e.cartList.push(s[t])})),this.calculationTotalPrice(),this.cartList.forEach((function(t){t.cartList.forEach((function(t){t.sku_spec_format?t.sku_spec_format=JSON.parse(t.sku_spec_format):t.sku_spec_format=[]}))}))},singleElection:function(t,e){this.calculationTotalPrice()},siteAllElection:function(t){var e=this;this.cartList[t].cartList.forEach((function(s){s.checked=e.cartList[t].checked})),this.calculationTotalPrice()},allElection:function(){var t=this;this.cartList.length&&this.cartList.forEach((function(e){e.checked=t.checkAll,e.cartList.forEach((function(e){e.checked=t.checkAll}))})),this.calculationTotalPrice()},calculationTotalPrice:function(){if(this.cartList.length){var t=0,e=0,s=0;this.cartList.forEach((function(i){var a=0;i.cartList.forEach((function(s){s.checked&&(a+=1,e+=1,t+=s.discount_price*s.num)})),i.cartList.length==a?(i.checked=!0,s+=1):i.checked=!1})),this.totalPrice=t.toFixed(2),this.totalCount=e,this.checkAll=this.cartList.length==s}else this.totalPrice="0.00",this.totalCount=0;this.modifyNum=1},deleteCart:function(t,e){var s=this;this.$confirm("确定要删除该商品吗?","提示信息",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){s.$store.dispatch("cart/delete_cart",{cart_id:s.cartList[t].cartList[e].cart_id.toString()}).then((function(i){i.code>=0?(s.cartList[t].cartList.splice(e,1),0==s.cartList[t].cartList.length&&s.cartList.splice(t,1),s.calculationTotalPrice(),s.$message({type:"success",message:"删除成功"})):s.$message({message:i.message,type:"warning"})})).catch((function(t){s.$message.error(t.message)}))}))},deleteCartSelected:function(){var t=this,e=[],s=[];this.cartList.forEach((function(t,i){t.cartList.forEach((function(a,c){a.checked&&(e.push(a.cart_id),s.push({siteIndex:i,cartIndex:c,siteId:t.siteId,cartId:a.cart_id}))}))})),0!=e.length?this.$confirm("确定要删除选择的商品吗?","提示信息",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){t.$store.dispatch("cart/delete_cart",{cart_id:e.toString()}).then((function(e){e.code>=0?(s.forEach((function(e){t.cartList.forEach((function(s,i){s.cartList.forEach((function(a,c){e.cartId==a.cart_id&&s.cartList.splice(c,1),0==s.cartList.length&&t.cartList.splice(i,1)}))}))})),t.calculationTotalPrice(),t.$message({type:"success",message:"删除成功"})):t.$message({message:e.message,type:"warning"})})).catch((function(e){t.$message.error(e.message)}))})):this.$message({message:"请选择要删除的商品",type:"warning"})},clearInvalidGoods:function(){var t=this;this.$confirm("确认要清空这些商品吗?","提示信息",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){var e=[];t.invalidGoods.forEach((function(t){e.push(t.cart_id)})),e.length&&t.$store.dispatch("cart/delete_cart",{cart_id:e.toString()}).then((function(e){e.code>=0?(t.invalidGoods=[],t.$message({type:"success",message:"删除成功"})):t.$message({message:e.message,type:"warning"})})).catch((function(e){t.$message.error(e.message)}))}))},cartNumChange:function(t,e){var s=this;console.log(t),console.log(e),(t<1||!t)&&(t=1),this.modifyNum=0,this.$store.dispatch("cart/edit_cart_num",{num:t,cart_id:this.cartList[e.siteIndex].cartList[e.cartIndex].cart_id}).then((function(i){i.code>=0?(s.cartList[e.siteIndex].cartList[e.cartIndex].num=t,s.calculationTotalPrice()):(s.$message({message:i.message,type:"warning"}),s.modifyNum=1)})).catch((function(t){s.$message.error(t.message),s.modifyNum=1}))},settlement:function(){if(this.totalCount>0){var t=[];this.cartList.forEach((function(e){e.cartList.forEach((function(e){e.checked&&t.push(e.cart_id)}))}));var e={cart_ids:t.toString()};this.$store.dispatch("order/setOrderCreateData",e),this.$router.push({path:"/payment"})}},imageError:function(t,e){this.cartList[t].cartList[e].sku_image=this.defaultGoodsImage},imageErrorInvalid:function(t){this.invalidGoods[t].sku_image=this.defaultGoodsImage}}},l={name:"cart",mixins:[r]},u=l,d=(s("e197"),s("2877")),h=Object(d["a"])(u,i,a,!1,null,"06a082c5",null);e["default"]=h.exports},e197:function(t,e,s){"use strict";var i=s("36b0"),a=s.n(i);a.a}}]); //# sourceMappingURL=chunk-32789f42.cb7cf2bf.js.map