index.vue 3.7 KB

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