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 = '

'+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); } }