diff --git a/src/components/service-info/service-info.vue b/src/components/service-info/service-info.vue index 8d46bd021e334df8603a4eb2123db1ed9bd8b89e..65e809b0f0d914e76247b7e43b5d38a5de8d8634 100644 --- a/src/components/service-info/service-info.vue +++ b/src/components/service-info/service-info.vue @@ -254,47 +254,55 @@ export default { }, addToCart() { // console.log("addToCart"); - this.$http - .post("/apaas/serviceapp/v3/shopcart/add", { - service_id: parseFloat(this.data.service_id), - app_id: 0, // 0表示不是应用 - spec_id: this.specification.id, // 规格id - duration: this.duration, // 申请时长 - duration_method: this.type, // 计时方式 按年 按月 - is_subscribe: 0, // 是否订阅 - }) - .then(({ data }) => { - if (data.success == 1) { + if(this.$store.state.userInfo){ + this.$http + .post("/apaas/serviceapp/v3/shopcart/add", { + service_id: parseFloat(this.data.service_id), + app_id: 0, // 0表示不是应用 + spec_id: this.specification.id, // 规格id + duration: this.duration, // 申请时长 + duration_method: this.type, // 计时方式 按年 按月 + is_subscribe: 0, // 是否订阅 + }) + .then(({ data }) => { + if (data.success == 1) { + this.$message({ + message: data.errMsg, + type: "success", + }); + this.$store.commit("setMenuCartState"); + } else { + this.$message({ + message: data.errMsg, + type: "warning", + }); + } + }) + .catch((error) => { this.$message({ - message: data.errMsg, - type: "success", - }); - this.$store.commit("setMenuCartState"); - } else { - this.$message({ - message: data.errMsg, + message: `添加申请单失败`, type: "warning", }); - } - }) - .catch((error) => { - this.$message({ - message: `添加申请单失败`, - type: "warning", }); - }); + }else{ + window.location.href = "/iam/login/#/login?ReturnUrl=" + encodeURIComponent(window.location.href); + } }, applyImmediately() { - this.$router.push({ - path: "/shop/shop_car_apply", - query: { - service_id: parseFloat(this.data.service_id), - spec_id: this.specification.id, - spcs_type: this.specification.spcs_type, - duration: this.duration, - duration_unit: this.type, - }, - }); + if(this.$store.state.userInfo){ + this.$router.push({ + path: "/shop/shop_car_apply", + query: { + service_id: parseFloat(this.data.service_id), + spec_id: this.specification.id, + spcs_type: this.specification.spcs_type, + duration: this.duration, + duration_unit: this.type, + }, + }); + }else{ + window.location.href = "/iam/login/#/login?ReturnUrl=" + encodeURIComponent(window.location.href); + } }, }, created() {