|
@@ -1,3 +1,5 @@
|
|
1
|
+import 'dart:convert';
|
|
2
|
+
|
1
|
3
|
import 'package:dio/dio.dart';
|
2
|
4
|
import 'package:flutter/foundation.dart';
|
3
|
5
|
import 'package:flutter/material.dart';
|
|
@@ -30,6 +32,7 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
30
|
32
|
late TextEditingController accountCtrl;
|
31
|
33
|
late TextEditingController pwdCtrl;
|
32
|
34
|
late ValueNotifier<bool> _showPwd;
|
|
35
|
+ late ValueNotifier<Map<String, dynamic>> _account;
|
33
|
36
|
|
34
|
37
|
void onLogin() async {
|
35
|
38
|
var account = accountCtrl.text;
|
|
@@ -48,6 +51,13 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
48
|
51
|
return;
|
49
|
52
|
}
|
50
|
53
|
await UserService.get().saveLogin(login.data);
|
|
54
|
+
|
|
55
|
+ // 存储 账号、密码
|
|
56
|
+ var actMap = {
|
|
57
|
+ 'phone': account,
|
|
58
|
+ 'pwd': pwd,
|
|
59
|
+ };
|
|
60
|
+ SPUtils.getInstance().saveString('accountpwd', json.encode(actMap));
|
51
|
61
|
getSystemData();
|
52
|
62
|
} on DioException catch (_) {
|
53
|
63
|
} catch (e) {
|
|
@@ -97,6 +107,7 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
97
|
107
|
accountCtrl = TextEditingController();
|
98
|
108
|
pwdCtrl = TextEditingController();
|
99
|
109
|
_showPwd = ValueNotifier<bool>(true);
|
|
110
|
+ _account = ValueNotifier<Map<String, dynamic>>({});
|
100
|
111
|
}
|
101
|
112
|
|
102
|
113
|
@override
|
|
@@ -110,7 +121,10 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
110
|
121
|
LocationUtils.updatePrivacyShow(true, true);
|
111
|
122
|
LocationUtils.updatePrivacyAgree(true);
|
112
|
123
|
LocationUtils.setApiKey(
|
113
|
|
- AppConfig.env == AppEnvironment.product ? '2c783509376e267b24d63b21681686fa' : '7d0c033909f84adc14a0e60a835f044f', '');
|
|
124
|
+ AppConfig.env == AppEnvironment.product
|
|
125
|
+ ? '2c783509376e267b24d63b21681686fa'
|
|
126
|
+ : '7d0c033909f84adc14a0e60a835f044f',
|
|
127
|
+ '');
|
114
|
128
|
|
115
|
129
|
/// 获取手机设备信息
|
116
|
130
|
PrintService.getDeviceInfo();
|
|
@@ -123,6 +137,12 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
123
|
137
|
// 已登录
|
124
|
138
|
if (UserService.get().getLogin() != null) {
|
125
|
139
|
getSystemData();
|
|
140
|
+ } else {
|
|
141
|
+ // 未登录
|
|
142
|
+ String? account = SPUtils.getInstance().getString('accountpwd');
|
|
143
|
+ if (account != null) {
|
|
144
|
+ _account.value = json.decode(account);
|
|
145
|
+ }
|
126
|
146
|
}
|
127
|
147
|
}
|
128
|
148
|
|
|
@@ -224,11 +244,36 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
224
|
244
|
children: [
|
225
|
245
|
const SizedBox(height: 56),
|
226
|
246
|
buildEdit(
|
227
|
|
- ctrl: accountCtrl,
|
228
|
|
- hint: '请输入登录账号',
|
229
|
|
- icon: imgLoginAccount,
|
230
|
|
- action: TextInputAction.next,
|
231
|
|
- ),
|
|
247
|
+ ctrl: accountCtrl,
|
|
248
|
+ hint: '请输入登录账号',
|
|
249
|
+ icon: imgLoginAccount,
|
|
250
|
+ action: TextInputAction.next,
|
|
251
|
+ rightIcon: ValueListenableBuilder(
|
|
252
|
+ valueListenable: _account,
|
|
253
|
+ builder: (ctx, Map<String,dynamic> ac, child){
|
|
254
|
+ if(ac.isNotEmpty){
|
|
255
|
+ return PopupMenuButton(
|
|
256
|
+ icon: const Icon(
|
|
257
|
+ Icons.arrow_drop_down_circle_outlined,
|
|
258
|
+ size: 18,
|
|
259
|
+ color: Color(0xFFBBBBBB),
|
|
260
|
+ ),
|
|
261
|
+ itemBuilder: (context) => [
|
|
262
|
+ PopupMenuItem<String>(
|
|
263
|
+ child: Text("账号:${ac['phone']}"),
|
|
264
|
+ onTap: (){
|
|
265
|
+ accountCtrl.text = ac['phone'];
|
|
266
|
+ pwdCtrl.text =ac['pwd'];
|
|
267
|
+ },
|
|
268
|
+ ),
|
|
269
|
+ ]
|
|
270
|
+ );
|
|
271
|
+ }else{
|
|
272
|
+ return const SizedBox.shrink();
|
|
273
|
+ }
|
|
274
|
+ }
|
|
275
|
+ )
|
|
276
|
+ ),
|
232
|
277
|
const SizedBox(height: 32),
|
233
|
278
|
ValueListenableBuilder(
|
234
|
279
|
valueListenable: _showPwd,
|
|
@@ -243,7 +288,8 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
243
|
288
|
);
|
244
|
289
|
},
|
245
|
290
|
child: IconButton(
|
246
|
|
- icon: const Icon(Icons.remove_red_eye_outlined, size: 18, color: Color(0xFFBBBBBB)),
|
|
291
|
+ icon:
|
|
292
|
+ const Icon(Icons.remove_red_eye_outlined, size: 18, color: Color(0xFFBBBBBB)),
|
247
|
293
|
onPressed: () {
|
248
|
294
|
_showPwd.value = !_showPwd.value;
|
249
|
295
|
},
|
|
@@ -257,7 +303,8 @@ class _LoginPageState extends BaseLifecycleState<LoginPage> {
|
257
|
303
|
MyRouter.forgetPwd();
|
258
|
304
|
},
|
259
|
305
|
style: const ButtonStyle(alignment: Alignment.centerRight),
|
260
|
|
- child: const Text('忘记密码', style: TextStyle(color: Color(0xFF25A6EE), fontSize: 14))),
|
|
306
|
+ child:
|
|
307
|
+ const Text('忘记密码', style: TextStyle(color: Color(0xFF25A6EE), fontSize: 14))),
|
261
|
308
|
),
|
262
|
309
|
const SizedBox(height: 18),
|
263
|
310
|
],
|