<template>
<view id="brand-detail">
    <!--<wxparser rich-text="{{richText.brand_detail}}" />-->
    <u-parse :content="richText.brand_detail"  v-if="richText.brand_detail" />
</view>
</template>
<script>
import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';

import uParse from '@/components/gaoyia-parse/parse.vue';

export default {
  data() {
    return {
      richText: ''
    };
  },

  onLoad(e) {
    this.getBrandDetail(e.id);
  },

  components: {
      uParse
  },
  props: {},
  methods: {
    //获取品牌详情
    getBrandDetail(id) {
      wx.showLoading({
        title: "加载中",
        mask: true
      });
      this.$http.get({
        api: 'api/brand/detail/' + id
      }).then(res => {
        if (res.statusCode == 200) {
          res = res.data;

          if (res.status) {
            this.setData({
              richText: res.data.detail
            });
            wx.setNavigationBarTitle({
              title: res.data.detail.name
            });
          } else {
            wx.showModal({
              content: res.message || '请求失败',
              showCancel: false
            });
          }
        } else {
          wx.showModal({
            content: res.message || '请求失败',
            showCancel: false
          });
        }

        this.setData({
          show: false
        });
        wx.hideLoading();
      }).catch(rej => {
        wx.hideLoading();
        wx.showModal({
          content: res.message || '请求失败',
          showCancel: false
        });
      });
    },

    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  },
  computed: {},
  watch: {}
};
</script>
<style rel="stylesheet/less" lang="less">
    @import "detail";
</style>