From 53f133ad9d26b9f06134d741912d760148022bb4 Mon Sep 17 00:00:00 2001 From: xuyiming Date: Mon, 15 Jun 2020 16:27:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=95=86=E5=BA=97=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E8=AF=A6=E6=83=85=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/service-info/service-info.vue | 17 ++++++++++++----- src/pages/service_shop/sjfwDetail.vue | 15 +++++++++------ src/pages/service_shop/skfwDetail.vue | 14 ++++++++------ src/pages/service_shop/zhfwDetail.vue | 14 ++++++++------ 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/components/service-info/service-info.vue b/src/components/service-info/service-info.vue index 366f59e..d7b77b6 100644 --- a/src/components/service-info/service-info.vue +++ b/src/components/service-info/service-info.vue @@ -62,7 +62,10 @@
规格说明: - +
购买方式: @@ -125,10 +128,6 @@ export default { (item) => item.type == this.type ); - if (this.specification.id === undefined) { - this.specification = specifications[0]; - } - return specifications; }, }, @@ -146,6 +145,9 @@ export default { }, changeType({ value }) { this.type = value; + if (this.specifications.length > 0) { + this.specification = this.specifications[0]; + } }, addToCart() { // console.log("addToCart"); @@ -183,6 +185,11 @@ export default { console.log("applyImmediately"); }, }, + mounted() { + if (this.specifications.length > 0) { + this.specification = this.specifications[0]; + } + }, }; diff --git a/src/pages/service_shop/sjfwDetail.vue b/src/pages/service_shop/sjfwDetail.vue index 1a9a7ee..b210175 100644 --- a/src/pages/service_shop/sjfwDetail.vue +++ b/src/pages/service_shop/sjfwDetail.vue @@ -56,12 +56,15 @@ export default { }) .then(({ data }) => { let datas = data.data; - let specificationData = datas.serviceRequestSpcs.map((item) => ({ - id: item.id, - type: item.type, - name: `访问次数:${item.pv}/日 访问量:${item.count}/日`, - descript: item.des, - })); + let specificationData = + (datas.serviceRequestSpcs && + datas.serviceRequestSpcs.map((item) => ({ + id: item.id, + type: item.type, + name: `访问次数:${item.pv}/日 访问量:${item.count}/日`, + descript: item.des, + }))) || + []; this.baseInfo = { service_id: this.id, diff --git a/src/pages/service_shop/skfwDetail.vue b/src/pages/service_shop/skfwDetail.vue index 4279356..1d5feda 100644 --- a/src/pages/service_shop/skfwDetail.vue +++ b/src/pages/service_shop/skfwDetail.vue @@ -61,12 +61,14 @@ export default { }) .then(({ data }) => { let datas = data.data; - let specificationData = datas.serviceRequestSpcs.map((item) => ({ - id: item.id, - type: item.type, - name: `访问次数:${item.pv}/日 访问量:${item.count}/日`, - descript: item.des, - })); + (datas.serviceRequestSpcs && + datas.serviceRequestSpcs.map((item) => ({ + id: item.id, + type: item.type, + name: `访问次数:${item.pv}/日 访问量:${item.count}/日`, + descript: item.des, + }))) || + []; this.baseInfo = { service_id: this.id, diff --git a/src/pages/service_shop/zhfwDetail.vue b/src/pages/service_shop/zhfwDetail.vue index 2e503e6..da41905 100644 --- a/src/pages/service_shop/zhfwDetail.vue +++ b/src/pages/service_shop/zhfwDetail.vue @@ -61,12 +61,14 @@ export default { }) .then(({ data }) => { let datas = data.data; - let specificationData = datas.serviceRequestSpcs.map((item) => ({ - id: item.id, - type: item.type, - name: `访问次数:${item.pv}/日 访问量:${item.count}/日`, - descript: item.des, - })); + (datas.serviceRequestSpcs && + datas.serviceRequestSpcs.map((item) => ({ + id: item.id, + type: item.type, + name: `访问次数:${item.pv}/日 访问量:${item.count}/日`, + descript: item.des, + }))) || + []; this.baseInfo = { service_id: this.id, -- 2.26.0