detail.vue 1.75 KB
<template>
  <view class="page">
    <scroll-view class="scroll" scroll-y>
      <view class="detail-page">
        <view class="section">
          <text class="row company">{{ detail.title }}</text>
          <view class="row"><text class="label">内容</text><text class="value">{{ detail.content }}</text></view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import { getContentApi } from '@/api/message.js'

export default {
  data() {
    return {
      detail: { title: '', content: '' }
    }
  },
  onLoad(options) {
    const id = options && (options.id || options.code) || ''
    if (!id) return
    this.loadDetail(id)
  },
  methods: {
    loadDetail(id) {
      getContentApi(id)
        .then(res => {
          const d = res && res.data ? res.data : {}
          this.detail = { title: d.title || '', content: d.content || '' }
        })
        .catch(() => {
          this.detail = { title: '', content: '' }
          uni.showToast({ title: '加载失败', icon: 'none' })
        })
    }
  }
}
</script>

<style lang="scss" scoped>
.page { display: flex; flex-direction: column; height: 100%; }
.scroll { flex: 1; padding: 8rpx 0 0; }
.detail-page { background: #f3f3f3; }
.section { padding: 32rpx; background: #fff; }
.row {
  display: flex;
  margin-bottom: 28rpx;

  &:last-child {
    margin-bottom: 0;
  }

  &.company {
    font-size: 36rpx;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.9);
    line-height: 50rpx;
  }

  .label {
    max-width: 420rpx;
    line-height: 32rpx;
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.6);
  }

  .value {
    flex: 1;
    line-height: 32rpx;
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.9);
    text-align: right;

    &.act {
      color: $theme-primary;
    }
  }
}
</style>