<template>
  <div class="app-container" style="overflow-y: auto">
    <div class="cmain">
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <div class="bos">
          <div class="lab">
            <div class="bsg"></div>
            <div class="tit">协议(小程序上架需要)</div>
          </div>
          <el-form-item label="用户协议" prop="privacy">
            <editor v-model="form.agreement" placeholder="请输入"></editor>
          </el-form-item>
          <el-form-item label="隐私政策" prop="privacy">
            <editor v-model="form.privacy" placeholder="请输入"></editor>
          </el-form-item>
        </div>
      </el-form>
      <div>
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="$layer.close(layerid)">取 消</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {},
      rules: {
        privacy: [{ required: true, message: '不能为空', trigger: 'blur' }],
        agreement: [{ required: true, message: '不能为空', trigger: 'blur' }]
      }
    };
  },
  mounted() {
    this.ajax({ url: '/work/introduction/detail' }).then((response) => {
      this.form = response.data;
    });
  },
  methods: {
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.form.id) {
            this.ajax({ method: 'post', url: '/work/introduction/edit', data: this.form }).then((response) => {
              this.$modal.msgSuccess('修改成功');
            });
          }
        }
      });
    }
  }
};
</script>
