Commit c5d4a5b1 by 肖亮

feat:更新gitignore配置

parent 2fba2675
android @ cfa005dd
Subproject commit 6739f8711e57794e31f0ade55a3a0494f44b784c Subproject commit cfa005dd4b3902d32a52ef4eeaffb20ada906c4d
ios @ 3922333e
Subproject commit 41d56f7f391dde39dcf6d3469b86d2acc385fd47 Subproject commit 3922333e6e0f904d6ff344620db7d35c95ae3694
const dev = { const dev = {
API_ROOT: 'http://devbmcmapp.hikcreate.com/', API_ROOT: 'http://devbmcapp.hikcreate.com',
} }
const test = { const test = {
API_ROOT: 'http://testbmcmapp.hikcreate.com/', API_ROOT: 'http://testbmcapp.hikcreate.com',
} }
const prod = { const prod = {
API_ROOT: 'https://bmcmapp.hikcreate.com/', API_ROOT: 'https://bmcapp.hikcreate.com',
} }
const configs = { const configs = {
......
...@@ -4,45 +4,54 @@ ...@@ -4,45 +4,54 @@
* */ * */
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { SafeAreaView, TextInput, Text, TouchableHighlight, View, } from 'react-native'; import { TextInput, Text, TouchableHighlight, View, NativeModules } from 'react-native';
import { user as userServices } from '../../services';
import styles from './style'; import styles from './style';
import requestUrl from '../../config';
const { BMCInfo: { getUserInfo }, BMCUI } = NativeModules;
const Equipment = () => { const Equipment = () => {
const [nickName, setnickName] = useState(''); const [nickname, setNickName] = useState('');
useEffect(() => { useEffect(() => {
getEquimentList(); getNativeLoginInfo();
}, []); }, []);
const getEquimentList = async () => { const getNativeLoginInfo = async () => {
try { const data = await getUserInfo();
const { data } = await fetch(`${requestUrl}user/loginDevices`); setNickName(data.nickname);
console.log('data', data);
} catch (e) {
console.log('e', e);
}
}; };
const handleSave = async () => {
if (/^[\w\d_-]{4,20}$/.test(nickName)) {
const data = await userServices.setNickName({ nickname });
BMCUI.show('修改昵称成功!');
} else {
BMCUI.show('昵称不合法!');
}
};
return ( return (
<SafeAreaView style={styles.container}> <View style={styles.container}>
<View>
<TextInput <TextInput
style={styles.input} style={styles.input}
value={nickName} value={nickname}
onChange={(e) => { setnickName(e.target.value); }} onChangeText={(text) => {setNickName(text);}}
placeholder="请输入昵称" placeholder="请输入昵称"
/> />
</View>
<Text style={styles.tip}>4-20个字符,可由中英文、数字、“-”、“_”组成</Text> <Text style={styles.tip}>4-20个字符,可由中英文、数字、“-”、“_”组成</Text>
<View style={styles.submit}> <View style={styles.submit}>
<TouchableHighlight> <TouchableHighlight onPress={handleSave}>
<View style={styles.btn}> <View style={styles.btn}>
<Text style={styles.btnText}>保存</Text> <Text style={styles.btnText}>保存</Text>
</View> </View>
</TouchableHighlight> </TouchableHighlight>
</View> </View>
</SafeAreaView> </View>
) )
}; };
......
...@@ -6,6 +6,7 @@ export default StyleSheet.create({ ...@@ -6,6 +6,7 @@ export default StyleSheet.create({
marginTop: 12, marginTop: 12,
}, },
input: { input: {
width: '100%',
height: 58, height: 58,
backgroundColor: '#fff', backgroundColor: '#fff',
paddingLeft: 12, paddingLeft: 12,
......
...@@ -3,42 +3,48 @@ ...@@ -3,42 +3,48 @@
* *
* */ * */
import React, { useEffect } from 'react' import React, { useEffect, useState } from 'react'
import { ScrollView, View, Text, SafeAreaView, NativeModules } from 'react-native'; import { ScrollView, View, Text, SafeAreaView, NativeModules, FlatList } from 'react-native';
import { equiment as equimentServices } from '../../services';
import styles from './style'; import styles from './style';
import requestUrl from '../../config';
const { BMCInfo: { getLoginInfo } } = NativeModules;
const Equipment = () => { const Equipment = () => {
const [equimentList, setEquimentList] = useState([]);
useEffect(() => { useEffect(() => {
console.log('NativeModules', NativeModules); getEquimentList();
// getEquimentList();
}, []); }, []);
const getEquimentList = async () => { const getEquimentList = async () => {
try { try {
const { data } = await fetch(`${requestUrl}user/loginDevices`); const data = await equimentServices.getArticleList();
console.log('data', data); setEquimentList(data[0].devices || []);
} catch (e) { } catch (e) {
console.log('e', e); console.log('e', e);
} }
}; };
return ( return (
<SafeAreaView> <SafeAreaView>
<ScrollView style={styles.container}> <ScrollView style={styles.container}>
<Text style={styles.tip}> <Text style={styles.tip}>
标题文字点击无反馈,文字超长则隐藏,文字超长则隐藏 标题文字点击无反馈,文字超长则隐藏,文字超长则隐藏
</Text> </Text>
<View>
<View style={styles.content}> <FlatList
<View style={styles.ceil}> data={equimentList}
keyExtractor={(item, index) => item.deviceId + ''}
renderItem={({ item }) => {
return <View style={styles.ceil}>
<View style={styles.ceilTitle}> <View style={styles.ceilTitle}>
<Text style={styles.ceilName}>设备的名字</Text> <Text style={styles.ceilName}>{item.title}</Text>
<Text style={styles.ceilTag}>本机</Text> {item.currentDevice && <Text style={styles.ceilTag}>本机</Text>}
</View>
<Text style={styles.ceilInfo}>最后登录时间:2019-08-25 16:32</Text>
</View> </View>
<Text style={styles.ceilInfo}>最后登录时间:{item.gmtLoginDisplay}</Text>
</View>;
}}
/>
</View> </View>
</ScrollView> </ScrollView>
</SafeAreaView> </SafeAreaView>
......
...@@ -29,6 +29,9 @@ export default StyleSheet.create({ ...@@ -29,6 +29,9 @@ export default StyleSheet.create({
}, },
ceilTag: { ceilTag: {
marginLeft: 10, marginLeft: 10,
backgroundColor: 'rgba(195, 195, 195, 0.5)',
padding: 2,
borderRadius: 4,
}, },
ceilInfo: { ceilInfo: {
paddingTop: 6, paddingTop: 6,
......
...@@ -8,9 +8,9 @@ const Stack = createStackNavigator(); ...@@ -8,9 +8,9 @@ const Stack = createStackNavigator();
function AllStack() { function AllStack() {
return ( return (
<Stack.Navigator initialRouteName="equiment"> <Stack.Navigator initialRouteName="changeNickname">
<Stack.Screen options={{title: '常用设备'}} name="equiment" component={Equipment} /> <Stack.Screen options={{title: '常用设备'}} name="equiment" component={Equipment} />
<Stack.Screen options={{title: '修改昵称'}} name="ChangeNickname" component={ChangeNickname} /> <Stack.Screen options={{title: '修改昵称'}} name="changeNickname" component={ChangeNickname} />
</Stack.Navigator> </Stack.Navigator>
); );
} }
......
import { $request } from '../utils/request';
export default {
getArticleList(params = {}) {
return $request.get('/user/loginDevices')
},
}
export default {} export { default as equiment } from './equiment';
export { default as user } from './user';
import { $request } from '../utils/request';
export default {
setNickName(params = {}) {
return $request.post('/user/nickname', params)
},
}
import { NativeModules } from 'react-native';
import appConfig from '../config' import appConfig from '../config'
import Toast from 'react-native-root-toast'
const { BMCInfo: { getLoginInfo, getDeviceInfo } } = NativeModules;
// 服务器地址 // 服务器地址
export const API_SERVER = appConfig.API_ROOT export const API_SERVER = appConfig.API_ROOT
...@@ -22,18 +24,37 @@ const errorProcess = (resp, reject, errorToast) => { ...@@ -22,18 +24,37 @@ const errorProcess = (resp, reject, errorToast) => {
const resData = resp.data || {} const resData = resp.data || {}
let message = resData.message || resData.msg || resp.statusText let message = resData.message || resData.msg || resp.statusText
const status = resData.stats || resp.status const status = resData.stats || resp.status
console.log('resData', resData);
if (ERROR_CODE_MAP[status] && ERROR_CODE_MAP[status].message) { if (ERROR_CODE_MAP[status] && ERROR_CODE_MAP[status].message) {
message = ERROR_CODE_MAP[status].message message = ERROR_CODE_MAP[status].message
} }
if (errorToast) { if (errorToast) {
Toast.show(message || '', {
duration: Toast.durations.LONG,
position: Toast.positions.BOTTOM,
})
} }
reject({ message, data: resData }) reject({ message, data: resData })
} }
const getRequestInfo = async (calback, requestInfo = {}) => {
const loginInfo = await getLoginInfo() || {};
const deviceInfo = await getDeviceInfo() || {};
const result = {
'Pvt-Token': loginInfo.pvtToken || '',
'Token': loginInfo.token || '',
'City-Code': loginInfo.cityCode || '',
'Device-Name': deviceInfo.deviceName || '',
'Device-Model': deviceInfo.deviceModel || '',
'Mac': deviceInfo.mac || '',
'Device-Brand': deviceInfo.deviceBrand || '',
'OS-Type': deviceInfo.osType || '',
'Version': deviceInfo.version || '',
'Device-Type': deviceInfo.deviceType || '',
'Device-Code': deviceInfo.deviceCode || '',
'Net': deviceInfo.net || '',
'Resolution': deviceInfo.resolution || '',
};
calback && calback(result);
return result;
};
// 处理响应 // 处理响应
const responseProcess = (resp, resolve, reject, outServer, errorToast) => { const responseProcess = (resp, resolve, reject, outServer, errorToast) => {
if (outServer) { if (outServer) {
...@@ -47,7 +68,7 @@ const responseProcess = (resp, resolve, reject, outServer, errorToast) => { ...@@ -47,7 +68,7 @@ const responseProcess = (resp, resolve, reject, outServer, errorToast) => {
// 封装get post 请求 // 封装get post 请求
export const $request = { export const $request = {
_requestConfig: getRequestInfo, _requestConfig: () => { return getRequestInfo(); },
async _request(url, method, params, config = {}) { async _request(url, method, params, config = {}) {
const isOutRequest = isOutServer(url) const isOutRequest = isOutServer(url)
let headers = config.headers || {} let headers = config.headers || {}
...@@ -73,6 +94,10 @@ export const $request = { ...@@ -73,6 +94,10 @@ export const $request = {
method, method,
headers, headers,
} }
console.log('method', method);
console.log('headers', headers);
console.log('body', body);
console.log('url', url);
if (method === 'POST') { if (method === 'POST') {
fetchConfig.body = body fetchConfig.body = body
} }
...@@ -82,9 +107,11 @@ export const $request = { ...@@ -82,9 +107,11 @@ export const $request = {
if (res.ok) { if (res.ok) {
return res.json() return res.json()
} }
console.log('res1', res);
errorProcess(res, reject, errorToast) errorProcess(res, reject, errorToast)
}) })
.then(json => { .then(json => {
console.log('json', json);
responseProcess(json, resolve, reject, isOutRequest, errorToast) responseProcess(json, resolve, reject, isOutRequest, errorToast)
}) })
.catch(e => { .catch(e => {
......
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