<template>
  <div class="app-container">
    <div class="tinymce-title"><span class="title-tip">*</span>售后无忧：</div>
    <tinymce v-model="afterSale" :height="300" />
    <div slot="footer" class="dialog-footer" style="float: right;padding:80px 0 80px 0;">
      <el-button type="primary" style="width:100px;" :loading="loadingbut" @click="onSubmite()">{{ loadingbuttext }}</el-button>
    </div>
  </div>
</template>

<script>
import Tinymce from '@/components/Tinymce'
import { getOrganizeInfo, updateOrganizeInfo } from '@/api/other'
export default {
  components: {
    Tinymce
  },
  data() {
    return {
      isContent: false,
      afterSale: '',
      loadingbut: false,
      loadingbuttext: '提交'
    }
  },
  computed: {
    organizeID() {
      return this.$store.getters.organizeID
    }
  },
  created() {
    this.initData()
  },
  methods: {
    initData() {
      getOrganizeInfo({ id: this.organizeID }).then(response => {
        console.log(response)
        this.afterSale = response.data.afterSale
      })
    },
    onSubmite() {
      if (this.afterSale === '') {
        this.$message({ message: '内容不能为空', type: 'warning', center: true })
        return
      }
      this.loadingbut = true
      this.loadingbuttext = '提交中'
      updateOrganizeInfo({ id: this.organizeID, afterSale: this.afterSale }).then(response => {
        this.$message({ message: response.msg, type: 'success', center: true })
        this.loadingbut = false
        this.loadingbuttext = '提交'
        setTimeout(() => {
          this.initData()
        }, 1000)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  .tinymce-title{
    font-size: 14px;
    line-height: 20px;
    padding: 10px 0;
    text-align: left;
    font-weight: bold;
  }
  .title-tip{
    color: red;
  }
</style>
