binxie
2023-06-26 b5c5eb130ca0848124f9d136af4be142ad5aac07
force-app/main/default/lwc/lexLicenceReminder/lexLicenceReminder.js
@@ -1,4 +1,4 @@
import { LightningElement, track } from 'lwc';
import { LightningElement,track} from 'lwc';
import initReminder from '@salesforce/apex/LexLicenceReminderController.initReminder';
export default class LexLicenceReminder extends LightningElement {
@@ -6,63 +6,47 @@
    @track isShowReminder = false;
    @track msg = '';
    connectedCallback() {
    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');
        .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+'天了!';
                }
            })
            .catch((error) => {
                console.log('Error:' + JSON.stringify(error));
                this.showMyToast(
                    '初始化提醒失败',
                    JSON.stringify(error),
                    'error'
                );
            });
            } 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(variant == 'success'){
           iconName = 'utility:check';
        }else{
           iconName = 'utility:error';
        }
        if (message != '') {
            content =
                '<h2><strong>' +
                title +
                '<strong/></h2><h5>' +
                message +
                '</h5>';
        } else {
            content = '<h2><strong>' + title + '<strong/></h2>';
        if(message != ''){
           content = '<h2><strong>'+title+'<strong/></h2><h5>'+message+'</h5>';
        }else{
           content = '<h2><strong>'+title+'<strong/></h2>';
        }
        this.template
            .querySelector('c-common-toast')
            .showToast(variant, content, iconName, 10000);
        this.template.querySelector('c-common-toast').
        showToast(variant,content,iconName,10000);
        // var mode;
        // if(this.isNoteStay){
        //     mode ='sticky';