123456789101112131415161718192021222324252627282930313233343536373839 |
- import request from './request'
- export function withInstall(component) {
- component.install = function (app) {
- app.component(component.name, component);
- };
- return component;
- }
- export function WithInstallOfGlobalMethod(globalName, method) {
- method.install = function (app) {
- app.prototype[globalName] = method;
- };
- return method;
- }
- export {
- request
- }
- export function calcPercent(bn, tq) {
- if (bn - tq === 0) {
- return '0%'
- }
- if (tq === 0) {
- return '100%'
- }
- return `${(parseInt((Math.abs(bn - tq) / tq).toFixed(2) * 100 ))}%`
- }
- export function getState(bn, tq) {
- if (bn -tq > 0) {
- return 1;
- } else if (bn - tq < 0){
- return -1;
- } else {
- return 0;
- }
- }
|