张萌 4 years ago
commit 3ca092666e

@ -21,6 +21,9 @@ class _Auth {
////退app ////退app
String get login => '/login/loginSMSUser'; String get login => '/login/loginSMSUser';
////退退
String get logout => '/user/signOut';
} }
class _User { class _User {

@ -2,6 +2,7 @@
import 'dart:io'; import 'dart:io';
// Flutter imports: // Flutter imports:
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Project imports: // Project imports:
@ -24,13 +25,9 @@ class UserProvider extends ChangeNotifier {
/// ///
Future setLogin(int token) async { Future setLogin(int token) async {
_isLogin = true; _isLogin = true;
NetUtil() NetUtil().auth(token);
.dio await HiveStore.appBox.put('token', token);
.options await HiveStore.appBox.put('login', true);
.headers
.putIfAbsent('butlerApp-admin-token', () => token);
HiveStore.appBox.put('token', token);
HiveStore.appBox.put('login', true);
_profileModel = await updateProfile(); _profileModel = await updateProfile();
_infoModel = await updateUserInfo(); _infoModel = await updateUserInfo();
// await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true) // await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true)
@ -62,9 +59,12 @@ class UserProvider extends ChangeNotifier {
} }
/// ///
logout() { logout() async {
await NetUtil().get(API.auth.logout, showMessage: true);
NetUtil().logout();
_isLogin = false; _isLogin = false;
HiveStore.appBox.delete('token'); await HiveStore.appBox.delete('token');
await HiveStore.appBox.put('login', false);
notifyListeners(); notifyListeners();
} }

@ -37,6 +37,7 @@ class NetUtil {
onRequest: (RequestOptions options) async => options, onRequest: (RequestOptions options) async => options,
onResponse: (Response response) async { onResponse: (Response response) async {
LoggerData.addData(response); LoggerData.addData(response);
print(response.headers);
return response; return response;
}, },
onError: (DioError error) async { onError: (DioError error) async {
@ -47,8 +48,12 @@ class NetUtil {
} }
///call auth after login ///call auth after login
auth(String token) { auth(int token) {
_dio.options.headers.putIfAbsent('Butler-Admin-Token', () => token); _dio.options.headers.putIfAbsent('butlerApp-admin-token', () => token);
}
logout() {
_dio.options.headers.remove('butlerApp-admin-token');
} }
/// ## alias of Dio().get /// ## alias of Dio().get

@ -551,11 +551,9 @@ packages:
power_logger: power_logger:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." name: power_logger
ref: HEAD url: "https://pub.flutter-io.cn"
resolved-ref: "5a6be230ed03e9da941b2c67018e4a6bc3e81759" source: hosted
url: "http://192.168.2.201:8099/aku_fe/power_logger.git"
source: git
version: "0.1.0" version: "0.1.0"
pretty_json: pretty_json:
dependency: transitive dependency: transitive

@ -51,9 +51,7 @@ dependencies:
dio: dio:
power_logger: power_logger: ^0.1.0
git:
url: http://192.168.2.201:8099/aku_fe/power_logger.git
logger: ^0.9.4 logger: ^0.9.4
aku_ui: aku_ui:
git: git:

Loading…
Cancel
Save