index.vue 3.6 KB

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