Browse Source

免输入账号登录,经纬度精确调整。

liujq 4 months ago
parent
commit
3df2fd9b2d

+ 7 - 2
android/build.gradle

@@ -5,8 +5,13 @@ allprojects {
5 5
         }
6 6
     }
7 7
     repositories {
8
-        google()
9
-        mavenCentral()
8
+//        google()
9
+//        mavenCentral()
10
+        maven { url 'https://maven.aliyun.com/repository/central/' }
11
+        maven { url 'https://maven.aliyun.com/repository/public/' }
12
+        maven { url 'https://maven.aliyun.com/repository/google/' }
13
+        maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
14
+
10 15
     }
11 16
 }
12 17
 

+ 1 - 1
lib/page/home/store_house_page.dart

@@ -147,7 +147,7 @@ class _StoreHousePageState extends BaseLifecycleState<StoreHousePage> {
147 147
                                     children: [
148 148
                                       StorehouseItem(left: '粮食品种',right: data?.itemList?.first?.lspzmc),
149 149
                                       StorehouseItem(left: '粮食等级',right: data?.itemList?.first?.lsdjmc),
150
-                                      StorehouseItem(left: '库存',right: '${data?.itemList?.first?.jjsl}'),
150
+                                      StorehouseItem(left: '库存',right: '${data?.itemList?.first?.jjsl}kg'),
151 151
                                       StorehouseItem(left: '储存性质',right: data?.itemList?.first?.lsxzmc),
152 152
                                       StorehouseItem(left: '粮权归属单位',right: data?.itemList?.first?.lqgsdw),
153 153
                                       StorehouseItem(left: '入仓时间',right: data?.itemList?.first?.timeStr()),

+ 55 - 8
lib/page/login/login_page.dart

@@ -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
           ],

+ 2 - 2
lib/page/sample_task/reap_sample_detail/reap_sample_basic_detail_page.dart

@@ -168,8 +168,8 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
168 168
   void initLocation() {
169 169
     locationListener = LocationUtils.onLocationChanged().listen((value) async {
170 170
       logger.d('LocationChanged:${jsonEncode(value)}');
171
-      var lon = (value['longitude'] as double).toStringAsFixed(2);
172
-      var lat = (value['latitude'] as double).toStringAsFixed(2);
171
+      var lon = (value['longitude'] as double).toStringAsFixed(6);
172
+      var lat = (value['latitude'] as double).toStringAsFixed(6);
173 173
       String province = value['province'] as String;
174 174
       String city = value['city'] as String;
175 175
       String district = value['district'] as String;

+ 2 - 0
lib/page/user_center/account_manage_page.dart

@@ -4,6 +4,7 @@ import 'package:lszlgl/base/base_lifecycle_state.dart';
4 4
 import 'package:lszlgl/base/base_state.dart';
5 5
 import 'package:lszlgl/model/rsp/user_rsp.dart';
6 6
 import 'package:lszlgl/service/user_service.dart';
7
+import 'package:lszlgl/utils/sp_utils.dart';
7 8
 import 'package:lszlgl/widget/button.dart';
8 9
 import 'package:lszlgl/widget/card_item.dart';
9 10
 
@@ -23,6 +24,7 @@ class _AccountManagePageState extends BaseLifecycleState<AccountManagePage> {
23 24
   }
24 25
 
25 26
   void onLogout() {
27
+    SPUtils.getInstance().remove('accountpwd');
26 28
     UserService.get().logout();
27 29
   }
28 30