serviceAgreement.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="container">
  3. <!-- 内容区域 -->
  4. <scroll-view class="content" scroll-y>
  5. <view class="agreement-list">
  6. <view class="agreement-item" v-for="(item, index) in agreementList" :key="index" @click="goToDetail(item)">
  7. <text class="agreement-name">{{ item.name }}</text>
  8. <text class="arrow-right">></text>
  9. </view>
  10. </view>
  11. </scroll-view>
  12. </view>
  13. </template>
  14. <script>
  15. import { getServiceAgreementList, getAgreementTypeList } from '@/api/serviceAgreement'
  16. export default {
  17. data() {
  18. return {
  19. agreementList: [
  20. { id: 1, name: '用户服务协议', type: 'userService' },
  21. { id: 2, name: '用户注册协议', type: 'userRegister' },
  22. { id: 3, name: '隐私政策保护', type: 'privacy' }
  23. ]
  24. }
  25. },
  26. onLoad() {
  27. this.loadAgreementList()
  28. },
  29. methods: {
  30. async loadAgreementList() {
  31. try {
  32. uni.showLoading({ title: '加载中...' })
  33. const [listRes, typeRes] = await Promise.all([
  34. getServiceAgreementList(),
  35. getAgreementTypeList().catch(() => ({ code: 0 }))
  36. ])
  37. uni.hideLoading()
  38. if (listRes.code === 200 && listRes.data) {
  39. this.agreementList = Array.isArray(listRes.data) ? listRes.data : []
  40. } else {
  41. this.agreementList = []
  42. }
  43. // 如果有协议类型列表,可以用于筛选等功能
  44. if (typeRes.code === 200 && typeRes.data) {
  45. console.log('协议类型列表', typeRes.data)
  46. }
  47. } catch (e) {
  48. uni.hideLoading()
  49. console.error('加载服务协议列表失败', e)
  50. this.agreementList = []
  51. }
  52. },
  53. goBack() {
  54. uni.navigateBack()
  55. },
  56. goToDetail(item) {
  57. uni.navigateTo({
  58. url: `/pages_user/serviceAgreementDetail?type=${item.type}&id=${item.id}`
  59. })
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .container {
  66. min-height: 100vh;
  67. background: #f5f5f5;
  68. display: flex;
  69. flex-direction: column;
  70. }
  71. .navbar {
  72. display: flex;
  73. align-items: center;
  74. justify-content: space-between;
  75. padding: 20rpx 24rpx;
  76. background: #fff;
  77. border-bottom: 1rpx solid #f0f0f0;
  78. .nav-left {
  79. width: 60rpx;
  80. .back-icon {
  81. font-size: 36rpx;
  82. color: #333;
  83. font-weight: bold;
  84. }
  85. }
  86. .nav-title {
  87. flex: 1;
  88. text-align: center;
  89. font-size: 36rpx;
  90. font-weight: bold;
  91. color: #333;
  92. }
  93. .nav-right {
  94. display: flex;
  95. align-items: center;
  96. gap: 24rpx;
  97. width: 60rpx;
  98. justify-content: flex-end;
  99. .more-icon {
  100. font-size: 32rpx;
  101. color: #333;
  102. }
  103. .eye-icon {
  104. font-size: 32rpx;
  105. color: #333;
  106. }
  107. }
  108. }
  109. .content {
  110. flex: 1;
  111. }
  112. .agreement-list {
  113. background: #fff;
  114. margin: 24rpx;
  115. border-radius: 16rpx;
  116. overflow: hidden;
  117. .agreement-item {
  118. display: flex;
  119. align-items: center;
  120. justify-content: space-between;
  121. padding: 32rpx 24rpx;
  122. border-bottom: 1rpx solid #f0f0f0;
  123. &:last-child {
  124. border-bottom: none;
  125. }
  126. .agreement-name {
  127. font-size: 28rpx;
  128. color: #333;
  129. }
  130. .arrow-right {
  131. font-size: 32rpx;
  132. color: #999;
  133. }
  134. }
  135. }
  136. </style>