|
|
@@ -21,11 +21,12 @@ class QuickLoginHelper {
|
|
|
static final QuickpassFlutterPlugin quickLoginPlugin =
|
|
|
QuickpassFlutterPlugin();
|
|
|
|
|
|
+ static Map<String, dynamic>? _configMap;
|
|
|
+
|
|
|
static Future<void> init() {
|
|
|
return quickLoginPlugin.init(_businessId).then((map) {
|
|
|
bool result = map?['success'];
|
|
|
AtmobLog.d(tag, 'init success:$result');
|
|
|
- _setUiConfig();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -37,17 +38,20 @@ class QuickLoginHelper {
|
|
|
quickLoginPlugin.closeLoginAuthView();
|
|
|
}
|
|
|
|
|
|
- static void _setUiConfig() {
|
|
|
- Map<String, dynamic> configMap;
|
|
|
+ static Future<void> _setUiConfig() async {
|
|
|
+ _configMap ??= await _getFileConfig();
|
|
|
+ quickLoginPlugin.setUiConfig(_configMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ static Future<Map<String, dynamic>> _getFileConfig() async {
|
|
|
String file = "";
|
|
|
if (Platform.isIOS) {
|
|
|
file = Assets.config.iosQuickLoginConfig;
|
|
|
} else if (Platform.isAndroid) {
|
|
|
file = Assets.config.androidQuickLoginConfig;
|
|
|
}
|
|
|
- rootBundle.loadString(file).then((value) async {
|
|
|
- configMap = {"uiConfig": json.decode(value)};
|
|
|
- quickLoginPlugin.setUiConfig(configMap);
|
|
|
+ return rootBundle.loadString(file).then((value) {
|
|
|
+ return {"uiConfig": json.decode(value)};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -55,7 +59,6 @@ class QuickLoginHelper {
|
|
|
required void Function(String token) onSuccess,
|
|
|
required void Function(String errorMsg) onError,
|
|
|
}) async {
|
|
|
- // _setUiConfig();//仅测试
|
|
|
Map<dynamic, dynamic>? map = await quickLoginPlugin.preFetchNumber();
|
|
|
if (map?['success'] == true) {
|
|
|
var ydToken = map?['token'];
|
|
|
@@ -75,6 +78,7 @@ class QuickLoginHelper {
|
|
|
required void Function(String errorMsg) onError,
|
|
|
}) async {
|
|
|
try {
|
|
|
+ await _setUiConfig();
|
|
|
Map<dynamic, dynamic>? map = await quickLoginPlugin.onePassLogin();
|
|
|
if (map?["success"]) {
|
|
|
var accessToken = map?["accessToken"];
|
|
|
@@ -86,11 +90,15 @@ class QuickLoginHelper {
|
|
|
var errorMsg = map?["msg"];
|
|
|
AtmobLog.e(tag, "onePassLogin error msg:$errorMsg");
|
|
|
onError(errorMsg);
|
|
|
+ closeLoginAuthView();
|
|
|
}
|
|
|
- closeLoginAuthView();
|
|
|
} catch (e) {
|
|
|
onError(e.toString());
|
|
|
closeLoginAuthView();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ static void dispose() {
|
|
|
+ _configMap = null;
|
|
|
+ }
|
|
|
}
|