Проведение покупки, проверка деактивированного токена, подтверждение логаута, функциональная маска на сканере, кнопка назад в faq
This commit is contained in:
@@ -55,10 +55,28 @@ void main() {
|
||||
}
|
||||
|
||||
/// Проверка статуса токена. Токен может быть активирован, либо не активирован.
|
||||
checkToken(BuildContext context) async {
|
||||
checkTokenStatus(BuildContext context) async {
|
||||
return httpClient.get(intUrl + 'tokens/' + token + '?_dmapptoken=' + intToken);
|
||||
}
|
||||
|
||||
createToken(String merchantId) async {
|
||||
|
||||
String url = intUrl + 'tokens/?_dmapptoken=' + intToken;
|
||||
|
||||
String posID = await platform.invokeMethod('getPosID');
|
||||
print('posID: ${posID}');
|
||||
|
||||
print('merchantId: ${merchantId}');
|
||||
|
||||
// Поле description - необязательное.
|
||||
var body = {
|
||||
'merchant_shop': merchantId,
|
||||
'pos': posID,
|
||||
};
|
||||
|
||||
return httpClient.post(url, body: body);
|
||||
}
|
||||
|
||||
/// Запуск спецефичной для каждой платформы части приложения - сканера.
|
||||
/// Может производиться с нескольких экранов (splash, finish_registration).
|
||||
startScanner(BuildContext context) async {
|
||||
@@ -88,7 +106,7 @@ startScanner(BuildContext context) async {
|
||||
print(response.body);
|
||||
|
||||
List usersList = JSON.decode(response.body);
|
||||
|
||||
print('usersList.length: ${usersList.length}');
|
||||
if (usersList.length > 0) {
|
||||
pushRoute(context, new PurchaseScreen(usersList[0], card));
|
||||
}
|
||||
@@ -105,21 +123,38 @@ startScanner(BuildContext context) async {
|
||||
}
|
||||
|
||||
logout(BuildContext context) {
|
||||
if (token != null) {
|
||||
String url = intUrl + 'tokens/' + token + '?_dmapptoken=' + intToken;
|
||||
print(url);
|
||||
httpClient.delete(url).then((response) {
|
||||
print(response.body);
|
||||
const platform = const MethodChannel('com.dinect.checker/instance_id');
|
||||
platform.invokeMethod('removeKeys');
|
||||
Navigator.of(context).pop();
|
||||
pushRoute(context, new RegistrationScreen());
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
showDialog(context: context, child: new AlertDialog(
|
||||
title: new Text('Подтверждение'),
|
||||
content: new Text('Вы действительно хотите выйти и ввести другой номер магазина?'),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text('Нет'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text('Да'),
|
||||
onPressed: () {
|
||||
if (token != null) {
|
||||
String url = intUrl + 'tokens/' + token + '?_dmapptoken=' + intToken;
|
||||
print(url);
|
||||
httpClient.delete(url).then((response) async {
|
||||
print(response.body);
|
||||
await platform.invokeMethod('removeKeys');
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
pushRoute(context, new RegistrationScreen());
|
||||
}).catchError((error) {
|
||||
print(error.toString());
|
||||
});
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
)]));
|
||||
|
||||
}
|
||||
|
||||
/// Навигация по приложению.
|
||||
|
||||
Reference in New Issue
Block a user