qauMaWeb/node_modules/.cache/babel-loader/5039dd0d8dcc368ea2df4201c50...

1 line
15 KiB
JSON
Raw Normal View History

2024-10-13 18:02:27 +08:00
{"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