{"ast":null,"code":"import \"core-js/modules/es.object.to-string.js\";\nimport \"core-js/modules/web.dom-collections.for-each.js\";\nimport \"core-js/modules/es.number.to-fixed.js\";\nimport \"core-js/modules/es.json.stringify.js\";\nimport \"core-js/modules/es.regexp.exec.js\";\nimport \"core-js/modules/es.string.replace.js\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport API from \"@/utils/request\";\nimport addressBox from \"@/components/AddressBox\";\nexport default {\n name: \"cart\",\n data: function data() {\n return {\n baseApi: this.$store.state.baseApi,\n userId: 0,\n addressData: [],\n //临时存储地址信息\n address: {},\n checkedIndex: 0,\n dialogFormVisible: false,\n good: {},\n realPrice: -1,\n goods: [],\n cartId: \"\"\n };\n },\n components: {\n \"address-box\": addressBox\n },\n created: function created() {\n this.loadAddress();\n this.good = JSON.parse(this.$route.query.good);\n this.good.realPrice = this.$route.query.realPrice;\n this.good.num = this.$route.query.num;\n this.good.standard = this.$route.query.standard;\n this.cartId = this.$route.query.cartId;\n this.goods.push(this.good);\n },\n computed: {\n sumPrice: function sumPrice() {\n var sum = 0;\n this.goods.forEach(function (good) {\n sum += good.realPrice * good.num;\n });\n return sum.toFixed(2);\n },\n sumDiscount: function sumDiscount() {\n var sum = 0;\n this.goods.forEach(function (good) {\n sum += (good.realPrice / good.discount - good.realPrice) * good.num;\n });\n return sum.toFixed(2);\n }\n },\n methods: {\n select: function select(index) {\n console.log(index);\n this.checkedIndex = index;\n },\n addAddress: function addAddress() {\n this.address = {};\n this.dialogFormVisible = true;\n },\n editAddress: function editAddress(item) {\n //深拷贝\n this.address = JSON.parse(JSON.stringify(item));\n this.dialogFormVisible = true;\n },\n deleteAddress: function deleteAddress(item) {\n var _this = this;\n\n this.$confirm(\"您确认删除该地址吗?\", \"提示\", {\n confirmButtonText: \"确定\",\n cancelButtonText: \"取消\",\n type: \"warning\"\n }).then(function () {\n API.delete(\"api/address/\" + item.id).then(function (res) {\n if (res.code === \"200\") {\n _this.$message.success(\"删除地址成功\");\n\n _this.loadAddress();\n }\n });\n });\n },\n saveAddress: function saveAddress() {\n var _this2 = this;\n\n this.address.userId = this.userId;\n API.post(\"/api/address\", this.address).then(function (res) {\n if (res.code === \"200\") {\n _this2.$message.success(\"保存成功\");\n\n _this2.loadAddress();\n\n _this2.dialogFormVisible = false;\n } else {\n _this2.$message.error(res.msg);\n }\n });\n },\n loadAddress: function loadAddress() {\n var _this3 = this;\n\n API.get(\"/userid\").then(function (res) {\n _this3.userId = res;\n API.get(\"/api/address/\" + res).then(function (res) {\n if (res.code === \"200\") {\n _this3.addressData = res.data;\n console.log(\"address\" + _this3.addressData);\n }\n });\n });\n },\n submitOrder: function submitOrder() {\n var _this4 = this;\n\n var address = this.addressData[this.checkedIndex];\n console.log(address);\n\n if (!address) {\n this.$message({\n type: \"warning\",\n message: \"请选择收货地址!\"\n });\n return;\n }\n\n console.log(JSON.stringify(this.good)); // 提交订单\n\n API.post(\"/api/order\", {\n totalPrice: this.sumPrice,\n linkUser: address.linkUser,\n linkPhone: address.linkPhone,\n linkAddress: address.linkAddress,\n state: \"待付款\",\n goods: JSON.stringify(this.goods),\n cartId: this.cartId\n }).then(function (res) {\n if (res.code === \"200\") {\n var orderNo = res.data; //跳转到支付页面\n\n _this4.$router.replace({\n path: \"pay\",\n query: {\n money: _this4.sumPrice,\n orderNo: orderNo\n }\n });\n } else {\n _this4.$message({\n type: \"error\",\n message: res.msg\n });\n }\n });\n }\n }\n};","map":{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA;AACA;AACA;AACAA,cADA;AAEAC,MAFA,kBAEA;AACA;AACAC,wCADA;AAEAC,eAFA;AAGAC,qBAHA;AAIA;AACAC,iBALA;AAMAC,qBANA;AAOAC,8BAPA;AAQAC,cARA;AASAC,mBATA;AAUAC,eAVA;AAWAC;AAXA;AAaA,GAhBA;AAiBAC;AACA;AADA,GAjBA;AAoBAC,SApBA,qBAoBA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GA7BA;AA8BAC;AACAC;AACA;AACA;AACAC;AACA,OAFA;AAGA;AACA,KAPA;AAQAC;AACA;AACA;AACAD;AACA,OAFA;AAGA;AACA;AAdA,GA9BA;AA8CAE;AACAC,UADA,kBACAC,KADA,EACA;AACAC;AACA;AACA,KAJA;AAKAC,cALA,wBAKA;AACA;AACA;AACA,KARA;AASAC,eATA,uBASAC,IATA,EASA;AACA;AACA;AACA;AACA,KAbA;AAcAC,iBAdA,yBAcAD,IAdA,EAcA;AAAA;;AACA;AACAE,+BADA;AAEAC,8BAFA;AAGAC;AAHA,SAIAC,IAJA,CAIA;AACAC;AACA;AACA;;AACA;AACA;AACA,SALA;AAMA,OAXA;AAYA,KA3BA;AA4BAC,eA5BA,yBA4BA;AAAA;;AACA;AACAD;AACA;AACA;;AACA;;AACA;AACA,SAJA,MAIA;AACA;AACA;AACA,OARA;AASA,KAvCA;AAwCAE,eAxCA,yBAwCA;AAAA;;AACAF;AACA;AACAA;AACA;AACA;AACAT;AACA;AACA,SALA;AAMA,OARA;AASA,KAlDA;AAoDAY,eApDA,yBAoDA;AAAA;;AACA;AACAZ;;AACA;AACA;AACAO,yBADA;AAEAM;AAFA;AAIA;AACA;;AACAb,6CAVA,CAWA;;AACAS;AACAK,iCADA;AAEAC,kCAFA;AAGAC,oCAHA;AAIAC,wCAJA;AAKAC,oBALA;AAMA7B,yCANA;AAOAC;AAPA,SAQAkB,IARA,CAQA;AACA;AACA,iCADA,CAEA;;AACA;AACAW,uBADA;AAEAC;AAAAC;AAAAC;AAAA;AAFA;AAIA,SAPA,MAOA;AACA;AACAf,yBADA;AAEAM;AAFA;AAIA;AACA,OAtBA;AAuBA;AAvFA;AA9CA","names":["name","data","baseApi","userId","addressData","address","checkedIndex","dialogFormVisible","good","realPrice","goods","cartId","components","created","computed","sumPrice","sum","sumDiscount","methods","select","index","console","addAddress","editAddress","item","deleteAddress","confirmButtonText","cancelButtonText","type","then","API","saveAddress","loadAddress","submitOrder","message","totalPrice","linkUser","linkPhone","linkAddress","state","path","query","money","orderNo"],"sourceRoot":"src/views/front/order","sources":["PreOrder.vue"],"sourcesContent":["\r\n \r\n \r\n \r\n \r\n \r\n 收货地址\r\n +\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {{ (scope.row.realPrice * scope.row.num).toFixed(2) }}\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n 总价:\r\n ¥ {{ sumPrice }}\r\n \r\n \r\n 优惠: ¥{{ sumDiscount }}\r\n \r\n \r\n 提交订单\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n"]},"metadata":{},"sourceType":"module"}