agreement-detail.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="container">
  3. <!-- 自定义头部 -->
  4. <view class="custom-header">
  5. <view class="header-left" @click="navBack">
  6. <image class="back-icon" src="/static/icons/chevron_right_dark.svg" style="transform: rotate(180deg);"></image>
  7. </view>
  8. <text class="header-title">{{ title || '协议详情' }}</text>
  9. <view class="header-right"></view>
  10. </view>
  11. <view class="header-placeholder"></view>
  12. <!-- 内容区域 -->
  13. <scroll-view scroll-y class="content-scroll">
  14. <view class="content-card">
  15. <rich-text :nodes="content" class="rich-text"></rich-text>
  16. </view>
  17. <view class="safe-area-inset-bottom"></view>
  18. </scroll-view>
  19. </view>
  20. </template>
  21. <script>
  22. import { getAgreement } from '@/api/system/agreement'
  23. export default {
  24. data() {
  25. return {
  26. id: null,
  27. title: '',
  28. content: '',
  29. loading: false
  30. }
  31. },
  32. onLoad(options) {
  33. if (options.id) {
  34. this.id = options.id;
  35. this.loadDetail();
  36. }
  37. },
  38. methods: {
  39. async loadDetail() {
  40. if (!this.id) return;
  41. uni.showLoading({ title: '加载中...' });
  42. try {
  43. const res = await getAgreement(this.id);
  44. if (res.code === 200 && res.data) {
  45. this.title = res.data.title;
  46. this.content = res.data.content;
  47. // 设置原生导航栏标题(作为兜底)
  48. uni.setNavigationBarTitle({ title: this.title });
  49. } else {
  50. uni.showToast({ title: res.msg || '获取失败', icon: 'none' });
  51. }
  52. } catch (err) {
  53. console.error('获取协议详情失败:', err);
  54. uni.showToast({ title: '网络错误', icon: 'none' });
  55. } finally {
  56. uni.hideLoading();
  57. }
  58. },
  59. navBack() {
  60. uni.navigateBack({ delta: 1 });
  61. }
  62. }
  63. }
  64. </script>
  65. <style>
  66. page {
  67. background-color: #fff;
  68. }
  69. .container {
  70. display: flex;
  71. flex-direction: column;
  72. height: 100vh;
  73. }
  74. /* 自定义头部统一风格 */
  75. .custom-header {
  76. position: fixed;
  77. top: 0;
  78. left: 0;
  79. width: 100%;
  80. height: 88rpx;
  81. padding-top: var(--status-bar-height);
  82. background-color: #fff;
  83. display: flex;
  84. align-items: center;
  85. justify-content: space-between;
  86. padding-left: 30rpx;
  87. padding-right: 30rpx;
  88. box-sizing: content-box;
  89. z-index: 100;
  90. border-bottom: 1rpx solid #f5f5f5;
  91. }
  92. .header-placeholder {
  93. height: calc(88rpx + var(--status-bar-height));
  94. flex-shrink: 0;
  95. }
  96. .back-icon {
  97. width: 40rpx;
  98. height: 40rpx;
  99. }
  100. .header-title {
  101. font-size: 32rpx;
  102. font-weight: bold;
  103. color: #333;
  104. }
  105. .header-right {
  106. width: 40rpx;
  107. }
  108. .content-scroll {
  109. flex: 1;
  110. overflow: hidden;
  111. }
  112. .content-card {
  113. padding: 30rpx 40rpx;
  114. line-height: 1.6;
  115. }
  116. .rich-text {
  117. font-size: 28rpx;
  118. color: #333;
  119. }
  120. .safe-area-inset-bottom {
  121. height: constant(safe-area-inset-bottom);
  122. height: env(safe-area-inset-bottom);
  123. }
  124. </style>