import { LightningElement,track} from 'lwc'; import initReminder from '@salesforce/apex/LexLicenceReminderController.initReminder'; export default class LexLicenceReminder extends LightningElement { @track days = 0; @track isShowReminder = false; @track msg = ''; connectedCallback(){ initReminder() .then(result=>{ if (result.result == 'Success') { this.days = result.days; this.isShowReminder = result.isShowReminder; if(this.days > 0){ this.msg = '您的医疗器械经营企业许可证还有'+this.days+'天就到期了!'; }else if(this.days == 0){ this.msg = '您的医疗器械经营企业许可证今天就到期了!'; }else if(this.days < 0){ var days = this.days * -1 this.msg = '您的医疗器械经营企业许可证已经过期'+days+'天了!'; } } else { console.log("Error:" + result.errorMsg); this.showMyToast(result.errorMsg, '', 'error'); } }) .catch(error => { console.log("Error:" + JSON.stringify(error)); this.showMyToast('初始化提醒失败', JSON.stringify(error), 'error'); }) } showMyToast(title, message, variant) { console.log('show custom message'); var iconName = ''; var content = ''; if(variant == 'success'){ iconName = 'utility:check'; }else{ iconName = 'utility:error'; } if(message != ''){ content = '

'+title+'

'+message+'
'; }else{ content = '

'+title+'

'; } this.template.querySelector('c-common-toast'). showToast(variant,content,iconName,10000); // var mode; // if(this.isNoteStay){ // mode ='sticky'; // }else{ // mode = 'dismissable'; // } // const evt = new ShowToastEvent({ // title: title, // message: message, // variant: variant, // mode: mode // }); // this.dispatchEvent(evt); } }