diff --git a/src/components/service-info/app-info.vue b/src/components/service-info/app-info.vue index 76aa307d01ca5f653f559f753df96e3afc36be3b..2a9c1485e0f40eef30e30d6ba630086b8f5e230e 100644 --- a/src/components/service-info/app-info.vue +++ b/src/components/service-info/app-info.vue @@ -44,9 +44,7 @@ {{ item.name }} @@ -83,21 +81,57 @@ export default { value: 2, }, ], - commodityData: { - specification: 1, - }, + specificationID: 1, }), methods: { changeSpecification({ value }) { - this.commodityData.specification = value; + this.specificationID = value; }, addToCart() { - console.log("addToCart"); - console.log(this.commodityData); + // console.log("addToCart"); + + this.$http + .post("/apaas/serviceapp/v3/shopcart/add", { + service_id: 0, // 0表示不是服务 + app_id: parseFloat(this.data.app_id), + spec_id: this.specificationID, + duration: 1, + duration_method: 1, + is_subscribe: 0, // 是否订阅 + }) + .then(({ data }) => { + if (data.success == 1) { + this.$message({ + message: `添加购物车成功`, + type: "success", + }); + this.$store.commit("setMenuCartState"); + } else { + this.$message({ + message: `添加购物车失败`, + type: "warning", + }); + } + }) + .catch((error) => { + this.$message({ + message: `添加购物车失败`, + type: "warning", + }); + }); }, applyImmediately() { - console.log("applyImmediately"); - console.log(this.commodityData); + // console.log("applyImmediately"); + + this.$router.push({ + path: "/shop/shop_car_apply", + query: { + app_id: parseFloat(this.data.app_id), + spec_id: this.specificationID, + duration: 1, + duration_unit: 1, + }, + }); }, }, }; diff --git a/src/components/service-info/service-info.vue b/src/components/service-info/service-info.vue index c0adc6781d3131b681eeb7c6efdf86f6c5cbfbd0..d87fa781170097d2383ebed693a4cd14d5f9cac0 100644 --- a/src/components/service-info/service-info.vue +++ b/src/components/service-info/service-info.vue @@ -153,10 +153,10 @@ export default { // console.log("addToCart"); this.$http .post("/apaas/serviceapp/v3/shopcart/add", { - service_id: parseFloat(this.data.service_id), // 0表示不是服务 - app_id: parseFloat(this.data.app_id), // 0表示不是应用 + service_id: parseFloat(this.data.service_id), + app_id: 0, // 0表示不是应用 + spec_id: this.specification.id, // 规格id duration: this.duration, // 申请时长 - spec_id: this.specification.id, // 当为服务时,为服务规格 当为应用时 这里是部署方式的规格 1 部署 2开发 duration_method: this.type, // 计时方式 按年 按月 is_subscribe: 0, // 是否订阅 }) @@ -186,9 +186,9 @@ export default { path: "/shop/shop_car_apply", query: { service_id: parseFloat(this.data.service_id), + spec_id: this.specification.id, duration: this.duration, duration_unit: this.type, - spec_id: this.specification.id }, }); },