Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Mar 26, 2021
1 parent 1138f49 commit 283f364
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions plugins/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@
import { judgePermission } from './permission'
// #endif
import Vue from 'vue';
//金额过滤
Vue.filter('money', function(val) {
console.log(val);
if (val) {
let value = Math.round(parseFloat(val) * 100) / 100;
let valMoney = value.toString().split(".");
if (valMoney.length == 1) {
value = value.toString() + ".00";
return value;
}
if (valMoney.length > 1) {
if (valMoney[1].length < 2) {
value = value.toString() + "0";
}
return value;
}
return value;
} else {
return "0.00";
}
})
/**
* 时间转换为XX前
*/
Expand Down Expand Up @@ -502,4 +481,34 @@ export const getAppWxLatLon = function(successCallback, errCallback) {
}
});
// #endif
}
}

//金额过滤
Vue.filter('money', function(val) {
console.log(val);
if (val) {
let value = Math.round(parseFloat(val) * 100) / 100;
let valMoney = value.toString().split(".");
if (valMoney.length == 1) {
value = value.toString() + ".00";
return value;
}
if (valMoney.length > 1) {
if (valMoney[1].length < 2) {
value = value.toString() + "0";
}
return value;
}
return value;
} else {
return "0.00";
}
});
//时间格式化
Vue.filter('timeFormat', function(val, fmt = 'yyyy-MM-dd hh:mm:ss') {
if (val) {
return new Date(val).format(fmt);
} else {
return "";
}
});

0 comments on commit 283f364

Please sign in to comment.