|
|
let Vue = require('vue');
|
|
|
|
|
|
/**
|
|
|
module.exports = (Vue) => {
|
|
|
/**
|
|
|
* 替换参数
|
|
|
*
|
|
|
* @example
|
...
|
...
|
@@ -8,7 +7,7 @@ let Vue = require('vue'); |
|
|
*
|
|
|
* {value | resize 100 200 2} ==> /100/200/2
|
|
|
*/
|
|
|
Vue.filter('resize', (value, width, height, mode) => {
|
|
|
Vue.filter('resize', (value, width, height, mode) => {
|
|
|
return value ? value.replace(/(\{width}|\{height}|\{mode})/g, function($0) {
|
|
|
const dict = {
|
|
|
'{width}': width,
|
...
|
...
|
@@ -18,16 +17,16 @@ Vue.filter('resize', (value, width, height, mode) => { |
|
|
|
|
|
return dict[$0];
|
|
|
}) : '';
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 性别款式
|
|
|
*
|
|
|
* @example
|
|
|
*
|
|
|
* {value | gender}
|
|
|
*/
|
|
|
Vue.filter('clothingGenderIdentity', (value) => {
|
|
|
Vue.filter('clothingGenderIdentity', (value) => {
|
|
|
let ret = null;
|
|
|
|
|
|
switch (value) {
|
...
|
...
|
@@ -42,21 +41,21 @@ Vue.filter('clothingGenderIdentity', (value) => { |
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 品牌URL
|
|
|
*
|
|
|
* @param value brand domain
|
|
|
*/
|
|
|
Vue.filter('brandUrl', (value) => {
|
|
|
Vue.filter('brandUrl', (value) => {
|
|
|
return `/product/shop/${value}`;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 产品 URL
|
|
|
*/
|
|
|
Vue.filter('goodsUrl', (product, kind)=> {
|
|
|
Vue.filter('goodsUrl', (product, kind)=> {
|
|
|
let productId, goodsId, cnAlphabet;
|
|
|
|
|
|
switch (kind) {
|
...
|
...
|
@@ -72,15 +71,15 @@ Vue.filter('goodsUrl', (product, kind)=> { |
|
|
}
|
|
|
|
|
|
return `/product/pro_${productId}_${goodsId}/${cnAlphabet}.html`;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 订单状态
|
|
|
* @example
|
|
|
* {value | order}
|
|
|
* 状态 0:待付款,1-3:待发货,4-5:待收货(0:未付款,1:已付款,2:备货中,3:配货中,4:已发货,5:运输中,6:已完成)
|
|
|
*/
|
|
|
Vue.filter('convertOrderState', (value) => {
|
|
|
Vue.filter('convertOrderState', (value) => {
|
|
|
let stateTxt = '';
|
|
|
|
|
|
if (typeof value !== 'undefined') {
|
...
|
...
|
@@ -113,20 +112,20 @@ Vue.filter('convertOrderState', (value) => { |
|
|
break;
|
|
|
}
|
|
|
return stateTxt;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
Vue.filter('toFixed', (value, num) => {
|
|
|
Vue.filter('toFixed', (value, num) => {
|
|
|
if (typeof value === 'undefined') {
|
|
|
return;
|
|
|
}
|
|
|
return Number(value).toFixed(num || 2);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 转换时间
|
|
|
* yyyy-MM-dd hh:mm:ss
|
|
|
*/
|
|
|
Vue.filter('convertTime', (value) => {
|
|
|
Vue.filter('convertTime', (value) => {
|
|
|
if (typeof value === 'undefined') {
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -139,13 +138,13 @@ Vue.filter('convertTime', (value) => { |
|
|
let s = date.getSeconds();
|
|
|
|
|
|
return Y + M + D + h + m + s;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 格式化时间
|
|
|
*/
|
|
|
Vue.filter('formatUnixTime', (value) => {
|
|
|
Vue.filter('formatUnixTime', (value) => {
|
|
|
// return moment.unix(value).format(format || 'YYYY-MM-DD HH:mm:ss');
|
|
|
|
|
|
if (typeof value === 'undefined') {
|
...
|
...
|
@@ -164,9 +163,9 @@ Vue.filter('formatUnixTime', (value) => { |
|
|
|
|
|
// return M + '.' + D + ' ' + h + ' ' + ' ' + m + ' ' + s;
|
|
|
return `${M}.${D} ${h}:${m}`;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
const zhDict = {
|
|
|
const zhDict = {
|
|
|
color: '颜色',
|
|
|
gender: '性别',
|
|
|
size: '尺寸',
|
...
|
...
|
@@ -176,9 +175,9 @@ const zhDict = { |
|
|
discount: '折扣',
|
|
|
style: '风格',
|
|
|
ageLevel: '年龄'
|
|
|
};
|
|
|
};
|
|
|
|
|
|
const enDict = {
|
|
|
const enDict = {
|
|
|
color: 'Color',
|
|
|
gender: 'Gender',
|
|
|
size: 'Size',
|
...
|
...
|
@@ -188,17 +187,18 @@ const enDict = { |
|
|
discount: 'Sale',
|
|
|
style: 'Style',
|
|
|
ageLevel: 'Age'
|
|
|
};
|
|
|
};
|
|
|
|
|
|
Vue.filter('filter-cn', (value, prefix) => {
|
|
|
Vue.filter('filter-cn', (value, prefix) => {
|
|
|
prefix = prefix || '';
|
|
|
value = zhDict[value] || '';
|
|
|
return prefix + value || '';
|
|
|
});
|
|
|
});
|
|
|
|
|
|
Vue.filter('filter-en-cn', value => {
|
|
|
Vue.filter('filter-en-cn', value => {
|
|
|
const cn = zhDict[value] || '';
|
|
|
const en = enDict[value] || '';
|
|
|
|
|
|
return en + cn;
|
|
|
}); |
|
|
});
|
|
|
}; |
...
|
...
|
|