<template>
  <view class="content">
    <view>
      <view class="title" v-if="content.title">{{content.title}}</view>
      <view class="time" v-if="content.createtime">发布时间：{{content.createtime}}</view>
      <u-parse :content="content.content" @preview="preview" @navigate="navigate"></u-parse>
    </view>
  </view>
</template>

<script>
  import {
    mapState
  } from "vuex";
  import uParse from '@/components/u-parse/u-parse.vue'
  export default {
    data() {
      return {
        content: "",
        url: null
      }
    },
    components: {
      uParse
    },
    computed: {
      ...mapState(["user", "appTheme"]),
    },
    onLoad(option) {
      // 导航栏颜色
      uni.setNavigationBarColor({
        frontColor: '#ffffff',
        backgroundColor: this.appTheme,
      })
      // 
      console.log(option)
      if (option.id) {
        this.getOrderDetail(option.id);
      }
      if (option.url) {
        this.url = option.url
      } else {
        this.url = null
      }

    },
    methods: {
      getOrderDetail(orderno) {
        this.$model.getBannerDetail({
          id: orderno
        }).then(res => {
          if (res.code != 0) return
          this.content = res.data
          console.log("轮播详情", res)
        });
      },
      preview(src, e) {
        // do something
      },
      navigate(href, e) {
        // do something
      }
    }
  }
</script>

<style scoped>
  @import url("@/components/u-parse/u-parse.css");

  .content {
    padding: 30rpx;
  }

  .title {
    width: 100%;
    margin-bottom: 15px;
    text-align: left;
    font-size: 18px;
    font-weight: bold;
  }

  .time {
    width: 100%;
    text-align: left;
    margin-bottom: 15px;
    color: #666;
  }
</style>
