Reinit project

This commit is contained in:
Limo Saplf
2019-08-31 20:44:15 +08:00
commit b51ae824c7
115 changed files with 20955 additions and 0 deletions

43
src/utils/transform.ts Normal file
View 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;
}