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

应用加购物车和立即申请

parent 4ab69016
......@@ -44,9 +44,7 @@
<el-button
v-for="(item, index) in specifications"
:key="'specifications_' + index"
:type="
item.value === commodityData.specification ? 'primary' : 'default'
"
:type="item.value === specificationID ? 'primary' : 'default'"
@click="changeSpecification(item)"
>
{{ 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,
},
});
},
},
};
......
......@@ -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
},
});
},
......
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