qauMaWeb/node_modules/.cache/babel-loader/9251ec205ed3c0db69886e1579a...

1 line
14 KiB
JSON

{"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//\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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QA;AACA;AACA,iCADA,CAEA;;AACA;AAAAW;AAAAC;AAAAC;AAAAC;AAAA;AAAA;AACA,SAJA,MAIA;AACA;AACAf,yBADA;AAEAM;AAFA;AAIA;AACA,OAnBA;AAoBA;AArFA;AA/CA","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":["<template>\r\n <div style=\"margin-top: 10px;width: 90%;margin: 10px auto;\">\r\n <div style=\"background-color: white; padding: 10px;border-radius: 12px\">\r\n <!--收货地址-->\r\n <div style=\"padding: 10px; margin-bottom: 20px; border-bottom: 1px solid #eee\">\r\n <div style=\"font-size: 20px; border-bottom: 2px solid dodgerblue; padding-bottom: 10px; margin-bottom: 20px\">\r\n 收货地址\r\n <el-button style=\"height: 25px;padding: 5px\" @click=\"addAddress\">+</el-button>\r\n </div>\r\n <template v-for=\"(item,index) in addressData\">\r\n <address-box :address=\"item\"\r\n :key=\"index\"\r\n :class=\"index === checkedIndex?'active':' '\"\r\n style=\"margin-right: 20px\"\r\n @edit=\"editAddress(item)\"\r\n @delete=\"deleteAddress(item)\"\r\n @click.native=\"select(index)\"></address-box>\r\n </template>\r\n </div>\r\n<!-- 地址弹窗-->\r\n <el-dialog title=\"地址信息\" :visible.sync=\"dialogFormVisible\">\r\n <el-form label-width=\"90px\" style=\"padding: 0 60px\">\r\n <el-form-item label=\"联系人\">\r\n <el-input v-model=\"address.linkUser\" autocomplete=\"off\"></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"联系电话\">\r\n <el-input v-model=\"address.linkPhone\" autocomplete=\"off\"></el-input>\r\n </el-form-item>\r\n <el-form-item label=\"地址\">\r\n <el-input v-model=\"address.linkAddress\" autocomplete=\"off\"></el-input>\r\n </el-form-item>\r\n </el-form>\r\n <div slot=\"footer\" class=\"dialog-footer\">\r\n <el-button @click=\"dialogFormVisible = false\">取 消</el-button>\r\n <el-button type=\"primary\" @click=\"saveAddress\">确 定</el-button>\r\n </div>\r\n </el-dialog>\r\n\r\n\r\n <!-- 商品确认-->\r\n <el-table :data=\"goods\" stripe style=\"width: 100%\">\r\n <el-table-column label=\"商品图片\" width=\"150\">\r\n <template slot-scope=\"scope\">\r\n <el-image :src=\"baseApi + scope.row.imgs\" style=\"width: 100px; height: 100px;\" fit=\"contain\"></el-image>\r\n </template>\r\n </el-table-column>\r\n <el-table-column prop=\"name\" label=\"商品名称\"></el-table-column>\r\n <el-table-column prop=\"standard\" label=\"规格\"></el-table-column>\r\n <el-table-column prop=\"realPrice\" label=\"单价\"></el-table-column>\r\n <el-table-column prop=\"num\" label=\"数量\"></el-table-column>\r\n <el-table-column label=\"价格\">\r\n <template slot-scope=\"scope\">\r\n {{ (scope.row.realPrice * scope.row.num).toFixed(2) }}\r\n </template>\r\n </el-table-column>\r\n\r\n </el-table>\r\n\r\n <div style=\"margin-top: 10px\">\r\n <div style=\"background-color: white; padding: 10px\">\r\n <div style=\"color: red; text-align: right\">\r\n <div>\r\n <span>总价:</span>\r\n <span>¥ {{ sumPrice }}</span>\r\n </div>\r\n <div style=\"text-align: right; color: #999; font-size: 12px;\">\r\n 优惠: ¥{{ sumDiscount }}\r\n </div>\r\n <div style=\"padding: 10px 0\">\r\n <el-button style=\"background-color: red; color: white; width: 100px\" @click=\"submitOrder\">提交订单</el-button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script>\r\nimport API from \"@/utils/request\";\r\nimport addressBox from \"@/components/AddressBox\"\r\nexport default {\r\n name: \"cart\",\r\n data() {\r\n return {\r\n baseApi: this.$store.state.baseApi,\r\n userId: 0,\r\n addressData: [],\r\n //临时存储地址信息\r\n address:{},\r\n checkedIndex : 0,\r\n dialogFormVisible: false,\r\n good: {},\r\n realPrice: -1,\r\n goods:[],\r\n cartId: \"\"\r\n }\r\n },\r\n components:{\r\n 'address-box': addressBox,\r\n },\r\n created() {\r\n\r\n this.loadAddress();\r\n\r\n this.good = JSON.parse(this.$route.query.good)\r\n this.good.realPrice = this.$route.query.realPrice\r\n this.good.num = this.$route.query.num\r\n this.good.standard = this.$route.query.standard\r\n this.cartId = this.$route.query.cartId\r\n this.goods.push(this.good)\r\n },\r\n computed: {\r\n sumPrice: function () {\r\n let sum = 0;\r\n this.goods.forEach(function (good){\r\n sum += good.realPrice * good.num;\r\n })\r\n return sum.toFixed(2);\r\n },\r\n sumDiscount: function (){\r\n let sum = 0;\r\n this.goods.forEach(function (good){\r\n sum += (good.realPrice / good.discount -good.realPrice) * good.num;\r\n })\r\n return sum.toFixed(2);\r\n }\r\n },\r\n methods: {\r\n select(index){\r\n console.log(index)\r\n this.checkedIndex = index;\r\n },\r\n addAddress(){\r\n this.address = {};\r\n this.dialogFormVisible = true;\r\n },\r\n editAddress(item){\r\n //深拷贝\r\n this.address = JSON.parse(JSON.stringify(item));\r\n this.dialogFormVisible = true;\r\n },\r\n deleteAddress(item){\r\n this.$confirm('您确认删除该地址吗?', '提示', {\r\n confirmButtonText: '确定',\r\n cancelButtonText: '取消',\r\n type: 'warning'\r\n }).then(()=>{\r\n API.delete(\"api/address/\"+item.id).then(res=>{\r\n if(res.code==='200'){\r\n this.$message.success(\"删除地址成功\");\r\n this.loadAddress();\r\n }\r\n })\r\n })\r\n\r\n },\r\n saveAddress(){\r\n this.address.userId = this.userId;\r\n API.post(\"/api/address\",this.address).then(res=>{\r\n if(res.code==='200'){\r\n this.$message.success(\"保存成功\");\r\n this.loadAddress();\r\n this.dialogFormVisible = false;\r\n }else {\r\n this.$message.error(res.msg);\r\n }\r\n })\r\n },\r\n loadAddress(){\r\n API.get(\"/userid\").then(res=>{\r\n this.userId = res;\r\n API.get(\"/api/address/\"+ res).then(res=>{\r\n if(res.code==='200'){\r\n this.addressData = res.data;\r\n console.log(\"address\"+this.addressData)\r\n }\r\n })\r\n })\r\n },\r\n\r\n submitOrder() {\r\n let address = this.addressData[this.checkedIndex];\r\n console.log(address)\r\n if (!address) {\r\n this.$message({\r\n type: 'warning',\r\n message: '请选择收货地址!'\r\n })\r\n return\r\n }\r\n console.log(JSON.stringify(this.good))\r\n // 提交订单\r\n API.post(\"/api/order\", {\r\n totalPrice: this.sumPrice,\r\n linkUser: address.linkUser,\r\n linkPhone: address.linkPhone,\r\n linkAddress: address.linkAddress,\r\n state: '待付款',\r\n goods: JSON.stringify(this.goods),\r\n cartId: this.cartId\r\n }).then(res => {\r\n if (res.code === '200') {\r\n let orderNo = res.data\r\n //跳转到支付页面\r\n this.$router.replace({path: 'pay',query:{money: this.sumPrice,orderNo: orderNo}})\r\n } else {\r\n this.$message({\r\n type: 'error',\r\n message: res.msg\r\n })\r\n }\r\n })\r\n },\r\n\r\n }\r\n}\r\n</script>\r\n\r\n<style scoped>\r\n.active{\r\n background-color: #f6c169;\r\n color: #ffffff;\r\n border: #f17878 2px solid;\r\n}\r\n</style>\r\n"]},"metadata":{},"sourceType":"module"}