index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. import { decodeBase64 } from '@/utils/index'
  24. export default {
  25. data() {
  26. return {
  27. id: null,
  28. title: '',
  29. content: '',
  30. loading: false,
  31. appName: '履约者',
  32. version: '2.0.6'
  33. }
  34. },
  35. onLoad(options) {
  36. if (options.title) {
  37. this.title = options.title;
  38. }
  39. if (options.id) {
  40. this.id = options.id;
  41. this.loadDetail();
  42. }
  43. this.getAppInfo();
  44. },
  45. methods: {
  46. async loadDetail() {
  47. if (!this.id) return;
  48. uni.showLoading({ title: '加载中...' });
  49. try {
  50. const res = await getAgreement(this.id);
  51. if (!this.title) {
  52. this.title = res.data.title;
  53. }
  54. this.content = decodeBase64(res.data.content);
  55. // 设置原生导航栏标题(作为兜底)
  56. uni.setNavigationBarTitle({ title: this.title });
  57. } catch (err) {
  58. console.error('获取协议详情失败:', err);
  59. uni.showToast({ title: err.message || '获取协议详情失败', icon: 'none' });
  60. } finally {
  61. uni.hideLoading();
  62. }
  63. },
  64. getAppInfo() {
  65. // #ifdef APP-PLUS
  66. plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
  67. this.version = widgetInfo.version || '2.0.6';
  68. this.appName = widgetInfo.name || '履约者';
  69. });
  70. // #endif
  71. // #ifndef APP-PLUS
  72. const systemInfo = uni.getSystemInfoSync();
  73. this.version = systemInfo.appVersion || '2.0.6';
  74. // #endif
  75. },
  76. navBack() {
  77. uni.navigateBack({ delta: 1 });
  78. }
  79. }
  80. }
  81. </script>
  82. <style>
  83. page {
  84. background-color: #fff;
  85. }
  86. .container {
  87. display: flex;
  88. flex-direction: column;
  89. height: 100vh;
  90. }
  91. /* 自定义头部统一风格 */
  92. .custom-header {
  93. position: fixed;
  94. top: 0;
  95. left: 0;
  96. width: 100%;
  97. height: 88rpx;
  98. padding-top: var(--status-bar-height);
  99. background-color: #fff;
  100. display: flex;
  101. align-items: center;
  102. justify-content: space-between;
  103. padding-left: 30rpx;
  104. padding-right: 30rpx;
  105. box-sizing: content-box;
  106. z-index: 100;
  107. border-bottom: 1rpx solid #f5f5f5;
  108. }
  109. .header-placeholder {
  110. height: calc(88rpx + var(--status-bar-height));
  111. flex-shrink: 0;
  112. }
  113. .back-icon {
  114. width: 40rpx;
  115. height: 40rpx;
  116. }
  117. .header-title {
  118. font-size: 32rpx;
  119. font-weight: bold;
  120. color: #333;
  121. }
  122. .header-right {
  123. width: 40rpx;
  124. }
  125. .content-scroll {
  126. flex: 1;
  127. overflow: hidden;
  128. }
  129. .content-card {
  130. padding: 30rpx 40rpx;
  131. line-height: 1.6;
  132. }
  133. .rich-text {
  134. font-size: 28rpx;
  135. color: #333;
  136. }
  137. .safe-area-inset-bottom {
  138. height: constant(safe-area-inset-bottom);
  139. height: env(safe-area-inset-bottom);
  140. }
  141. </style>