serviceAgreementDetail.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="container">
  3. <!-- 内容区域 -->
  4. <scroll-view class="content" scroll-y>
  5. <view class="agreement-content" v-html="agreementContent"></view>
  6. </scroll-view>
  7. </view>
  8. </template>
  9. <script>
  10. import { getServiceAgreementDetail } from '@/api-js/serviceAgreement'
  11. export default {
  12. data() {
  13. return {
  14. agreementType: '',
  15. agreementId: '',
  16. agreementTitle: '服务协议',
  17. agreementContent: ''
  18. }
  19. },
  20. onLoad(options) {
  21. if (options.type) {
  22. this.agreementType = options.type
  23. }
  24. if (options.id) {
  25. this.agreementId = options.id
  26. }
  27. this.setTitle()
  28. this.loadAgreementDetail()
  29. },
  30. methods: {
  31. setTitle() {
  32. const titleMap = {
  33. 'userService': '用户服务协议',
  34. 'userRegister': '用户注册协议',
  35. 'privacy': '隐私政策保护'
  36. }
  37. this.agreementTitle = titleMap[this.agreementType] || '服务协议'
  38. },
  39. async loadAgreementDetail() {
  40. try {
  41. uni.showLoading({ title: '加载中...' })
  42. const res = await getServiceAgreementDetail({
  43. type: this.agreementType,
  44. id: this.agreementId
  45. })
  46. uni.hideLoading()
  47. if (res.code === 200 && res.data) {
  48. this.agreementContent = res.data.content || '暂无内容'
  49. if (res.data.title) {
  50. this.agreementTitle = res.data.title
  51. }
  52. } else {
  53. this.agreementContent = '暂无内容,请稍后再试'
  54. }
  55. } catch (e) {
  56. uni.hideLoading()
  57. console.error('加载协议详情失败', e)
  58. this.agreementContent = '加载失败,请稍后再试'
  59. }
  60. },
  61. goBack() {
  62. uni.navigateBack()
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .container {
  69. min-height: 100vh;
  70. background: #fff;
  71. display: flex;
  72. flex-direction: column;
  73. }
  74. .navbar {
  75. display: flex;
  76. align-items: center;
  77. justify-content: space-between;
  78. padding: 20rpx 24rpx;
  79. background: #fff;
  80. border-bottom: 1rpx solid #f0f0f0;
  81. .nav-left {
  82. width: 60rpx;
  83. .back-icon {
  84. font-size: 36rpx;
  85. color: #333;
  86. font-weight: bold;
  87. }
  88. }
  89. .nav-title {
  90. flex: 1;
  91. text-align: center;
  92. font-size: 36rpx;
  93. font-weight: bold;
  94. color: #333;
  95. }
  96. .nav-right {
  97. display: flex;
  98. align-items: center;
  99. gap: 24rpx;
  100. width: 60rpx;
  101. justify-content: flex-end;
  102. .more-icon {
  103. font-size: 32rpx;
  104. color: #333;
  105. }
  106. .eye-icon {
  107. font-size: 32rpx;
  108. color: #333;
  109. }
  110. }
  111. }
  112. .content {
  113. flex: 1;
  114. }
  115. .agreement-content {
  116. padding: 32rpx 24rpx;
  117. font-size: 28rpx;
  118. color: #333;
  119. line-height: 1.8;
  120. word-wrap: break-word;
  121. ::v-deep p {
  122. margin-bottom: 16rpx;
  123. }
  124. ::v-deep h1,
  125. ::v-deep h2,
  126. ::v-deep h3 {
  127. font-weight: bold;
  128. margin: 24rpx 0 16rpx;
  129. }
  130. ::v-deep ul,
  131. ::v-deep ol {
  132. padding-left: 40rpx;
  133. margin-bottom: 16rpx;
  134. }
  135. }
  136. </style>