| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <view class="container">
- <!-- 导航栏 -->
- <view class="navbar">
- <view class="nav-left" @click="goBack">
- <text class="back-icon"><</text>
- </view>
- <view class="nav-title">{{ agreementTitle }}</view>
- <view class="nav-right">
- <text class="more-icon">...</text>
- <text class="eye-icon">O</text>
- </view>
- </view>
-
- <!-- 内容区域 -->
- <scroll-view class="content" scroll-y>
- <view class="agreement-content" v-html="agreementContent"></view>
- </scroll-view>
- </view>
- </template>
- <script>
- import { getServiceAgreementDetail } from '@/api-js/serviceAgreement'
- export default {
- data() {
- return {
- agreementType: '',
- agreementId: '',
- agreementTitle: '服务协议',
- agreementContent: ''
- }
- },
- onLoad(options) {
- if (options.type) {
- this.agreementType = options.type
- }
- if (options.id) {
- this.agreementId = options.id
- }
- this.setTitle()
- this.loadAgreementDetail()
- },
- methods: {
- setTitle() {
- const titleMap = {
- 'userService': '用户服务协议',
- 'userRegister': '用户注册协议',
- 'privacy': '隐私政策保护'
- }
- this.agreementTitle = titleMap[this.agreementType] || '服务协议'
- },
- async loadAgreementDetail() {
- try {
- uni.showLoading({ title: '加载中...' })
- const res = await getServiceAgreementDetail({
- type: this.agreementType,
- id: this.agreementId
- })
- uni.hideLoading()
-
- if (res.code === 200 && res.data) {
- this.agreementContent = res.data.content || '暂无内容'
- if (res.data.title) {
- this.agreementTitle = res.data.title
- }
- } else {
- this.agreementContent = '暂无内容,请稍后再试'
- }
- } catch (e) {
- uni.hideLoading()
- console.error('加载协议详情失败', e)
- this.agreementContent = '加载失败,请稍后再试'
- }
- },
- goBack() {
- uni.navigateBack()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- min-height: 100vh;
- background: #fff;
- display: flex;
- flex-direction: column;
- }
- .navbar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 20rpx 24rpx;
- background: #fff;
- border-bottom: 1rpx solid #f0f0f0;
-
- .nav-left {
- width: 60rpx;
-
- .back-icon {
- font-size: 36rpx;
- color: #333;
- font-weight: bold;
- }
- }
-
- .nav-title {
- flex: 1;
- text-align: center;
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- }
-
- .nav-right {
- display: flex;
- align-items: center;
- gap: 24rpx;
- width: 60rpx;
- justify-content: flex-end;
-
- .more-icon {
- font-size: 32rpx;
- color: #333;
- }
-
- .eye-icon {
- font-size: 32rpx;
- color: #333;
- }
- }
- }
- .content {
- flex: 1;
- }
- .agreement-content {
- padding: 32rpx 24rpx;
- font-size: 28rpx;
- color: #333;
- line-height: 1.8;
- word-wrap: break-word;
-
- ::v-deep p {
- margin-bottom: 16rpx;
- }
-
- ::v-deep h1,
- ::v-deep h2,
- ::v-deep h3 {
- font-weight: bold;
- margin: 24rpx 0 16rpx;
- }
-
- ::v-deep ul,
- ::v-deep ol {
- padding-left: 40rpx;
- margin-bottom: 16rpx;
- }
- }
- </style>
|