<template>
    <view>
        <view class="certification-card serve-main ">
            <view class="serve-box flex_c_s" @click="goModifyIt">
                <view class="font-32-1D">{{viewStatus?'服务类目':'已选服务类目'}}</view>
                <view class="flex_c_r" v-if="viewStatus">
                    <view class="font-32-05">{{ project && project.length >0 ? '去修改':'选择' }}</view>
                    <up-icon name="arrow-right" color="#C9CDD4" size="16" v-if="project && project.length >0"></up-icon>
                </view>
            </view>
            <view class="hr-solid-top serve-box-contnt" v-if="project && project.length > 0">
                <view class="serve-item" v-for="item in project" :key="item.id">{{ item.businessName }}</view>
            </view>
        </view>

       <view v-for="item in project" :key="item.id" class="serve-img-boxs">
        <Certificate :data="item" v-if="item.isFiles"/>
       </view>
       
       <view class="certification-card whether-or-not flex_c_s" v-if="project && project.length > 0">
        <view class="font-32-1D">是否展示资质</view>
        <view class="radio-box flex_c_c" v-if="viewStatus">
            <view v-for="item in radoiList" :key="item.value" @click="racioClick(item)" class="radio-item flex_c_c">
                 <view class="font-32-1D radio-name">{{ item.name }}</view>
                 <view :class="formData.whether === item.value ? 'whether-radio-active' : 'whether-radio'"></view>
            </view>
        </view>
        <view class="radio-box flex_c_c" v-else>
            <view class="radio-item flex_c_c">
                 <view class="font-32-1D radio-name">{{ project.whether === '1'?'是':'否' }}</view>
                 <view class="whether-radio-active"></view>
            </view>
        </view>
       </view>
    </view>
</template>
<script setup>
import { inject } from 'vue';
import Certificate from './Certificate.vue';
import { computed } from 'vue';
const formData = inject('formData');

const { project } = formData;
const props=defineProps({
    viewStatus: {
        type: Boolean,
        default: true
    },
})
const radoiList = [
    {
        name: '是',
        value: '1'
    },
    {
        name: '否',
        value: '2'
    },
];



const goModifyIt = async() => {
    try {
        console.log("TCL: formData", project)
        uni.navigateTo({
            url: `/pages_home/pages/certification/Class?data=${encodeURIComponent(JSON.stringify(project))}`
        });
    } catch (error) {
		console.log("TCL: goModifyIt -> error", error)
    }
}

const racioClick = (item) => {
	try {
        Object.assign(formData, { whether: item.value });
    } catch (error) {
		console.log("TCL: racioClick -> error", error)
    }
}


</script>

<style lang="scss" scoped>
@import "./index.scss";
</style>