small fix

This commit is contained in:
Semyon Babushkin
2017-10-31 17:27:04 +03:00
parent 2bf999ce48
commit 52aab9a6e0
2 changed files with 9 additions and 8 deletions

View File

@@ -52,6 +52,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
Map user;
String card = '';
String flavor = '';
String loyalityType = '';
String loyalty = '';
String bonus = '';
bool dataLoaded = false;
@@ -75,7 +76,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
widgets.add(getInputField()); // Нельзя добавить еще одно поле таким же способом
if (this.flavor != 'autobonus') {
if (this.loyalityType == 'bonus') {
widgets.add(getBonusInputField());
}
@@ -195,9 +196,11 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
getLoyaltyRequest(url, helper).then((response) {
print(response);
this.dataLoaded = true;
Map loyality = JSON.decode(response.body);
setState(() {
this.flavor = flavor;
setBonuses(JSON.decode(response.body), showBonus );
this.loyalityType = loyality['type'];
setBonuses(loyality, showBonus);
});
}).catchError((error) {
print(error.toString());
@@ -355,7 +358,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
}
void setBonuses(Map bonuses, bool showBonus) {
print('kifio ' + bonuses['type']);
print('kifio ' + this.loyalityType);
if (bonuses['type'] == 'amount') {
this.loyalty = '${user['discount']}%';
} else {
@@ -364,7 +367,7 @@ class PurchaseScreenState<T> extends BaseState<PurchaseScreen> {
this.loyalty = '${loyaltyVal.toStringAsFixed(0)}%';
}
if (showBonus && (bonuses['type'] == 'bonus')) {
if (showBonus && (this.loyalityType == 'bonus')) {
this.bonus = '${user['bonus']}';
}
print('kifio ' + this.loyalty);