import AWSService from './AWSService';
|
export{AWSService};
|
|
const catchError = (_this,whereStr,error) =>{
|
let message = error
|
if(error.body && error.body.message){
|
message = error.body.message;
|
}else{
|
message += ''
|
}
|
console.log(message);
|
let em = {
|
'没有访问权限':/.+没有.+访问权限/,
|
'You do not have access' : /You do not have access.+/
|
}
|
|
for(let k in em){
|
|
if(em[k].test(message)){
|
message = k;
|
}
|
}
|
message = whereStr + message;
|
console.log(message);
|
showError(_this,message);
|
}
|
|
const showSuccess = (_this,message)=>{
|
const evt = new ShowToastEvent({
|
title: 'Notice',
|
message: message,
|
variant: 'success'
|
});
|
_this.dispatchEvent(evt);
|
}
|
|
const showError = (_this,message)=>{
|
const evt = new ShowToastEvent({
|
title: 'Notice',
|
message: message,
|
variant: 'error',
|
mode : 'sticky'
|
});
|
_this.dispatchEvent(evt);
|
}
|
|
const formatPrice = (num) =>{
|
// if( !num ) return '0.00'
|
try {
|
let numStr = num.toFixed(2);
|
let arr = numStr.split('.');
|
return parseInt(arr[0]).toLocaleString()+'.'+arr[1];
|
} catch (error) {
|
console.log(error);
|
return '0.00'
|
}
|
|
}
|