| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- /**
- * 公共配置文件
- * @邠心vbe on 2021/04/07
- */
- import {
- Text,
- TextInput,
- Dimensions,
- Platform,
- StatusBar,
- StyleSheet,
- NativeModules,
- } from 'react-native';
- import DeviceInfo from 'react-native-device-info';
- import apiUser from '../api/apiUser';
- import geolocation from '@react-native-community/geolocation';
- navigator.geolocation = geolocation;
- global.isIOS = Platform.OS == 'ios';
- global.$width = Dimensions.get('window').width;
- global.$height = Dimensions.get('window').height;
- global.$screen = Dimensions.get('screen').height;
- global.statusHeight = isIOS ? 0 : StatusBar.currentHeight;
- global.toolbarSize = isIOS ? 50 : 56;
- global.navbarHeight = 0;
- if (isIOS) {
- const {StatusBarManager} = NativeModules;
- StatusBarManager.getHeight(statusBarHeight => {
- const height = statusBarHeight.height;
- //global.toolbarSize = toolbarSize + height;
- global.statusHeight = height;
- });
- global.BRAND = '';
- } /*else {
- global.statusHeight = StatusBar.currentHeight;
- global.BRAND = DeviceInfo.getBrand().toLowerCase();
- }*/
- if (Text.defaultProps == null)
- Text.defaultProps = {};
- Text.defaultProps.allowFontScaling = false;
- const sourceRender = Text.render;
- Text.render = function render(props, ref) {
- return sourceRender.apply(this, [{ ...props, style: [{fontFamily: 'system-ui'}, props.style] }, ref]);
- };
- if (TextInput.defaultProps == null)
- TextInput.defaultProps = {};
- TextInput.defaultProps.allowFontScaling = false;
- const sourceRender2 = TextInput.render;
- TextInput.render = function render(props, ref) {
- return sourceRender2.apply(this, [{ ...props, style: [{fontFamily: 'system-ui'}, props.style] }, ref]);
- };
- global.currency = "";//'$';
- global.accessToken = '';
- global.startPage = {};
- global.storageSite = [];
- global.chargeInfoState = {};
- global.hasAnalytics = false;
- global.userInfo = {
- userPk: -1,
- credit: 0,
- userType: "Public",
- nickname: 'Sign In'
- };
- global.isLogin = () => {
- return global.accessToken !== '';
- };
- global.getUserId = () => {
- return global.userInfo.userPk;
- };
- global.getUserInfo = (resolve, force) => {
- if (isLogin()) {
- if (userInfo.userPk > 0 && !force) {
- //console.log('-->>>>> 获取用户数据');
- if (resolve) resolve(global.userInfo);
- } else {
- apiUser.getProfile().then(res => {
- console.log('-->>>>> global.getUserInfo', res);
- if (res.data) {
- global.userInfo = res.data;
- if (resolve) resolve(res.data);
- }
- }).catch(erros => {
- console.info('<<<<<-- global.getUserInfo', erros);
- })
- }
- } else {
- if (resolve) resolve(global.userInfo)
- }
- }
- global.$vh = percent => {
- return (global.$height * percent) / 100;
- };
- global.$vhs = percent => {
- return global.$height * percent / 100 - global.statusHeight;
- };
- global.$vht = percent => {
- return global.$height * percent / 100 - toolbarSize;
- };
- global.$vhts = percent => {
- return global.$height * percent / 100 - toolbarSize - global.statusHeight;
- };
- global.$vw = percent => {
- return (global.$width * percent) / 100;
- };
- global.$padding = (top, right, bottom, left) => {
- if (top == undefined) {
- return {};
- }
- if (right == undefined) {
- right = top;
- }
- if (bottom == undefined) {
- bottom = top;
- }
- if (left == undefined) {
- left = right;
- }
-
- return {
- paddingTop: top,
- paddingLeft: left,
- paddingRight: right,
- paddingBottom: bottom
- };
- }
- global.$margin = (top, right, bottom, left) => {
- if (top == undefined) {
- return {};
- }
- if (right == undefined) {
- right = top;
- }
- if (bottom == undefined) {
- bottom = top;
- }
- if (left == undefined) {
- left = right;
- }
- return {
- marginTop: top,
- marginLeft: left,
- marginRight: right,
- marginBottom: bottom
- };
- }
- global.$borderRadius = (topLeft, topRight, bottomRight, bottomLeft) => {
- if (topLeft == undefined) {
- return {};
- }
- if (topRight == undefined) {
- topRight = topLeft;
- }
- if (bottomRight == undefined) {
- bottomRight = topLeft;
- }
- if (bottomLeft == undefined) {
- bottomLeft = topRight;
- }
- return {
- borderTopLeftRadius: topLeft,
- borderTopRightRadius: topRight,
- borderBottomLeftRadius: bottomLeft,
- borderBottomRightRadius: bottomRight
- };
- }
- global.ui = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: pageBackground
- },
- flex: {
- flexDirection: 'row'
- },
- flexc: {
- alignItems: 'center',
- flexDirection: 'row'
- },
- flexcc: {
- alignItems: 'center',
- flexDirection: 'row',
- justifyContent: 'center'
- },
- flexcw: {
- alignItems: 'center',
- flexDirection: 'row',
- justifyContent: 'space-between'
- },
- flexvc: {
- alignItems: 'center',
- justifyContent: 'center'
- },
- flex1: {
- flex: 1
- },
- flex2: {
- flex: 2
- },
- flex3: {
- flex: 3
- },
- flex4: {
- flex: 4
- },
- flex5: {
- flex: 5
- },
- center: {
- textAlign: 'center',
- alignItems: 'center'
- },
- right: {
- textAlign: 'right',
-
- },
- link: {
- color: "#0684D4"
- },
- bold: {
- fontWeight: 'bold'
- },
- underline: {
- textDecorationLine: "underline"
- },
- blackText: {
- color: '#000'
- },
- mainText: {
- color: colorAccent
- },
- button: {
- flex: 1,
- height: 50,
- elevation: 2,
- borderRadius: 8,
- marginBottom: 8,
- alignItems: 'center',
- justifyContent: 'center',
- backgroundColor: colorAccent
- },
- buttonMini: {
- height: 42,
- borderRadius: 6,
- paddingLeft: 16,
- paddingRight: 16,
- alignItems: 'center',
- justifyContent: 'center',
- backgroundColor: colorAccent
- },
- buttonText: {
- color: textPrimary,
- fontSize: 17,
- fontWeight: 'bold',
- textAlign: 'center',
- },
- noData: {
- color: '#aaa',
- fontSize: 12,
- padding: 16,
- textAlign: 'center'
- }
- });
- globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
- /*if (!__DEV__) {
- global.console = {
- info: () => {},
- log: () => {},
- warn: () => {},
- error: () => {},
- };
- }*/
|