Commit 9a727ce1 authored by 徐一鸣's avatar 徐一鸣

应用加购物车和立即申请

parent 4ab69016
...@@ -44,9 +44,7 @@ ...@@ -44,9 +44,7 @@
<el-button <el-button
v-for="(item, index) in specifications" v-for="(item, index) in specifications"
:key="'specifications_' + index" :key="'specifications_' + index"
:type=" :type="item.value === specificationID ? 'primary' : 'default'"
item.value === commodityData.specification ? 'primary' : 'default'
"
@click="changeSpecification(item)" @click="changeSpecification(item)"
> >
{{ item.name }} {{ item.name }}
...@@ -83,21 +81,57 @@ export default { ...@@ -83,21 +81,57 @@ export default {
value: 2, value: 2,
}, },
], ],
commodityData: { specificationID: 1,
specification: 1,
},
}), }),
methods: { methods: {
changeSpecification({ value }) { changeSpecification({ value }) {
this.commodityData.specification = value; this.specificationID = value;
}, },
addToCart() { addToCart() {
console.log("addToCart"); // console.log("addToCart");
console.log(this.commodityData);
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() { applyImmediately() {
console.log("applyImmediately"); // console.log("applyImmediately");
console.log(this.commodityData);
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,
},
});
}, },
}, },
}; };
......
...@@ -153,10 +153,10 @@ export default { ...@@ -153,10 +153,10 @@ export default {
// console.log("addToCart"); // console.log("addToCart");
this.$http this.$http
.post("/apaas/serviceapp/v3/shopcart/add", { .post("/apaas/serviceapp/v3/shopcart/add", {
service_id: parseFloat(this.data.service_id), // 0表示不是服务 service_id: parseFloat(this.data.service_id),
app_id: parseFloat(this.data.app_id), // 0表示不是应用 app_id: 0, // 0表示不是应用
spec_id: this.specification.id, // 规格id
duration: this.duration, // 申请时长 duration: this.duration, // 申请时长
spec_id: this.specification.id, // 当为服务时,为服务规格 当为应用时 这里是部署方式的规格 1 部署 2开发
duration_method: this.type, // 计时方式 按年 按月 duration_method: this.type, // 计时方式 按年 按月
is_subscribe: 0, // 是否订阅 is_subscribe: 0, // 是否订阅
}) })
...@@ -186,9 +186,9 @@ export default { ...@@ -186,9 +186,9 @@ export default {
path: "/shop/shop_car_apply", path: "/shop/shop_car_apply",
query: { query: {
service_id: parseFloat(this.data.service_id), service_id: parseFloat(this.data.service_id),
spec_id: this.specification.id,
duration: this.duration, duration: this.duration,
duration_unit: this.type, duration_unit: this.type,
spec_id: this.specification.id
}, },
}); });
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment