index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="agreement-detail-page">
  3. <nav-bar :title="title"></nav-bar>
  4. <view class="content-card" v-if="!loading">
  5. <text class="title">{{ agreementData.title || title }}</text>
  6. <rich-text :nodes="contentHtml" class="rich-content"></rich-text>
  7. </view>
  8. <view v-else class="loading-state">
  9. <text>协议内容加载中...</text>
  10. </view>
  11. </view>
  12. </template>
  13. <script setup>
  14. // @Author: Antigravity
  15. import { ref } from 'vue'
  16. import { onLoad } from '@dcloudio/uni-app'
  17. import { getAgreement } from '@/api/system/agreement'
  18. import navBar from '@/components/nav-bar/index.vue'
  19. const title = ref('协议详情')
  20. const agreementData = ref({})
  21. const contentHtml = ref('')
  22. const loading = ref(true)
  23. onLoad(async (options) => {
  24. if (options.title) title.value = decodeURIComponent(options.title)
  25. if (options.id) {
  26. fetchAgreement(options.id)
  27. }
  28. })
  29. const fetchAgreement = async (id) => {
  30. loading.value = true
  31. try {
  32. const res = await getAgreement(id)
  33. if (res) {
  34. agreementData.value = res
  35. // 解码 Base64 内容 (Admin端采用 btoa(unescape(encodeURIComponent(content))) 编码)
  36. if (res.content) {
  37. try {
  38. contentHtml.value = decodeURIComponent(escape(atob(res.content)))
  39. } catch (e) {
  40. // 如果解码失败,回显原始内容
  41. contentHtml.value = res.content
  42. }
  43. } else {
  44. contentHtml.value = '暂无协议内容'
  45. }
  46. }
  47. } catch (error) {
  48. console.error('获取协议详情失败', error)
  49. } finally {
  50. loading.value = false
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .agreement-detail-page { min-height: 100vh; background: #f7f8fa; padding-bottom: calc(40rpx + env(safe-area-inset-bottom)); }
  56. .content-card { background: #fff; margin: 24rpx; border-radius: 24rpx; padding: 40rpx 32rpx; box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.03); }
  57. .title { display: block; font-size: 36rpx; font-weight: 800; color: #333; margin-bottom: 32rpx; position: relative; padding-bottom: 24rpx; border-bottom: 2rpx solid #EEEEEE; }
  58. .rich-content { display: block; font-size: 28rpx; color: #555; line-height: 1.8; word-break: break-all; }
  59. .loading-state { text-align: center; padding: 100rpx 0; color: #999; font-size: 28rpx; }
  60. </style>