From 954881424de03d59be689233731fb92ff467595e Mon Sep 17 00:00:00 2001 From: xuyiming Date: Wed, 10 Jun 2020 18:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9C=8D=E5=8A=A1=E8=AF=A6?= =?UTF-8?q?=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/comments-list.vue | 10 +- src/components/service-info/service-info.vue | 132 ++++++++++----- .../service-tabs/service-tab-comments.vue | 52 +++++- .../service-tabs/service-tab-detail.vue | 25 +-- .../service-tabs/service-tab-provider.vue | 33 ++-- .../service-tab-specification.vue | 49 ++---- src/components/service-tabs/service-tabs.vue | 43 +++-- src/pages/service_shop/sjfwDetail.vue | 156 ++++++++++++++++-- 8 files changed, 338 insertions(+), 162 deletions(-) diff --git a/src/components/comments-list.vue b/src/components/comments-list.vue index c98904f..9b44f0b 100644 --- a/src/components/comments-list.vue +++ b/src/components/comments-list.vue @@ -6,21 +6,21 @@ :key="'comment_' + index" >
- +
-

+

-

-

+

+

diff --git a/src/components/service-info/service-info.vue b/src/components/service-info/service-info.vue index c05cff5..c85b865 100644 --- a/src/components/service-info/service-info.vue +++ b/src/components/service-info/service-info.vue @@ -3,58 +3,57 @@
- + - + - +
-
- +
+
  • 提供机构: - +
  • 发布时间: - +
  • 更新时间: - +
  • 数据领域: - +
  • 服务类型: - +
  • 资源摘要: - +
规  格:
{{ item.name }} @@ -63,17 +62,17 @@
规格说明: - +
购买方式:
@@ -81,11 +80,7 @@
购买时长:
- +
@@ -110,33 +105,82 @@ export default { }, }, data: () => ({ - commodityData: { - specification: 0, - way: 0, - duration: 1, - }, + types: [ + { + name: "按月", + value: 1, + }, + { + name: "按年", + value: 2, + }, + ], + type: 1, // 购买方式 1:按月,2:按年 + specification: {}, // 规格 + duration: 1, // 时长 }), computed: { - specificationDescription() { - let obj = - this.data.specifications[this.commodityData.specification] || {}; - return obj.description || ""; + specifications() { + let specifications = (this.data.serviceRequestSpcs || []).filter( + (item) => item.type == this.type + ); + + if (this.specification.id === undefined) { + this.specification = specifications[0]; + } + + return specifications; + }, + }, + watch: { + specifications: { + handler() { + this.specification = this.specifications[0]; + }, + deep: true, }, }, methods: { - changeSpecification({ value }) { - this.commodityData.specification = value; + changeSpecification(specification) { + this.specification = specification; }, - changeWay({ value }) { - this.commodityData.way = value; + changeType({ value }) { + this.type = value; }, addToCart() { - console.log("addToCart"); - console.log(this.commodityData); + // 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表示不是应用 + duration: this.duration, // 申请时长 + spec_id: this.specification.id, // 当为服务时,为服务规格 当为应用时 这里是部署方式的规格 1 部署 2开发 + duration_method: this.type, // 计时方式 按年 按月 + is_subscribe: 1, // 是否订阅 + }) + .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); }, }, }; diff --git a/src/components/service-tabs/service-tab-comments.vue b/src/components/service-tabs/service-tab-comments.vue index 33f7904..8e69c07 100644 --- a/src/components/service-tabs/service-tab-comments.vue +++ b/src/components/service-tabs/service-tab-comments.vue @@ -1,9 +1,9 @@ @@ -71,21 +74,25 @@ export default { type: String, default: () => "服务评价信息", }, - detailUrl: { - type: String, - default: () => "", + detailData: { + type: Array, + default: () => [], }, - specificationUrl: { - type: String, - default: () => "", + specificationData: { + type: Array, + default: () => [], }, - providerUrl: { - type: String, - default: () => "", + providerData: { + type: Object, + default: () => {}, + }, + commentsData: { + type: Object, + default: () => {}, }, commentsUrl: { type: String, - default: () => "", + default: () => [], }, }, data: () => ({ diff --git a/src/pages/service_shop/sjfwDetail.vue b/src/pages/service_shop/sjfwDetail.vue index e2e6c56..edad4e5 100644 --- a/src/pages/service_shop/sjfwDetail.vue +++ b/src/pages/service_shop/sjfwDetail.vue @@ -3,20 +3,21 @@
服务超市 - + 数据服务 服务详情信息
- +
@@ -33,24 +34,157 @@ export default { data: () => ({ baseInfo: null, detailData: null, - specification: null, - provider: null, + specificationData: null, + providerData: null, + commentsData: null, }), computed: { id() { return this.$route.params.id; }, + commentsUrl() { + return `/apaas/serviceapp/v3/servicemarket/estimates?serviceId=${this.id}`; + }, }, methods: { init() { this.$http .get("/apaas/serviceapp/v3/servicemarket/detail", { params: { - serviceId: 666, + serviceId: this.id, }, }) - .then((response) => { - console.log(response.data); + .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, + })); + + this.baseInfo = { + service_id: this.id, + app_id: 0, + name: datas.name, + // type: "", + openness: datas.openness, + view_count: datas.view_count, + apply_count: datas.apply_count, + // cover: "", + organization_name: datas.organization_name, + create_time: datas.create_time, + update_date: datas.update_date, + sectors_name: datas.sectors_name, + data_service_type3_str: datas.data_service_type3_str, + descript: datas.descript, + serviceRequestSpcs: specificationData, + }; + + this.detailData = [ + { + name: "获取流程", + type: "step", + value: ["服务申请", "信息填写", "审核确认", "服务获取"], + }, + { + name: "服务描述", + type: "text", + value: datas.descript, + }, + { + name: "请求方式", + type: "text", + value: ["-", "GET", "POST", "PUT", "DELETE"][datas.req_type || 0], + }, + { + name: "编码格式", + type: "text", + value: datas.encode_method, + }, + { + name: "请求参数", + type: "table", + value: { + datas: JSON.parse(datas.req_fields), + columns: [ + { + prop: "name", + label: "字段编码", + align: "center", + width: 240, + }, + { + prop: "label", + label: "字段名称", + align: "center", + width: 180, + }, + { + prop: "field_type", + label: "字段类型", + align: "center", + width: 180, + }, + { + prop: "descript", + label: "字段说明", + }, + { + prop: "is_must", + label: "是否必须", + align: "center", + width: 180, + }, + { + prop: "example", + label: "示例值", + align: "center", + width: 180, + }, + ], + }, + }, + { + name: "响应参数", + type: "table", + value: { + datas: JSON.parse(datas.res_fields), + columns: [ + { + prop: "name", + label: "字段编码", + align: "center", + width: 240, + }, + { + prop: "label", + label: "字段名称", + align: "center", + width: 180, + }, + { + prop: "field_type", + label: "字段类型", + align: "center", + width: 180, + }, + { + prop: "descript", + label: "字段说明", + }, + ], + }, + }, + ]; + this.specificationData = specificationData; + this.providerData = { + organization_name: datas.organization_name, + picture_path: datas.picture_path, + user_name: "张先生", + phone: "010-66666666", + }; + this.commentsData = datas.scoreDetail; }) .catch(function(error) { console.log(error); -- 2.26.0