// components/dialog/dialog.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    showDialog: {
      type: Boolean,
      value: false,
      observer(newval) {
        this.setData({
          showDialog: newval,
        });
      },
    },
    message:{
      type: String,
      value: '',
      observer(newval) {
        this.setData({
          message: newval,
        });
      },
    },
    cancelBtn:{
      type: Boolean,
      value: true,
      observer(newval) {
        this.setData({
          cancelBtn: newval,
        });
      },
    },
    dialogTitle:{
      type: String,
      value: '温馨提示',
      observer(newval) {
        this.setData({
          dialogTitle: newval,
        });
      },
    },
    confirmColor:{
      type: String,
      value: '#3CC7C0',
      observer(newval) {
        this.setData({
          confirmColor: newval,
        });
      },
    },
    canceltext:{
      type: String,
      value: '取消',
      observer(newval) {
        this.setData({
          canceltext: newval,
        });
      },
    },
    confirmtext:{
      type: String,
      value: '确定',
      observer(newval) {
        this.setData({
          confirmtext: newval,
        });
      },
    },
  
  },

  /**
   * 组件的初始数据
   */
  data: {
    showDialog: false,
    message:'',
    confirmColor:'#3CC7C0',
    dialogTitle:"温馨提示",
    cancelBtn:true,
    canceltext:'取消',
    confirmtext:'确定'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onConfirm() {
      this.setData({ showDialog: false });
      this.triggerEvent("confirm",true)
    },
  
    onClose() {
      this.setData({ showDialog: false });
      this.triggerEvent("close",true)
    }
  }
})
