binxie
2023-06-26 dd004276162a2bf9d042ff0aaa569dc30a95d827
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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 =
                '<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);
        // 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);
    }
}