(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-1bd82549"],{2166:function(t,e,a){"use strict";a.d(e,"a",(function(){return s})),a.d(e,"d",(function(){return o})),a.d(e,"c",(function(){return r})),a.d(e,"b",(function(){return c}));var i=a("a27e");function s(t){return i["a"].post("/cart/add",t)}function o(t){return i["a"].post("/cart/list",t)}function r(t){return i["a"].post("/cart/delete",t)}function c(t){return i["a"].post("/order/addOrderByCart",t)}},5931:function(t,e,a){"use strict";a("e257")},bf12:function(t,e,a){"use strict";a.r(e);var i=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("transition",{attrs:{name:"el-fade-in-linear"}},[a("div",{staticClass:"app-cart"},[a("div",{staticClass:"app-header"},[a("appHeader"),a("el-divider")],1),a("div",{staticClass:"cart-body"},[a("div",{staticClass:"tableCardDiv"},[a("el-card",{staticClass:"box-card tableCard"},[a("div",{staticClass:"clearfix orderTitle",attrs:{slot:"header"},slot:"header"},[a("span",[t._v("购物车")])]),a("table",{staticClass:"cart-table",attrs:{border:"0",cellspacing:"50px"}},[a("tr",[a("th",[t._v("图片")]),a("th",[t._v("名称")]),a("th",[t._v("价格")]),a("th",[t._v("数量")]),a("th",[t._v("删除")])]),t._l(t.cartItemList,(function(e){return a("tr",{key:e.cartItemId},[a("td",[a("img",{staticClass:"goodsImg",staticStyle:{width:"70px",height:"70px"},attrs:{src:t.getImgUrl(e.goodsCoverImg)}})]),a("td",[t._v(t._s(e.goodsName))]),a("td",[t._v(" "+t._s(e.price)+" ")]),a("td",[a("el-input-number",{attrs:{min:1,max:100,label:"物品数量"},on:{change:function(a){return t.calSingleTotalPrice(e)}},model:{value:e.goodsCount,callback:function(a){t.$set(e,"goodsCount",a)},expression:"item.goodsCount"}})],1),a("td",[a("el-date-picker",{attrs:{type:"date",placeholder:"选择租赁起始日期"},on:{change:function(a){return t.calTotalDay(e)}},model:{value:e.createTime,callback:function(a){t.$set(e,"createTime",a)},expression:"item.createTime"}})],1),a("td",[a("el-date-picker",{attrs:{type:"date",placeholder:"选择租赁结束日期"},on:{change:function(a){return t.calTotalDay(e)}},model:{value:e.endTime,callback:function(a){t.$set(e,"endTime",a)},expression:"item.endTime"}})],1),a("td",[a("el-dialog",{attrs:{title:"删除",visible:t.dialogVisible,width:"30%"},on:{"update:visible":function(e){t.dialogVisible=e}}},[a("span",[t._v("确认是否删除？")]),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(e){t.dialogVisible=!1}}},[t._v("取 消")]),a("el-button",{attrs:{type:"primary"},on:{click:function(a){return t.deleteCartItem(e.cartItemId)}}},[t._v("确 定")])],1)]),a("el-button",{attrs:{slot:"reference",type:"danger"},on:{click:function(e){t.dialogVisible=!0}},slot:"reference"},[t._v("删除")])],1)])}))],2),a("el-divider"),a("div",{staticClass:"totalPriceDiv"},[a("span",{staticClass:"totalPrice"},[t._v(" 总计："+t._s(this.totalPrice)+" ")])]),a("div",{staticClass:"createOrder"},[a("el-button",{staticClass:"createOrderButton",attrs:{type:"success"},on:{click:t.addOrder}},[t._v("确认下单")])],1)],1)],1)]),a("div",{staticClass:"app-footer"},[a("el-divider"),a("appFooter",{staticClass:"app-footer"})],1)])])},s=[],o=(a("14d9"),a("f392")),r=a("2c4b"),c=a("2166"),l={name:"cart",components:{appHeader:o["a"],appFooter:r["a"]},data(){return{cartItemList:"",dialogVisible:!1,totalPrice:""}},methods:{async getList(){try{await Object(c["d"])({}).then(t=>{this.cartItemList=t;for(let e=0;e<this.cartItemList.length;e++)this.cartItemList[e]["totalDay"]=[],this.cartItemList[e]["singleTotalPrice"]=this.cartItemList[e].price;console.log(this.cartItemList)})}catch(t){console.log(t)}},async deleteCartItem(t){try{await Object(c["c"])({cartItemId:t}).then(t=>{console.log(t)})}catch(e){console.log(e)}this.dialogVisible=!1,alert("删除成功"),await this.$router.push({name:"cart",query:{t:Date.now()}})},getImgUrl(t){return this.$store.state.baseUrl+"/img/"+t+".jpg"},date(t){console.log(t)},calTotalPrice(){let t=0;for(let e=0;e<this.cartItemList.length;e++)t+=this.cartItemList[e].singleTotalPrice;this.totalPrice=t.toString(),console.log(this.totalPrice)},calSingleTotalPrice(t){t.singleTotalPrice=t.price*t.goodsCount*t.totalDay,this.calTotalPrice(),console.log(t.totalDay),console.log(t.singleTotalPrice)},calTotalDay(t){let e=t.endTime-t.createTime,a=e/36e5/24;t.totalDay=a,console.log(a),console.log(t.createTime),this.calSingleTotalPrice(t),this.calTotalPrice()},async addOrder(){try{await Object(c["b"])({cartItemList:this.cartItemList,totalPrice:this.totalPrice}).then(t=>{console.log(t),this.openSuccess(),this.$router.push({name:"home",query:{t:Date.now()}})})}catch(t){console.log(t)}},openSuccess(){this.$message({message:"恭喜你，下单成功!",type:"success"})}},mounted(){this.getList()},beforeRouteUpdate(){this.getList()}},n=l,d=(a("5931"),a("2877")),u=Object(d["a"])(n,i,s,!1,null,"3a4480b8",null);e["default"]=u.exports},e257:function(t,e,a){}}]);
//# sourceMappingURL=chunk-1bd82549.ad11e70a.js.map