Reinit project
This commit is contained in:
43
src/utils/transform.ts
Normal file
43
src/utils/transform.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import BigNumber from 'bignumber.js';
|
||||
import _ from 'lodash';
|
||||
import { AreaCode, Estate } from '@/types/common';
|
||||
|
||||
export function encodePhone(code: AreaCode, phone: string): string {
|
||||
if (code && code.areacode) return `+${code.areacode}-${phone || ''}`;
|
||||
return phone;
|
||||
}
|
||||
|
||||
export function showRate(value: BigNumber) {
|
||||
return `${value.times(100).decimalPlaces(2)}%`;
|
||||
}
|
||||
|
||||
export function calcEstate(it: Estate) {
|
||||
const profit = new BigNumber(it.profit || '0');
|
||||
const taxfee = new BigNumber(it.taxfee || '0');
|
||||
const inPrice = new BigNumber(it.inPrice || '0');
|
||||
|
||||
it.profitShow = showRate(profit);
|
||||
it.taxfeeShow = showRate(taxfee);
|
||||
|
||||
const taxfeeAmount = inPrice.times(taxfee).decimalPlaces(2);
|
||||
it.taxfeeAmount = taxfeeAmount.toString();
|
||||
const outPrice = inPrice.times(profit.plus(1)).decimalPlaces(2);
|
||||
it.outPrice = outPrice.toString();
|
||||
it.profitPrice = outPrice.minus(inPrice).minus(taxfeeAmount).toString();
|
||||
}
|
||||
|
||||
export const supportedLangs = [
|
||||
{
|
||||
lang: 'zh-CN',
|
||||
text: '中文',
|
||||
},
|
||||
{
|
||||
lang: 'en-US',
|
||||
text: 'English',
|
||||
},
|
||||
];
|
||||
|
||||
export function fromLangToText(lang: string) {
|
||||
const target = _.find(supportedLangs, { lang });
|
||||
return target && target.text;
|
||||
}
|
||||
Reference in New Issue
Block a user