2025-07-22 17:21:43 +08:00
|
|
|
import React, { useState } from 'react';
|
2025-07-22 16:03:22 +08:00
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Linking,
|
|
|
|
|
Platform,
|
|
|
|
|
ScrollView,
|
|
|
|
|
StyleSheet,
|
|
|
|
|
Text,
|
|
|
|
|
View,
|
|
|
|
|
} from 'react-native';
|
2025-07-22 15:16:47 +08:00
|
|
|
import { StackScreenProps } from '@react-navigation/stack';
|
|
|
|
|
import { MainParamList } from '@app/routes/MainParamList';
|
2025-07-22 15:31:41 +08:00
|
|
|
import { Apps, NavigationPushByName } from '@common/NavigationHelper.ts';
|
|
|
|
|
import { showMessage } from '@common/ToastHelper.ts';
|
2025-07-22 16:03:22 +08:00
|
|
|
import Alert from '@common/components/Alert.tsx';
|
|
|
|
|
import { version_common } from '@common/common.ts';
|
2025-07-22 17:21:43 +08:00
|
|
|
import { downloadToFile } from '@common/UpdateHelper.ts';
|
|
|
|
|
import UpdateManager from '../../../../specs/NativeUpdateManager.ts';
|
2025-07-22 18:23:42 +08:00
|
|
|
import Spinner from '@common/components/Spinner.tsx';
|
|
|
|
|
import RNFS from 'react-native-fs';
|
2025-07-22 15:16:47 +08:00
|
|
|
|
|
|
|
|
type Props = StackScreenProps<MainParamList, 'MainView'>;
|
|
|
|
|
|
|
|
|
|
export default function WebViewScreen(props: Props) {
|
2025-07-22 17:21:43 +08:00
|
|
|
const [progress, setProgress] = useState('');
|
2025-07-22 18:23:42 +08:00
|
|
|
const [progressH, setProgressH] = useState('');
|
|
|
|
|
const [isLoading, setLoading] = useState(false);
|
2025-07-22 17:21:43 +08:00
|
|
|
|
2025-07-22 15:31:41 +08:00
|
|
|
return (
|
|
|
|
|
<View style={styles.container}>
|
2025-07-22 16:03:22 +08:00
|
|
|
<ScrollView>
|
|
|
|
|
<>
|
|
|
|
|
<Text style={{ fontSize: 20, marginVertical: 15 }}>
|
|
|
|
|
小程序跳转以及公共组件
|
|
|
|
|
</Text>
|
|
|
|
|
<Button
|
2025-07-22 18:23:42 +08:00
|
|
|
title={`进入互联网医院(前台)${isLoading ? progressH : ''}`}
|
2025-07-22 16:03:22 +08:00
|
|
|
onPress={() => {
|
2025-07-22 18:23:42 +08:00
|
|
|
setLoading(true);
|
|
|
|
|
downloadToFile(
|
|
|
|
|
'https://download-api.51trust.com/ywx-android-sdk/buz1.android.zip',
|
|
|
|
|
'buz1.android.zip',
|
|
|
|
|
(bytesWritten, contentLength) => {
|
|
|
|
|
setProgressH(
|
|
|
|
|
`进度: ${((bytesWritten / contentLength) * 100).toFixed(
|
|
|
|
|
2,
|
|
|
|
|
)}%`,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
.then(() => {
|
|
|
|
|
NavigationPushByName(Apps.Hospital, {});
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
});
|
2025-07-22 16:03:22 +08:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<View style={{ height: 15 }} />
|
|
|
|
|
<Button
|
2025-07-22 18:23:42 +08:00
|
|
|
title={`进入医网签(后台)`}
|
2025-07-22 16:03:22 +08:00
|
|
|
onPress={() => {
|
|
|
|
|
NavigationPushByName(Apps.Ywq, {});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<View style={{ height: 15 }} />
|
|
|
|
|
<Button
|
|
|
|
|
title={'Toast'}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
showMessage('APP页面弹出toast');
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<View style={{ height: 45 }} />
|
|
|
|
|
<Button
|
|
|
|
|
title={'应用更新模拟'}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
Alert.show(
|
|
|
|
|
'提示',
|
|
|
|
|
<Text style={styles.alertText}>
|
|
|
|
|
有新版本可以更新,确定更新吗?
|
|
|
|
|
</Text>,
|
|
|
|
|
{
|
|
|
|
|
action: () => {
|
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
|
Linking.openURL(
|
|
|
|
|
'https://apps.apple.com/cn/app/%E5%8C%BB%E7%BD%91%E4%BF%A1/id1074200788',
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Linking.openURL('https://www.51trust.com/download.html/');
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
action: () => {},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<View style={{ height: 45 }} />
|
2025-07-22 17:21:43 +08:00
|
|
|
<Text>
|
2025-07-22 18:23:42 +08:00
|
|
|
基础包版本号{version_common}
|
|
|
|
|
{isLoading ? `(${progress})` : ''}
|
2025-07-22 17:21:43 +08:00
|
|
|
</Text>
|
2025-07-22 18:23:42 +08:00
|
|
|
<View style={{ height: 15 }} />
|
2025-07-22 16:03:22 +08:00
|
|
|
<Button
|
|
|
|
|
title={'基础包前台更新'}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
Alert.show(
|
|
|
|
|
'提示',
|
|
|
|
|
<Text style={styles.alertText}>
|
|
|
|
|
有新版本可以更新,确定更新吗?
|
|
|
|
|
</Text>,
|
|
|
|
|
{
|
2025-07-22 17:21:43 +08:00
|
|
|
action: () => {
|
2025-07-22 18:23:42 +08:00
|
|
|
setLoading(true);
|
2025-07-22 17:21:43 +08:00
|
|
|
downloadToFile(
|
2025-07-22 18:23:42 +08:00
|
|
|
'https://download-api.51trust.com/ywx-android-sdk/common1.android.zip',
|
|
|
|
|
'common1.android.zip',
|
2025-07-22 17:21:43 +08:00
|
|
|
(bytesWritten, contentLength) => {
|
|
|
|
|
setProgress(
|
|
|
|
|
`进度: ${(
|
|
|
|
|
(bytesWritten / contentLength) *
|
|
|
|
|
100
|
|
|
|
|
).toFixed(2)}%`,
|
|
|
|
|
);
|
|
|
|
|
},
|
2025-07-22 18:23:42 +08:00
|
|
|
)
|
|
|
|
|
.then(() => {
|
|
|
|
|
UpdateManager.reload();
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
});
|
2025-07-22 17:21:43 +08:00
|
|
|
},
|
2025-07-22 16:03:22 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
action: () => {},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-07-22 18:23:42 +08:00
|
|
|
<View style={{ height: 15 }} />
|
|
|
|
|
<Button
|
|
|
|
|
title={'基础包后台更新'}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
downloadToFile(
|
|
|
|
|
'https://download-api.51trust.com/ywx-android-sdk/common2.android.zip',
|
|
|
|
|
'common2.android.zip',
|
|
|
|
|
(bytesWritten, contentLength) => {
|
|
|
|
|
setProgress(
|
|
|
|
|
`进度: ${((bytesWritten / contentLength) * 100).toFixed(
|
|
|
|
|
2,
|
|
|
|
|
)}%`,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
).then(() => {
|
|
|
|
|
Alert.show(
|
|
|
|
|
'提示',
|
|
|
|
|
<Text style={styles.alertText}>
|
|
|
|
|
更新成功,下次启用应用生效
|
|
|
|
|
</Text>,
|
|
|
|
|
{},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-07-22 17:21:43 +08:00
|
|
|
<View style={{ height: 45 }} />
|
2025-07-22 18:23:42 +08:00
|
|
|
<Text>{`${RNFS.ExternalDirectoryPath}/bundles/`}</Text>
|
2025-07-22 16:03:22 +08:00
|
|
|
</>
|
|
|
|
|
</ScrollView>
|
2025-07-22 18:23:42 +08:00
|
|
|
{isLoading && <Spinner />}
|
2025-07-22 15:31:41 +08:00
|
|
|
</View>
|
|
|
|
|
);
|
2025-07-22 15:16:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
container: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
},
|
2025-07-22 16:03:22 +08:00
|
|
|
alertText: {
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
color: '#999999',
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
},
|
2025-07-22 15:16:47 +08:00
|
|
|
});
|