Merge branch 'master' into RG-3433

This commit is contained in:
Ivan Murashov
2017-09-04 19:00:01 +03:00
4 changed files with 26 additions and 266 deletions

View File

@@ -29,6 +29,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
getLoyality(user['loyalty_url']);
}
bool purchaseInProgress = false;
Map user;
String card = '';
String loyality = '';
@@ -186,35 +187,37 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
}
purchase(String sumTotal) async {
if (await platform.invokeMethod('isOnline')) {
if (!purchaseInProgress) {
purchaseInProgress = true;
platform.invokeMethod('getDocID').then((result) {
platform.invokeMethod('getDocID').then((result) {
String url = user['purchases_url'];
String url = user['purchases_url'];
var body = {
'doc_id': result,
'curr_iso_code': '643',
'commit': 'true',
'sum_total': sumTotal
};
var body = {
'doc_id': result,
'curr_iso_code': '643',
'commit': 'true',
'sum_total': sumTotal
};
var headers = {
'DM-Authorization': 'dmapptoken $appToken',
'Authorization': 'dmtoken ${token}'
};
var headers = {
'DM-Authorization': 'dmapptoken $appToken',
'Authorization': 'dmtoken ${token}'
};
httpClient.post(url, body: body, headers: headers).then((response) {
httpClient.post(url, body: body, headers: headers).then((response) {
print(response.body);
Navigator.of(context).pop();
pushRoute(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
print(response.body);
Navigator.of(context).pop();
pushRoute(context, new PurchaseSuccessScreen(sumTotal, user['first_name'] == null ? '' : user['first_name']));
}).catchError((error) {
print(error.toString());
});
});
}).catchError((error) {
purchaseInProgress = false;
print(error.toString());
});
});
}
}
}
}