Leon hai 1 ano
pai
achega
aa3254e637
Modificáronse 3 ficheiros con 45 adicións e 14 borrados
  1. 1 1
      src/pages/account/Setting.tsx
  2. 17 12
      src/pages/clock/Clock.tsx
  3. 27 1
      src/utils/tools.ts

+ 1 - 1
src/pages/account/Setting.tsx

@@ -65,7 +65,7 @@ export default function Page() {
 
     return <View style={{ color: '#fff', display: 'flex', flexDirection: 'column', flex: 1 }}>
         <View style={{ height: 20 }} />
-        <TableCell title={t('page.setting.version')} ><Text style={{ opacity: 0.8, color: '#fff' }}>{process.env.TARO_ENV == 'weapp'?'1.3.8':'1.3.3'}</Text></TableCell>
+        <TableCell title={t('page.setting.version')} ><Text style={{ opacity: 0.8, color: '#fff' }}>{process.env.TARO_ENV == 'weapp'?'1.3.9':'1.3.3'}</Text></TableCell>
         {/* <Text style={{color:'#9E9E9E',textAlign:'center',fontSize:14}}>v1.2.2</Text> */}
         {
             process.env.TARO_ENV == 'rn' && <View style={{ flex: 1 }} />

+ 17 - 12
src/pages/clock/Clock.tsx

@@ -18,7 +18,7 @@ import { bigRingRadius, getBgRing, getCommon, getDot, getSchedule, ringWidth, sm
 import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
 import IndexConsole from "@/features/trackTimeDuration/components/IndexConsole";
 import Modal from '@/components/layout/Modal'
-import { rpxToPx } from "@/utils/tools";
+import { compareVersion, rpxToPx } from "@/utils/tools";
 import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
 import DayLight from "@/features/trackTimeDuration/components/DayLight";
 import { getInfo, latestLocation } from "@/services/user";
@@ -176,16 +176,21 @@ export default function Page() {
     }
 
     function checkAddToMini() {
-        process.env.TARO_ENV == 'weapp' &&
-            wx.checkIsAddedToMyMiniProgram({
-                success: (res) => {
-                    if (!res.added) {
-                        setNeedShowAddTip(true)
+        if (process.env.TARO_ENV == 'weapp') {
+            const version = Taro.getAppBaseInfo().SDKVersion
+            if (compareVersion(version, '2.30.3') >= 0) {
+                wx.checkIsAddedToMyMiniProgram({
+                    success: (res) => {
+                        if (!res.added) {
+                            setNeedShowAddTip(true)
+                        }
+                    },
+                    fail: (e) => {
                     }
-                },
-                fail: (e) => {
-                }
-            });
+                });
+            }
+        }
+
     }
 
     useDidShow(() => {
@@ -270,7 +275,7 @@ export default function Page() {
         clientInfo({
             client: {
                 client_type: process.env.TARO_ENV == 'weapp' ? 'MP' : 'APP',
-                client_version: process.env.TARO_ENV == 'weapp' ? '1.3.8' : '1.0',//Taro.getAccountInfoSync().miniProgram.version : '1.0',//'1.0'
+                client_version: process.env.TARO_ENV == 'weapp' ? '1.3.9' : '1.0',//Taro.getAccountInfoSync().miniProgram.version : '1.0',//'1.0'
                 wx_version: process.env.TARO_ENV == 'weapp' ? systemInfo.version : '_'
             },
             meta: {
@@ -664,7 +669,7 @@ export default function Page() {
                 }
 
                 {
-                    user.isLogin && !showErrorPage  && <View style={{ marginTop: rpxToPx(60), display: 'flex', flexDirection: 'column' }}>
+                    user.isLogin && !showErrorPage && <View style={{ marginTop: rpxToPx(60), display: 'flex', flexDirection: 'column' }}>
                         <Text className="discovery1" >周统计</Text>
                         <WeekCalendar />
                     </View>

+ 27 - 1
src/utils/tools.ts

@@ -56,4 +56,30 @@ export function vibrate(type?: string) {
             type: 'medium'
         })
     }
-}
+}
+
+export function compareVersion(v1, v2) {
+    v1 = v1.split('.')
+    v2 = v2.split('.')
+    const len = Math.max(v1.length, v2.length)
+  
+    while (v1.length < len) {
+      v1.push('0')
+    }
+    while (v2.length < len) {
+      v2.push('0')
+    }
+  
+    for (let i = 0; i < len; i++) {
+      const num1 = parseInt(v1[i])
+      const num2 = parseInt(v2[i])
+  
+      if (num1 > num2) {
+        return 1
+      } else if (num1 < num2) {
+        return -1
+      }
+    }
+  
+    return 0
+  }