Commit b3facbaf by 肖亮

feat:更新设备列表页及修改昵称页面

parent 3c2bd13d
# Default ignored files
/workspace.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="JSX" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/banma_credit.iml" filepath="$PROJECT_DIR$/.idea/banma_credit.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/android" vcs="Git" />
<mapping directory="$PROJECT_DIR$/ios" vcs="Git" />
</component>
</project>
\ No newline at end of file
android @ e108a7d9
Subproject commit 5817bf0f5f38f7fed90107f3fc9cb685f97ad922 Subproject commit e108a7d998fec6596b0dfdc572b478779f3f3f73
...@@ -4,11 +4,9 @@ ...@@ -4,11 +4,9 @@
import { AppRegistry } from 'react-native'; import { AppRegistry } from 'react-native';
import App from './src/App'; import App from './src/App';
import NavigateEntryTest from './src/test/NavigateEntryTest.js'
import { name as appName } from './app.json'; import { name as appName } from './app.json';
AppRegistry.registerComponent(appName, (props) => { AppRegistry.registerComponent(appName, (props) => {
console.log('AppRegistry.registerComponent:' + props);
return App; return App;
// return NavigateEntryTest; // return NavigateEntryTest;
}); });
This source diff could not be displayed because it is too large. You can view the blob instead.
/** import React from 'react'
* Sample React Native App import AppRouter from './router'
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, { useState } from 'react'; const App = () => <AppRouter />
import {
NativeModules,
NativeEventEmitter,
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
Button,
StatusBar,
Alert,
Image,
TextInput,
DeviceEventEmitter,
} from 'react-native';
import { BMCUI } from './test/ui.js'
import CustomerView from './test/CustomerView.js'
import CustomRoundImageView from './test/RoundedImage.js'
import MapView from './test/MapView.js'
import { export default App
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
var ToastManager = NativeModules.ToastManager;
async function showConfirmVsCancelPromiseDialog(msg, leftTip, rightTip) {
try {
const {
right,
left
} = await BMCUI.showConfirmVsCancelPromiseDialog(msg, leftTip, rightTip);
console.log(
"你点击了按钮,结果为:" + left + " / " + right
);
} catch (e) {
console.error(e);
}
}
// class App extends React.Component {
// onRegionChange(event) {
// console.log(event.region.latitude)
// }
// render() {
// const region = {
// latitude: 37.48,
// longitue: -122.16,
// latitudeDelta: 0.1,
// longitudeDelta: 0.1,
// };
// return (
// <MapView
// region={region}
// zoomEnabled={false}
// onRegionChange={this.onRegionChange}
// style={{ flex: 1 }}
// />
// );
// }
// }
function onRegionChange(event) {
console.log(event.region.latitude, event.region.longitue)
}
const App = (props) => {
var index = 0;
const region = {
latitude: 37.48,
longitue: -122.16,
latitudeDelta: 0.1,
longitudeDelta: 0.1,
};
console.log('init path:' + props.path);
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes(need config!!!!)</Text>
</View>
)}
<View style={styles.buttonContainer}>
<CustomerView style={{ height: 80 }} />
{Platform.OS == 'ios' ? (
<MapView region={region} zoomEnabled={false} onRegionChange={this.onRegionChange} style={{ flex: 1, height: 200 }} />
) : null}
</View>
<View style={styles.body}>
<View style={styles.buttonContainer}>
{Platform.OS == 'android' ? (
<CustomRoundImageView src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1598436038838&di=d725130cf6ca00e920ad68b21ba72f5c&imgtype=0&src=http%3A%2F%2Ft9.baidu.com%2Fit%2Fu%3D1307125826%2C3433407105%26fm%3D79%26app%3D86%26f%3DJPEG%3Fw%3D5760%26h%3D3240"
cornerRadius={30} borderWidth={2} style={{ width: 200, height: 160 }} />
) : null
}
<Button
style={styles.buttonStyle}
onPress={() => {
index++;
DeviceEventEmitter.emit('msg', '发送了个通知:' + index);
}}
title="发送消息"
/>
</View>
<View style={styles.buttonContainer}>
<Button
style={styles.buttonStyle}
onPress={() => {
if (Platform.OS == 'android') {
// BMCUI.show('"你点击了按钮!");\
console.log(NativeModules);
NativeModules.BMCUI.show("你点击了按钮111!");
// NativeModules.BMCUI.showWithDuration("你点击了按钮!", NativeModules.BMCUI.SHORT);
// Alert.alert("你点击了按钮");
} else {
// Alert.alert("ios undefine");
// NativeModules.ToastManager
var alerts = "alert..." + NativeModules.HIKAlertManager.alertStyleLight;
console.log(alerts)
NativeModules.HIKAlertManager.showAlert("tesss")
}
}}
title="吐司"
/>
</View>
<View style={styles.buttonContainer}>
<Button
style={styles.buttonStyle}
onPress={() => {
if (Platform.OS == 'android') {
BMCUI.showConfirmDialogWithCancelable(false, "你点击了按钮222!", "确定", (result) => {
console.log("你点击了取确定按钮,结果为:" + result);
});
// BMCUI.showConfirmDialog("你点击了按钮222!", "确定", (result) => {
// console.log("你点击了确定,结果为:" + result);
// });
// BMCUI.showConfirmDialogWithCancelableError((result) => {
// console.log("你点击了确定,结果为:" + result);
// }, true, "你点击了按钮222!", "确定");
} else {
NativeModules.ToastManager.showToast("iOS toast");
}
}}
title="单按钮提示框"
/>
</View>
<View style={styles.buttonContainer}>
<Button
style={styles.buttonStyle}
onPress={() => {
if (Platform.OS == 'android') {
// BMCUI.showConfirmVsCancelDialog("你点击了按钮333!", "取消", "确定", (result) => {
// console.log("你点击了取消单按钮,结果为:" + result);
// }, (result) => {
// console.log("你点击了取确定按钮,结果为:" + result);
// });
showConfirmVsCancelPromiseDialog("你点击了按钮333!", "取消", "确定");
} else {
Alert.alert("ios undefine");
}
}}
title="双按钮提示框"
/>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One 111</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes 2222</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug 3333</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More 4444</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24
},
buttonContainer: {
marginTop: 5,
paddingHorizontal: 24
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: "#FF0000",
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
export default App;
/**
* 设备列表页
*
* */
import React, { useEffect, useState } from 'react'
import { SafeAreaView, TextInput, Text, TouchableHighlight, View, } from 'react-native';
import styles from './style';
import requestUrl from '../../config';
const Equipment = () => {
const [nickName, setnickName] = useState('');
useEffect(() => {
getEquimentList();
}, []);
const getEquimentList = async () => {
try {
const { data } = await fetch(`${requestUrl}user/loginDevices`);
console.log('data', data);
} catch (e) {
console.log('e', e);
}
};
return (
<SafeAreaView style={styles.container}>
<TextInput
style={styles.input}
value={nickName}
onChange={(e) => { setnickName(e.target.value); }}
placeholder="请输入昵称"
/>
<Text style={styles.tip}>4-20个字符,可由中英文、数字、“-”、“_”组成</Text>
<View style={styles.submit}>
<TouchableHighlight>
<View style={styles.btn}>
<Text style={styles.btnText}>保存</Text>
</View>
</TouchableHighlight>
</View>
</SafeAreaView>
)
};
export default Equipment
import { StyleSheet } from 'react-native';
export default StyleSheet.create({
container: {
marginTop: 12,
},
input: {
height: 58,
backgroundColor: '#fff',
paddingLeft: 12,
},
tip: {
paddingLeft: 12,
paddingTop: 12,
color: 'rgba(120, 120, 120, 1)',
},
submit: {
marginTop: 186,
paddingLeft: 12,
paddingRight: 12,
},
btn: {
paddingTop: 12,
paddingBottom: 12,
backgroundColor: 'rgba(76, 155, 255, 1)',
borderRadius: 5,
alignItems: "center",
},
btnText: {
color: '#fff',
}
});
/**
* 设备列表页
*
* */
import React, { useEffect } from 'react'
import { ScrollView, View, Text, SafeAreaView, NativeModules } from 'react-native';
import styles from './style';
import requestUrl from '../../config';
const Equipment = () => {
useEffect(() => {
console.log('NativeModules', NativeModules);
// getEquimentList();
}, []);
const getEquimentList = async () => {
try {
const { data } = await fetch(`${requestUrl}user/loginDevices`);
console.log('data', data);
} catch (e) {
console.log('e', e);
}
};
return (
<SafeAreaView>
<ScrollView style={styles.container}>
<Text style={styles.tip}>
标题文字点击无反馈,文字超长则隐藏,文字超长则隐藏
</Text>
<View style={styles.content}>
<View style={styles.ceil}>
<View style={styles.ceilTitle}>
<Text style={styles.ceilName}>设备的名字</Text>
<Text style={styles.ceilTag}>本机</Text>
</View>
<Text style={styles.ceilInfo}>最后登录时间:2019-08-25 16:32</Text>
</View>
</View>
</ScrollView>
</SafeAreaView>
)
};
export default Equipment
import { StyleSheet } from 'react-native';
export default StyleSheet.create({
container: {
},
tip: {
fontSize: 16,
paddingLeft: 12,
paddingRight: 12,
paddingTop: 20,
paddingBottom: 20,
color: 'rgba(182, 182, 182, 1)',
},
content: {
},
ceil: {
backgroundColor: '#fff',
padding: 12,
marginBottom: 12,
},
ceilTitle: {
flexDirection: 'row',
alignItems: 'center',
},
ceilName: {
fontSize: 16,
color: '#000',
},
ceilTag: {
marginLeft: 10,
},
ceilInfo: {
paddingTop: 6,
},
});
import React, { useState, useEffect } from 'react'
import { AsyncStorage } from 'react-native'
import StatusView from '../../components/status-view/index'
import consts from '../../consts'
import { resetNavigatePage } from '../../router'
const AppInit = ({ navigation }) => {
const [loading, setLoading] = useState(true)
useEffect(() => {
let timer = null
AsyncStorage.getItem(consts.USER_INFO).then(userInfoText => {
setLoading(false)
const targetNavigation = userInfoText ? 'Home' : 'Login'
timer = setTimeout(() => {
resetNavigatePage(navigation, targetNavigation, {})
}, 1000)
})
return () => {
clearTimeout(timer)
}
})
return <StatusView loading={loading} />
}
export default AppInit
import React from 'react'
import { View, Text } from 'react-native'
import styles from './index.scss'
import { IC_LAUNCHER } from '../../assets/images'
const Home = () => {
return (
<View style={styles.app}>
<Text style={styles.appName}>Home</Text>
</View>
)
}
export default Home
.app {
background: #f00;
height: 600px;
}
.appName {
color: #fff;
}
\ No newline at end of file
import React from 'react'
import { View, Text } from 'react-native'
const Login = () => {
return (
<View>
<Text>Login</Text>
</View>
)
}
export default Login
import React from 'react'
import { View, Text } from 'react-native'
const Mine = () => {
return (
<View>
<Text>Mine</Text>
</View>
)
}
export default Mine
import { createAppContainer, StackActions, NavigationActions } from 'react-navigation' import React from 'react'
import { createStackNavigator } from 'react-navigation-stack' import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from 'react-navigation-tabs' import { createStackNavigator } from '@react-navigation/stack';
import Login from '../pages/login' import Equipment from '../pages/Equipment'
import Home from '../pages/home' import ChangeNickname from '../pages/ChangeNickname'
import Mine from '../pages/mine'
import AppInit from '../pages/appinit'
export function resetNavigatePage(navigation, page, params) { const Stack = createStackNavigator();
const resetAction = StackActions.reset({
index: 0,
actions: [
//要跳转到的页面名字
NavigationActions.navigate({ routeName: page, params }),
],
})
navigation.dispatch(resetAction)
}
const AppTabNavigator = createBottomTabNavigator(
{
Home: {
screen: Home,
path: 'home',
},
Mine: {
screen: Mine,
path: 'mine',
},
},
{
initialRouteName: 'Home',
}
)
const AppNavigator = createStackNavigator(
{
AppInit: {
screen: AppInit,
navigationOptions: ({ navigation }) => ({
headerShown: false,
}),
},
Login: {
screen: Login,
path: 'login',
},
TabMain: AppTabNavigator,
},
{
initialRouteName: 'AppInit',
}
)
const AppRouter = createAppContainer(AppNavigator) function AllStack() {
return (
<Stack.Navigator initialRouteName="equiment">
<Stack.Screen options={{title: '常用设备'}} name="equiment" component={Equipment} />
<Stack.Screen options={{title: '修改昵称'}} name="ChangeNickname" component={ChangeNickname} />
</Stack.Navigator>
);
}
export default AppRouter export default function App() {
return (
<NavigationContainer>
<AllStack />
</NavigationContainer>
);
}
import appConfig from '../config' import appConfig from '../config'
import Toast from 'react-native-root-toast'
// 服务器地址 // 服务器地址
export const API_SERVER = appConfig.API_ROOT export const API_SERVER = appConfig.API_ROOT
...@@ -14,18 +15,105 @@ const ERROR_CODE_MAP = { ...@@ -14,18 +15,105 @@ const ERROR_CODE_MAP = {
// }, // },
} }
const SUCCESS_CODE = 1000 const SUCCESS_CODE = 1000;
const defaultStateConfig = { // 错误处理
loading: true, const errorProcess = (resp, reject, errorToast) => {
errorToast: true, const resData = resp.data || {}
loadingText: '加载中...', let message = resData.message || resData.msg || resp.statusText
const status = resData.stats || resp.status
if (ERROR_CODE_MAP[status] && ERROR_CODE_MAP[status].message) {
message = ERROR_CODE_MAP[status].message
}
if (errorToast) {
Toast.show(message || '', {
duration: Toast.durations.LONG,
position: Toast.positions.BOTTOM,
})
}
reject({ message, data: resData })
}
// 处理响应
const responseProcess = (resp, resolve, reject, outServer, errorToast) => {
if (outServer) {
return resolve([resp, ''])
}
if (resp.code === SUCCESS_CODE) {
return resolve([resp.data, resp.msg])
}
return errorProcess(resp, reject, errorToast)
} }
// 封装get post 请求 // 封装get post 请求
export const $request = { export const $request = {
get(url, params, config) {}, _requestConfig: getRequestInfo,
post(url, params, config) {}, async _request(url, method, params, config = {}) {
delete(url, params, config) {}, const isOutRequest = isOutServer(url)
postForm(url, params, config) {}, let headers = config.headers || {}
let body = {}
let errorToast = config.errorToast || true
url = isOutRequest ? url : `${API_SERVER}${url}`
// 非外部请求,自定义headers中添加Token等操作
if (!isOutRequest && this._requestConfig) {
let composeHeaders = null
if (typeof this._requestConfig === 'function') {
composeHeaders = await this._requestConfig(url, method, params, config)
} else {
composeHeaders = this._requestConfig
}
headers = Object.assign({}, config.headers, composeHeaders)
}
if (headers['Content-Type'] === 'multipart/form-data') {
body = params
} else if (method === 'POST') {
body = JSON.stringify(params || {})
}
const fetchConfig = {
method,
headers,
}
if (method === 'POST') {
fetchConfig.body = body
}
return new Promise((resolve, reject) => {
fetch(url, fetchConfig)
.then(res => {
if (res.ok) {
return res.json()
}
errorProcess(res, reject, errorToast)
})
.then(json => {
responseProcess(json, resolve, reject, isOutRequest, errorToast)
})
.catch(e => {
errorProcess({ data: { message: e.message } }, reject, errorToast)
})
})
},
// GET请求
get(url, params, config = {}) {
return this._request(url, 'GET', params, config)
},
// POST请求
post(url, params, config = {}) {
return this._request(url, 'POST', params, {
...config,
headers: {
...(config.headers || {}),
'Content-Type': 'application/json',
},
})
},
// POST FORM 请求
postForm(url, params, config = {}) {
return this._request(url, 'POST', params, {
...config,
headers: {
...(config.headers || {}),
'Content-Type': 'multipart/form-data',
},
})
},
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment