Sfoglia il codice sorgente

苹果手机显示bug

zhengkaixin 1 anno fa
parent
commit
7bfb722b16

+ 2 - 2
apis/utils/index.js

@@ -21,7 +21,7 @@ export const nextMonth=(year,month,day,bl)=>{
 		str= year+"-"+(parseInt(month) +1)+"-"+day
 	}
 	if(bl){
-		var now= new Date(str);
+		var now= newDate(str);
 		return parseUnixTime(new Date(now.getTime()-1000*60*60*24),'{y}-{m}-{d}')	
 	}
 }
@@ -139,7 +139,7 @@ export const parseUnixTime = (time, cFormat) => {
 		date = time
 	} else {
 		if (('' + time).length === 10) time = parseInt(time) * 1000
-		date = new Date(time)
+		date = newDate(time)
 	}
 	const formatObj = {
 		y: date.getFullYear(),

+ 12 - 3
uni_modules/uview-ui/components/u-picker-select/u-picker-select.vue

@@ -76,7 +76,8 @@
 	import provinces from '../../libs/util/province.js';
 	import citys from '../../libs/util/city.js';
 	import areas from '../../libs/util/area.js';
-
+	// 苹果手机时间显示bug
+	 
 	/**
 	 * picker picker弹出选择器
 	 * @description 此选择器有两种弹出模式:一是时间模式,可以配置年,日,月,时,分,秒参数 二是地区模式,可以配置省,市,区参数
@@ -303,7 +304,15 @@
 				}
 			}
 		},
-		methods: {
+		methods: {
+			newDate (date)  {
+				var time=null;
+				if (date) {
+					var reg=new RegExp('-','gi')
+					time=new Date(date.replace(reg,'/'));	
+				}
+				return time
+			},
 			// 标识滑动开始,只有微信小程序才有这样的事件
 			pickstart() {
 				// #ifdef MP-WEIXIN
@@ -348,7 +357,7 @@
 				let fdate = this.defaultTime.replace(/\-/g, '/');
 				fdate = fdate && fdate.indexOf('/') == -1 ? `2020/01/01 ${fdate}` : fdate;
 				let time = null;
-				if (fdate) time = new Date(fdate);
+				if (fdate) time = this.newDate(fdate);
 				else time = new Date();
 				// 获取年日月时分秒
 				this.year = time.getFullYear();