12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /**
- * 公共方法的封装
- */
- import Vue from 'vue'
- // 性别
- Vue.filter("filterSex", function(val) {
- if(val == 0){
- return '男';
- }else if(val == 1){
- return '女';
- }else {
- return '未知';
- }
- });
- // 链接加时间戳
- Vue.filter("timestamp", function(link) {
- return link + '?t=' + new Date().getTime();
- });
- // 时间去掉时分秒
- Vue.filter("timeSplit", function(time) {
- if(time) {
- return time.indexOf(" ") > -1 ? time.split(" ")[0] : time
- } else {
- return ""
- }
- });
- // 结账方式
- Vue.filter("filterPayWay", function(val) {
- if(val == 0){
- return '现销';
- }else if(val == 1){
- return '赊销';
- }else {
- return '未知';
- }
- });
- // 订单类型
- Vue.filter("filterOrderType", function(val) {
- if(val == 0){
- return '普通';
- }else if(val == 1){
- return '换货销售';
- }else {
- return '未知';
- }
- });
- // 收货方式
- Vue.filter("filterReceiveWay", function(val) {
- if(val == 0){
- return '物流';
- }else if(val == 1){
- return '自提';
- }else if(val == 2){
- return '顺丰直发';
- }else {
- return '未知';
- }
- });
- // 保留两位小数,自动补充零
- Vue.filter("filterToFixed", function(val) {
- var value=Math.round(parseFloat(val)*100)/100;
- if(!value){return '0'}
- var xsd=value.toString().split(".");
- if(xsd.length==1){
- value=value.toString()+".00";
- return value;
- }
- if(xsd.length>1){
- if(xsd[1].length<2){
- value=value.toString()+"0";
- }
- return value;
- }
- })
- // 订单状态
- Vue.filter("filterOrderState", function(val) {
- let orderList = ['审核中', '待付款', '待发货', '待收货', '已完成', '售后', '已关闭', '酒业出库', '物流出库']
- return orderList[val]
- });
|