|
@@ -22,6 +22,31 @@ Vue.filter("timestamp", function(link) {
|
|
|
return link + '?t=' + new Date().getTime();
|
|
|
});
|
|
|
|
|
|
+//截取第一张照片且判断是否有图片,没有图片输入默认图片
|
|
|
+Vue.filter("firstImg",function(arr,sizeType,imgType){
|
|
|
+ //图片类型判断
|
|
|
+ if(arr){
|
|
|
+ if(arr instanceof Array){
|
|
|
+ img = arr[0]
|
|
|
+ }else{
|
|
|
+ img = arr.split(',')[0]
|
|
|
+ }
|
|
|
+ }else if(!arr){
|
|
|
+ //如果没有图片则随机输出一张
|
|
|
+ // if(imgType === 'farmer'){
|
|
|
+ // const farmerList = ['carbon2/farmer/1.png','carbon2/farmer/2.png']
|
|
|
+ // img = farmerList[Math.floor(Math.random() * farmerList.length)];
|
|
|
+ // }
|
|
|
+ // img = '/static/img/inbuild.png'
|
|
|
+ }
|
|
|
+ // return config.imgUrl + img;
|
|
|
+ return img;
|
|
|
+});
|
|
|
+
|
|
|
+//七牛云压缩图片
|
|
|
+Vue.filter("miniImg",function(img,quality){
|
|
|
+ return img+'?imageMogr2/quality/'+quality
|
|
|
+});
|
|
|
|
|
|
//单位米m转换为单位千米km,提醒:传递参数不要带引号,如kmUnit('100')会返回0m。
|
|
|
Vue.filter("kmUnit", function(m) {
|
|
@@ -101,8 +126,14 @@ Vue.filter("energyTpye", function(value) {
|
|
|
|
|
|
});
|
|
|
|
|
|
-// 免费时长
|
|
|
-Vue.filter("freeDuration", function(value) {
|
|
|
- return '0天0时30分0秒';
|
|
|
-
|
|
|
+// 免费时长
|
|
|
+Vue.filter("freeDuration", function(value){
|
|
|
+ console.log(value);
|
|
|
+ let createTime = new Date(value).valueOf(),
|
|
|
+ freeTime = new Date('2022-06-20 00:00:00').valueOf(),
|
|
|
+ freeTxt = '0天0时15分0秒'
|
|
|
+ if (createTime > freeTime) {
|
|
|
+ freeTxt = '0天0时30分0秒'
|
|
|
+ }
|
|
|
+ return freeTxt
|
|
|
});
|