Leon 1 год назад
Родитель
Сommit
d921f9654e

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
android/app/src/main/assets/index.android.bundle


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
android/app/src/main/assets/index.android.map


+ 1 - 0
config/env.ts

@@ -1,3 +1,4 @@
 
 export const APP_VERSION = '1.0.2'
+export const ANDROID_VERSION = '1.0.0'
 export const WX_VERSION = '1.4.8'

+ 55 - 16
src/app/time_of_day/index_time.tsx

@@ -9,7 +9,7 @@ import dayjs from "dayjs";
 import moment from 'moment-timezone'
 import Modal from "@/components/layout/Modal.weapp";
 import { loginAnonymous, place } from "./services/net";
-import Taro from "@tarojs/taro";
+import Taro, { useDidShow } from "@tarojs/taro";
 import { useTranslation } from "react-i18next";
 import 'dayjs/locale/zh-cn';
 import 'dayjs/locale/en';
@@ -17,13 +17,15 @@ import momentT from 'moment';
 
 import { getTimezone, getTimezoneName, kIsAndroid } from "@/utils/tools";
 
-import { AppState, SafeAreaView } from "react-native";
+import { AppState, Linking, SafeAreaView } from "react-native";
 import { method } from "lodash";
 import { AtActivityIndicator } from "taro-ui";
+import { systemVersion } from "@/services/common";
+import showAlert from "@/components/basic/Alert";
 // import 'moment/locale/en';
 
 
-
+let showUpdate = false;
 let LinearGradient, useActionSheet, useNavigation
 if (process.env.TARO_ENV == 'rn') {
     LinearGradient = require('react-native-linear-gradient').default
@@ -48,6 +50,7 @@ export default function IndexTimePage() {
 
     useEffect(() => {
         getLanguage();
+        
         AppState.addEventListener('change', handleAppStateChange);
         login()
         setInterval(() => {
@@ -68,6 +71,23 @@ export default function IndexTimePage() {
         }, 1000)
     }, [])
 
+    function login() {
+        loginAnonymous(kIsAndroid ? DeviceInfo.getAndroidIdSync() : DeviceInfo.getDeviceId()).then(res => {
+            global.token = (res as any).token
+            Taro.setStorage({
+                key: 'token',
+                data: (res as any).token
+            })
+            checkVersionUpdate()
+        }).catch(e => {
+            console.log('login error', e)
+        })
+    }
+
+    useDidShow(()=>{
+        checkVersionUpdate()
+    })
+
     const handleAppStateChange = (nextAppState) => {
         console.log(nextAppState)
         if (nextAppState != 'active') {
@@ -80,6 +100,36 @@ export default function IndexTimePage() {
 
     };
 
+    async function checkVersionUpdate() {
+        systemVersion('time').then(res => {
+            if ((res as any).result == 'UPDATE' && !showUpdate) {
+                showUpdate = true
+                showAlert({
+                    title: (res as any).title,
+                    content: (res as any).description,
+                    showCancel: true,
+                    confirmText: 'Update',
+                    confirm: () => {
+                        Linking.openURL((res as any).download_url)
+                    }
+                })
+            }
+            else if ((res as any).result == 'FORCE_UPDATE') {
+                showAlert({
+                    title: (res as any).title,
+                    content: (res as any).description,
+                    showCancel: false,
+                    confirmText: 'Update',
+                    confirm: () => {
+                        Linking.openURL((res as any).download_url)
+                    }
+                })
+            }
+        })
+
+
+    }
+
     function refresh() {
         if (current) {
             chooseLocation({
@@ -146,18 +196,7 @@ export default function IndexTimePage() {
         }
     }
 
-    function login() {
-        loginAnonymous(kIsAndroid ? DeviceInfo.getAndroidIdSync() : DeviceInfo.getDeviceId()).then(res => {
-            global.token = (res as any).token
-            Taro.setStorage({
-                key: 'token',
-                data: (res as any).token
-            })
-            console.log('login success', res)
-        }).catch(e => {
-            console.log('login error', e)
-        })
-    }
+    
 
     async function goMap() {
         if (loading) {
@@ -426,7 +465,7 @@ export default function IndexTimePage() {
 
             <View className="location">
                 {
-                    loading && <View style={{ display: 'flex', overflow: 'hidden', height: 20, marginRight: 5 }}><AtActivityIndicator color="#CACACA"/></View>
+                    loading && <View style={{ display: 'flex', overflow: 'hidden', height: 20, marginRight: 5 }}><AtActivityIndicator color="#CACACA" /></View>
                 }
                 {
                     loading && <Text className="location_text">{t('time_of_day.index.updating')}</Text>

+ 1 - 1
src/pages/clock/ClockMain.tsx

@@ -240,7 +240,7 @@ export default function Page() {
         }
 
         if (process.env.TARO_ENV == 'rn') {
-            systemVersion().then(res => {
+            systemVersion('fast').then(res => {
                 if ((res as any).result == 'UPDATE' && !showUpdate) {
                     showUpdate = true
                     showAlert({

+ 5 - 2
src/services/common.tsx

@@ -14,12 +14,15 @@ export const staticResources = () => (dispatch: any) => {
     })
 }
 
-export const systemVersion = () => {
+export const systemVersion = (sys:string) => {
     return new Promise((resolve, reject) => {
         var platform = kIsIOS?'IOS':'ANDROID'
         
         request({
-            url: API_SYSTEM_VERSION + platform, method: 'GET', data: {}
+            url: API_SYSTEM_VERSION, method: 'GET', data: {
+                sys:sys,
+                platform:platform
+            }
         }).then(res => {
             resolve(res)
         }).catch(e => {

+ 3 - 2
src/services/http/api.js

@@ -1,12 +1,13 @@
 const online = process.env.TARO_ENV == 'weapp' ? false : false;
 
-import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION } from "../../../config/env";
+import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION, ANDROID_VERSION as _ANDROID_VERSION } from "../../../config/env";
 
 // export const baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
 export const baseUrl = online ? process.env.TARO_ENV == 'rn' ? 'https://api.app.fast.liveplus.fun' : 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
 
 export const APP_VERSION = _APP_VERSION
 export const WX_VERSION = _WX_VERSION
+export const ANDROID_VERSION = _ANDROID_VERSION
 
 export let imgUrl = online
     ? 'https://api.fast.liveplus.fun/static/image/'
@@ -34,7 +35,7 @@ export const API_UPLOAD_SESSION = `${baseUrl}/api/thirdparty/wx/session`
 export const API_DEL_SESSION = `${baseUrl}/api/thirdparty/wx/session`
 export const API_USER_PERMS = `${baseUrl}/api/user/perms`
 export const API_USER_LOCATION = `${baseUrl}/api/user/location`
-export const API_SYSTEM_VERSION = `${baseUrl}/api/system/version/fast/`
+export const API_SYSTEM_VERSION = `${baseUrl}/api/system/version`
 
 //track time duration
 export const API_FAST_PLANS = `${baseUrl}/api/fast/plans`

+ 5 - 5
src/services/http/request.ts

@@ -4,8 +4,8 @@ import Taro from "@tarojs/taro";
 import { useDispatch } from "react-redux";
 
 import dayjs from 'dayjs'
-import { APP_VERSION, WX_VERSION } from "./api";
-import { getTimezone, getTimezoneId, getTimezoneName } from "@/utils/tools";
+import { APP_VERSION, WX_VERSION, ANDROID_VERSION } from "./api";
+import { getTimezone, getTimezoneId, getTimezoneName, kIsAndroid } from "@/utils/tools";
 import showAlert from "@/components/basic/Alert";
 
 const utc = require('dayjs/plugin/utc')
@@ -85,7 +85,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
         header['X-Platform'] = Taro.getSystemInfoSync().platform == 'ios' ? 'IOS' : 'ANDROID'; //IOS ANDROID
         header['X-Lang'] = process.env.TARO_ENV == 'rn' ? global.language : 'zh' //zh en
         header['X-Client-Type'] = process.env.TARO_ENV == 'rn' ? 'APP' : 'WX_APP' //WX_APP APP
-        header['X-Client-Version'] = process.env.TARO_ENV == 'rn' ? APP_VERSION : WX_VERSION
+        header['X-Client-Version'] = process.env.TARO_ENV == 'rn' ? kIsAndroid ? ANDROID_VERSION : APP_VERSION : WX_VERSION
         header['X-Day'] = dayjs().format('YYYYMMDD')
         header['X-Timestamp'] = new Date().getTime()
         if (token.length > 0) {
@@ -131,7 +131,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
         //     requestData = JSON.parse(JSON.stringify(data));
         //     requestData.remove('showAlert')
         // }
-        
+
 
         requestTask = Taro.request({
             url: url,
@@ -193,7 +193,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
                     }
                     else {
-                        if (response.data.error_code == 'BIZ_FAIL'){
+                        if (response.data.error_code == 'BIZ_FAIL') {
                             return;
                         }
                         if (process.env.TARO_ENV == 'rn' && (param.data as any).showAlert) {

Некоторые файлы не были показаны из-за большого количества измененных файлов