<template>
  <div class="sevice_detail">
    <div class="apass_breadcrumb">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item to="/shop">服务超市</el-breadcrumb-item>
        <el-breadcrumb-item to="/shop/space_time_service_list/6">
          时空服务
        </el-breadcrumb-item>
        <el-breadcrumb-item>服务详情信息</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <service-info :data="baseInfo" v-if="baseInfo"></service-info>

    <service-tabs
      :detail-data="detailData"
      :specification-data="specificationData"
      :provider-data="providerData"
      :comments-data="commentsData"
      :comments-url="commentsUrl"
    ></service-tabs>
  </div>
</template>

<script>
import serviceInfo from "@/components/service-info/service-info";
import serviceTabs from "@/components/service-tabs/service-tabs";

export default {
  components: {
    serviceInfo,
    serviceTabs,
  },
  data: () => ({
    baseInfo: null,
    detailData: null,
    specificationData: null,
    providerData: null,
    commentsData: null,
  }),
  computed: {
    id() {
      return this.$route.params.id;
    },
  },
  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: this.id,
          },
        })
        .then(({ data }) => {
          let datas = data.data;
          let specificationData =
            (datas.serviceRequestSpcs &&
              datas.serviceRequestSpcs.map((item) => ({
                id: item.id,
                type: item.type,
                pv: item.pv,
                count: item.count,
                name: `访问次数：${item.pv}/日 访问量：${item.count}/日`,
                descript: item.des,
              }))) ||
            [];

          this.baseInfo = {
            service_id: this.id,
            app_id: 0,
            name: datas.name,
            type: "Map Service",
            openness: datas.openness,
            view_count: datas.view_count,
            apply_count: datas.apply_count,
            cover: datas.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: "服务属性", // TODO: replace
              type: "list", 
              value: [
                {
                  name: "大小",
                  value: "66kb",
                },
                {
                  name: "API",
                  value: "Java",
                },
                {
                  name: "用途",
                  value: "即用型",
                },
                {
                  name: "空间范围",
                  value:
                    "111.8915040799999, 114.25605481900004, 28.762848204000022",
                },
                {
                  name: "标签",
                  value: "T003 智能地图 T001",
                },
                {
                  name: "制作单位",
                  value: "贵州省应急管理应急管理厅",
                },
                {
                  name: "离线模式",
                  value: "禁用",
                },
              ],
            }, */
          ];
          this.specificationData = specificationData;
          this.providerData = {
            organization_name: datas.organization_name,
            picture_path: datas.organization_picture,
            user_name: datas.register_user_info.user_name,
            phone: datas.register_user_info.phone,
          };
          this.commentsData = datas.scoreDetail;
        })
        .catch(function(error) {
          console.log(error);
        });
    },
  },
  mounted() {
    this.init();
  },
};
</script>
