/** * 公共方法的封装 */ 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] });