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
81
82
83
84
import { LightningElement, track } from 'lwc';
import initAgency from '@salesforce/apex/LexTopPageController.initAgency';
 
export default class LexAgencyInfo extends LightningElement {
    @track showSpinner = true;
    @track showPage = false;
    @track accountInfo;
    @track accountId;
    @track activeSections = ['A', 'B', 'C'];
    //是否一直显示提示
    @track isNoteStay = true;
 
    connectedCallback() {
        this.init();
    }
 
    init() {
        this.showSpinner = true;
        initAgency()
            .then((result) => {
                this.showPage = true;
                this.isNoteStay = result.isNoteStay;
                if (result.result == 'Success') {
                    this.accountInfo = result.accountInfo;
                    this.accountId = result.accountInfo.Id;
                    this.showSpinner = false;
                } else {
                    this.showSpinner = false;
                    console.log('Error:' + result.errorMsg);
                    this.showMyToast(
                        '初始化页面失败',
                        result.errorMsg,
                        'error'
                    );
                }
            })
            .catch((error) => {
                this.showSpinner = false;
                console.log('Error:' + 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);
    }
}