From 8f1d89947e0944aef20fa7e4ba3f542879b1dc18 Mon Sep 17 00:00:00 2001 From: zhangjun1 Date: Tue, 10 May 2022 17:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E7=94=B3=E8=AF=B7=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/service-info/service-info.vue | 78 +++++++++++--------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/src/components/service-info/service-info.vue b/src/components/service-info/service-info.vue index 8d46bd0..65e809b 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() { -- 2.26.0