
import Message from '../../miniprogram_npm/tdesign-miniprogram/message/index';
export default Behavior({
  data: {
    $messageId: 't-message',
  },
  lifetimes: {},
  methods: {
    showMessage(type: 'info' | 'success' | 'warning' | 'error', content: string, duration = 3000) {
      (<any>Message)[type]({
        selector: `#${this.data.$messageId}`,
        offset: [90, 32],
        duration, content,
      });
    },
    showInfoMessage(content: string, duration?: number) { this.showMessage('info', content, duration); },
    showSuccessMessage(content: string, duration?: number) { this.showMessage('success', content, duration); },
    showWarnMessage(content: string, duration?: number) { this.showMessage('warning', content, duration); },
    showErrorMessage(content: string, duration?: number) { this.showMessage('error', content, duration); },
  }
});

export function getTickleContext(this: any) {
  return this as Tickle;
}
