serviceAgreementDetail.vue 2.9 KB

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