На экране проведения покупки правильно обрабатывается сумма покупки, передается на экран подтверждения
This commit is contained in:
@@ -21,7 +21,7 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
}
|
||||
|
||||
@override getHint() {
|
||||
return 'ID merchant';
|
||||
return 'ID магазина';
|
||||
}
|
||||
|
||||
@overide getMenuButtons(BuildContext context) {
|
||||
@@ -37,35 +37,17 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
getLogo(),
|
||||
getHintLabel(),
|
||||
getDecoratedTextWidget(),
|
||||
_getButton(context)]))
|
||||
buildButton(new EdgeInsets.only(top: 36.0, left: buttonVerticalMargin, right: buttonVerticalMargin),
|
||||
buildRaisedButton(context, 'ЗАРЕГИСТРИРОВАТЬ', _isValidMerchantID() && !loading ? () => _registerShop(context) : null))]))
|
||||
].reversed.toList()));
|
||||
}
|
||||
|
||||
/// Метод возвращает кнопку, которая запускает отправку токена кассы на сервер.
|
||||
_getButton(BuildContext context) {
|
||||
double buttonHeight = 42.0;
|
||||
double topMargin = 36.0;
|
||||
double horizontalPadding = 40.0; // Отступы по краям от кнопки.
|
||||
return new Container(margin: new EdgeInsets.only(top: topMargin), height: buttonHeight,
|
||||
padding: new EdgeInsets.only(left: horizontalPadding, right: horizontalPadding),
|
||||
child: new RaisedButton(child: new Text('ЗАРЕГИСТРИРОВАТЬ',
|
||||
style: new TextStyle(color: Colors.white)),
|
||||
onPressed: _isValidMerchantID() && !loading ? () => _registerShop(context) : null,
|
||||
color: primaryColor));
|
||||
}
|
||||
|
||||
/// Токен кассы - это DIN код. DIN код - это специальный код динекта, максимальная его длина - 25 символов.
|
||||
_isValidMerchantID() {
|
||||
print("${textFieldValue.length}");
|
||||
return textFieldValue.length > 0 && textFieldValue.length < 25;
|
||||
}
|
||||
|
||||
/// Смена состояния экрана при изменении текста в поле ввода.
|
||||
_handleUserInput(String text) {
|
||||
setState(() {
|
||||
textFieldValue = text;
|
||||
});
|
||||
}
|
||||
|
||||
/// Показать индикатор, запросить токен.
|
||||
_registerShop(BuildContext context) {
|
||||
setState(() {
|
||||
@@ -84,7 +66,6 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
|
||||
/// Получение от платформы id установки, формирование запроса на получение токена, сохранение токена.
|
||||
_register(BuildContext context) async {
|
||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||
|
||||
String url = intUrl + 'tokens/?_dmapptoken=' + intToken;
|
||||
String pos = (new DateTime.now().millisecondsSinceEpoch / 1000).toString();
|
||||
@@ -95,31 +76,33 @@ class _RegistrationScreenState extends BaseState<RegistrationScreen> {
|
||||
'pos': pos,
|
||||
};
|
||||
|
||||
httpClient.post(url, body: body).then((response) {
|
||||
pushRoute(context, new FinishRegistrationScreen());
|
||||
|
||||
// httpClient.post(url, body: body).then((response) {
|
||||
|
||||
setState(() {
|
||||
error = null;
|
||||
});
|
||||
|
||||
print(response.body);
|
||||
Map parsedMap = JSON.decode(response.body);
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
if (response.statusCode == 201) {
|
||||
token = parsedMap['token'];
|
||||
platform.invokeMethod('saveToken', {'token' : token});
|
||||
platform.invokeMethod('saveMerchantID', {'merchantID' : merchantID});
|
||||
pushRoute(context, new FinishRegistrationScreen());
|
||||
} else {
|
||||
setState(() {
|
||||
error = parsedMap['errors'][0];
|
||||
});
|
||||
}
|
||||
}).catchError((error) {
|
||||
setState(() {
|
||||
error = 'Отсутствует интернет соединение';
|
||||
});
|
||||
});
|
||||
// print(response.body);
|
||||
// Map parsedMap = JSON.decode(response.body);
|
||||
// setState(() {
|
||||
// loading = false;
|
||||
// });
|
||||
// if (response.statusCode == 201) {
|
||||
// token = parsedMap['token'];
|
||||
// platform.invokeMethod('saveToken', {'token' : token});
|
||||
// platform.invokeMethod('saveMerchantID', {'merchantID' : merchantID});
|
||||
// pushRoute(context, new FinishRegistrationScreen());
|
||||
// } else {
|
||||
// setState(() {
|
||||
// error = parsedMap['errors'][0];
|
||||
// });
|
||||
// }
|
||||
// }).catchError((error) {
|
||||
// setState(() {
|
||||
// error = 'Отсутствует интернет соединение';
|
||||
// });
|
||||
// });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user