<template>
    <ie-page bg-color="#F6F8FA">
        <ie-navbar title="院校概率分析" transparent bg-color="#FFFFFF" title-color="black" keep-title-color/>
        <!-- #ifdef MP-WEIXIN -->
        <view class="h-90"
              style="background: linear-gradient(to Right, rgba(100, 200, 255, 1), rgba(165, 229, 255, 0.87))"/>
        <!-- #endif -->
        <ie-image is-oss src="/volunteer/voluntary/result/banner.png" custom-class="w-full h-483"/>
        <view class="px-30 flex flex-col gap-20 -mt-180 z-1">
            <voluntary-form-major custom-class="bg-white mt-0"/>
            <voluntary-result-analysis/>
            <voluntary-result-score/>
            <voluntary-result-history/>
            <voluntary-result-compare v-if="showCompare"/>
            <voluntary-result-skill/>
            <voluntary-result-disclaimer/>
        </view>
        <ie-safe-toolbar :height="84" :shadow="false">
            <view class="px-30 py-16">
                <ie-button @click="handleSubmit">加入志愿表</ie-button>
            </view>
        </ie-safe-toolbar>
    </ie-page>
</template>

<script setup lang="ts">

import {useTransferPage} from "@/hooks/useTransferPage";
import {VoluntaryDto} from "@/types/voluntary";
import {VOLUNTARY_TARGET, VOLUNTARY_RULES, VOLUNTARY_MODEL, VOLUNTARY_RESULT} from "@/types/injectionSymbols";
import VoluntaryFormMajor from "@/pagesOther/pages/voluntary/index/components/voluntary-form-major.vue";
import VoluntaryResultAnalysis from "@/pagesOther/pages/voluntary/result/components/voluntary-result-analysis.vue";
import VoluntaryResultScore from "@/pagesOther/pages/voluntary/result/components/voluntary-result-score.vue";
import VoluntaryResultHistory from "@/pagesOther/pages/voluntary/result/components/voluntary-result-history.vue";
import VoluntaryResultCompare from "@/pagesOther/pages/voluntary/result/components/voluntary-result-compare.vue";
import VoluntaryResultSkill from "@/pagesOther/pages/voluntary/result/components/voluntary-result-skill.vue";
import VoluntaryResultDisclaimer from "@/pagesOther/pages/voluntary/result/components/voluntary-result-disclaimer.vue";
import {useUserStore} from "@/store/userStore";
import {addVoluntary} from "@/api/modules/voluntary";

const userStore = useUserStore()
const {prevData} = useTransferPage<VoluntaryDto, any>()
const target = computed(() => prevData.value.target || {})
const rules = computed(() => prevData.value.rules || [])
const model = computed(() => prevData.value.model || {})
const result = computed(() => prevData.value.result || {})

const showCompare = computed(() => userStore.getLocation == '湖南')

const handleSubmit = async () => {
    await addVoluntary(target.value)
    uni.$ie.showSuccess('保存成功')
}

provide(VOLUNTARY_TARGET, target)
provide(VOLUNTARY_RULES, rules)
provide(VOLUNTARY_MODEL, model)
provide(VOLUNTARY_RESULT, result)

// 为了让子组件触发页面滚动，不可缺少
onPageScroll(() => {
})
</script>

<style lang="scss">

</style>
