<template>
    <view class="p-5">
        <u-parse :content="agreementContent"></u-parse>
    </view>
</template>

<script setup lang="ts">
import { ref, unref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getPolicy } from '@/api/app'
import { AgreementEnum } from '@/enums/agreementEnums'

const agreementType = ref<AgreementEnum>(AgreementEnum.SERVICE) // 协议类型
const agreementContent = ref('') // 协议内容

const getData = async (type: AgreementEnum) => {
    const { name, content } = await getPolicy({ type })
    agreementContent.value = content
    uni.setNavigationBarTitle({
        title: name
    })
}

onLoad((options: any) => {
    const { type }: { type: AgreementEnum } = options
    if (type) {
        agreementType.value = type
        getData(unref(agreementType))
    }
})
</script>

<style lang="scss" scoped></style>
