|
|
'use strict';
|
|
|
|
|
|
import {Platform, Dimensions} from 'react-native';
|
|
|
import ReactNative, {Platform, Dimensions} from 'react-native';
|
|
|
import CONFIG from '../config/config';
|
|
|
import DeviceInfo from 'react-native-device-info';
|
|
|
import queryString from 'query-string';
|
...
|
...
|
@@ -40,13 +40,18 @@ export default class Request { |
|
|
* @return {[promise]}
|
|
|
*/
|
|
|
async get(opts) {
|
|
|
|
|
|
if (opts.body && !opts.body.hasOwnProperty('uid')) {
|
|
|
let uid = await ReactNative.NativeModules.RNNativeConfig.uid();
|
|
|
opts.body.uid = uid
|
|
|
}
|
|
|
try {
|
|
|
let response = await this._fetch({
|
|
|
method: 'GET',
|
|
|
url: opts.url,
|
|
|
body: opts.body,
|
|
|
timeout: opts.timeout | 0,
|
|
|
});
|
|
|
});
|
|
|
|
|
|
let data = await this._parseResponse(response);
|
|
|
return data;
|
...
|
...
|
@@ -73,6 +78,10 @@ export default class Request { |
|
|
* @return {[promise]}
|
|
|
*/
|
|
|
async post(opts) {
|
|
|
if (opts.body && !opts.body.hasOwnProperty('uid')) {
|
|
|
let uid = await ReactNative.NativeModules.RNNativeConfig.uid();
|
|
|
opts.body.uid = uid
|
|
|
}
|
|
|
try {
|
|
|
let response = await this._fetch({
|
|
|
method: 'POST',
|
...
|
...
|
@@ -165,12 +174,13 @@ export default class Request { |
|
|
let client_type = Platform.OS === 'ios' ? 'iphone' : 'android';
|
|
|
let {height, width} = Dimensions.get('window');
|
|
|
let screen_size = width + 'x' + height;
|
|
|
|
|
|
let udid = ReactNative.NativeModules.RNNativeConfig.udid;
|
|
|
return {
|
|
|
app_version,
|
|
|
os_version,
|
|
|
client_type,
|
|
|
screen_size,
|
|
|
udid,
|
|
|
};
|
|
|
}
|
|
|
|
...
|
...
|
|