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 = {
API_ROOT: 'http://devbmcmapp.hikcreate.com/',
API_ROOT: 'http://devbmcapp.hikcreate.com',
}
const test = {
API_ROOT: 'http://testbmcmapp.hikcreate.com/',
API_ROOT: 'http://testbmcapp.hikcreate.com',
}
const prod = {
API_ROOT: 'https://bmcmapp.hikcreate.com/',
API_ROOT: 'https://bmcapp.hikcreate.com',
}
const configs = {
......
......@@ -4,45 +4,54 @@
* */
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 requestUrl from '../../config';
const { BMCInfo: { getUserInfo }, BMCUI } = NativeModules;
const Equipment = () => {
const [nickName, setnickName] = useState('');
const [nickname, setNickName] = useState('');
useEffect(() => {
getEquimentList();
getNativeLoginInfo();
}, []);
const getEquimentList = async () => {
try {
const { data } = await fetch(`${requestUrl}user/loginDevices`);
console.log('data', data);
} catch (e) {
console.log('e', e);
}
const getNativeLoginInfo = async () => {
const data = await getUserInfo();
setNickName(data.nickname);
};
const handleSave = async () => {
if (/^[\w\d_-]{4,20}$/.test(nickName)) {
const data = await userServices.setNickName({ nickname });
BMCUI.show('修改昵称成功!');
} else {
BMCUI.show('昵称不合法!');
}
};
return (
<SafeAreaView style={styles.container}>
<View style={styles.container}>
<View>
<TextInput
style={styles.input}
value={nickName}
onChange={(e) => { setnickName(e.target.value); }}
value={nickname}
onChangeText={(text) => {setNickName(text);}}
placeholder="请输入昵称"
/>
</View>
<Text style={styles.tip}>4-20个字符,可由中英文、数字、“-”、“_”组成</Text>
<View style={styles.submit}>
<TouchableHighlight>
<TouchableHighlight onPress={handleSave}>
<View style={styles.btn}>
<Text style={styles.btnText}>保存</Text>
</View>
</TouchableHighlight>
</View>
</SafeAreaView>
</View>
)
};
......
......@@ -6,6 +6,7 @@ export default StyleSheet.create({
marginTop: 12,
},
input: {
width: '100%',
height: 58,
backgroundColor: '#fff',
paddingLeft: 12,
......
......@@ -3,42 +3,48 @@
*
* */
import React, { useEffect } from 'react'
import { ScrollView, View, Text, SafeAreaView, NativeModules } from 'react-native';
import React, { useEffect, useState } from 'react'
import { ScrollView, View, Text, SafeAreaView, NativeModules, FlatList } from 'react-native';
import { equiment as equimentServices } from '../../services';
import styles from './style';
import requestUrl from '../../config';
const { BMCInfo: { getLoginInfo } } = NativeModules;
const Equipment = () => {
const [equimentList, setEquimentList] = useState([]);
useEffect(() => {
console.log('NativeModules', NativeModules);
// getEquimentList();
getEquimentList();
}, []);
const getEquimentList = async () => {
try {
const { data } = await fetch(`${requestUrl}user/loginDevices`);
console.log('data', data);
const data = await equimentServices.getArticleList();
setEquimentList(data[0].devices || []);
} 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>
<FlatList
data={equimentList}
keyExtractor={(item, index) => item.deviceId + ''}
renderItem={({ item }) => {
return <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>
<Text style={styles.ceilName}>{item.title}</Text>
{item.currentDevice && <Text style={styles.ceilTag}>本机</Text>}
</View>
<Text style={styles.ceilInfo}>最后登录时间:{item.gmtLoginDisplay}</Text>
</View>;
}}
/>
</View>
</ScrollView>
</SafeAreaView>
......
......@@ -29,6 +29,9 @@ export default StyleSheet.create({
},
ceilTag: {
marginLeft: 10,
backgroundColor: 'rgba(195, 195, 195, 0.5)',
padding: 2,
borderRadius: 4,
},
ceilInfo: {
paddingTop: 6,
......
......@@ -8,9 +8,9 @@ const Stack = createStackNavigator();
function AllStack() {
return (
<Stack.Navigator initialRouteName="equiment">
<Stack.Navigator initialRouteName="changeNickname">
<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>
);
}
......
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 Toast from 'react-native-root-toast'
const { BMCInfo: { getLoginInfo, getDeviceInfo } } = NativeModules;
// 服务器地址
export const API_SERVER = appConfig.API_ROOT
......@@ -22,18 +24,37 @@ const errorProcess = (resp, reject, errorToast) => {
const resData = resp.data || {}
let message = resData.message || resData.msg || resp.statusText
const status = resData.stats || resp.status
console.log('resData', resData);
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 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) => {
if (outServer) {
......@@ -47,7 +68,7 @@ const responseProcess = (resp, resolve, reject, outServer, errorToast) => {
// 封装get post 请求
export const $request = {
_requestConfig: getRequestInfo,
_requestConfig: () => { return getRequestInfo(); },
async _request(url, method, params, config = {}) {
const isOutRequest = isOutServer(url)
let headers = config.headers || {}
......@@ -73,6 +94,10 @@ export const $request = {
method,
headers,
}
console.log('method', method);
console.log('headers', headers);
console.log('body', body);
console.log('url', url);
if (method === 'POST') {
fetchConfig.body = body
}
......@@ -82,9 +107,11 @@ export const $request = {
if (res.ok) {
return res.json()
}
console.log('res1', res);
errorProcess(res, reject, errorToast)
})
.then(json => {
console.log('json', json);
responseProcess(json, resolve, reject, isOutRequest, errorToast)
})
.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