| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <template>
- <view class="container">
- <scroll-view class="content-scroll" scroll-y>
- <view class="rich-content">
- <rich-text :nodes="privacyContent"></rich-text>
- </view>
- </scroll-view>
- </view>
- </template>
- <script setup>
- import { ref, onMounted } from 'vue';
- import { getAgreement } from '@/api/auth';
- const privacyContent = ref('<p style="text-align: center; padding: 20px;">内容加载中...</p>');
- onMounted(async () => {
- try {
- const res = await getAgreement('privacy');
- if (res && res.data) {
- // 后端返回的对象包含 title 和 content,这里取 content 段落显示
- privacyContent.value = res.data.content || '<p style="text-align: center; padding: 20px;">暂无相关协议内容</p>';
-
- // 如果有标题,动态设置导航栏标题
- if (res.data.title) {
- uni.setNavigationBarTitle({
- title: res.data.title
- });
- }
- }
- } catch (err) {
- console.error('获取隐私政策失败:', err);
- privacyContent.value = '<p style="text-align: center; padding: 20px; color: #999;">协议加载失败,请稍后重试</p>';
- }
- });
- </script>
- <style lang="scss" scoped>
- .container {
- min-height: 100vh;
- background-color: #FFFFFF;
- }
- .content-scroll {
- height: 100vh;
- }
- .rich-content {
- padding: 0 40rpx 60rpx; // 核心:两侧保留40rpx间距
- box-sizing: border-box;
- }
- </style>
|