张延森 3 lat temu
rodzic
commit
07e8435004
2 zmienionych plików z 9 dodań i 8 usunięć
  1. 1
    1
      config/prod.js
  2. 8
    7
      src/utils/chatDate.js

+ 1
- 1
config/prod.js Wyświetl plik

10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
11
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
11
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
12
     ICON_FONT: '"https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/css/iconfont.ttf"',
12
     ICON_FONT: '"https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/css/iconfont.ttf"',
13
-    Version: '"V0.0.44-20210812"'
13
+    Version: '"V0.0.45-20210812"'
14
   },
14
   },
15
   mini: {},
15
   mini: {},
16
   h5: {
16
   h5: {

+ 8
- 7
src/utils/chatDate.js Wyświetl plik

17
   return [bw, day, hour, min, sec]
17
   return [bw, day, hour, min, sec]
18
 }
18
 }
19
 
19
 
20
-let systemInfo = null;
20
+export function getDateByStr(dtStr) {
21
+  if (!dtStr) return undefined;
22
+
23
+  const t = dtStr.split(/[-T :]/);
24
+
25
+  return new Date(t[0], t[1]-1, t[2], t[3] || 0, t[4] || 0, t[5] || 0)
26
+}
21
 
27
 
22
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
28
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
23
 export function formatDate(dt, fmt) {
29
 export function formatDate(dt, fmt) {
24
   if (!dt) return dt;
30
   if (!dt) return dt;
25
 
31
 
26
-  if (!systemInfo) {
27
-    systemInfo = Taro.getSystemInfoSync()
28
-  }
29
-
30
   // 解决苹果手机不能正常初始化的问题
32
   // 解决苹果手机不能正常初始化的问题
31
-  const dtStr = systemInfo.system.indexOf('iOS') > -1 && typeof dt === 'string' ? dt.replace(/-/g, "/") : dt;
32
-  const date = new Date(dtStr)
33
+  const date = typeof dt === 'string' ? getDateByStr(dt) : new Date(dt);
33
 
34
 
34
   var o = {
35
   var o = {
35
     "M+": date.getMonth() + 1, //月份
36
     "M+": date.getMonth() + 1, //月份