| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'dart:io'; | 
					
						
							|  |  |  | import 'package:flutter/services.dart'; | 
					
						
							| 
									
										
										
										
											2025-09-15 15:53:47 +08:00
										 |  |  | import 'package:qhd_prevention/customWidget/single_image_viewer.dart'; | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  | import 'package:qhd_prevention/customWidget/toast_util.dart'; | 
					
						
							|  |  |  | import 'package:qhd_prevention/http/ApiService.dart'; | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  | import 'package:qhd_prevention/pages/my_appbar.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import '../../tools/tools.dart'; | 
					
						
							|  |  |  | import 'mine_sign_page.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FirstSignPage extends StatefulWidget { | 
					
						
							|  |  |  |   const FirstSignPage({super.key}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   State<FirstSignPage> createState() => _SignatureUpdatePageState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _SignatureUpdatePageState extends State<FirstSignPage> { | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |   String imagePath = ""; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-06 16:52:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							|  |  |  |   void initState() { | 
					
						
							|  |  |  |     super.initState(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _getMySignature(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> _getMySignature() async { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     try { | 
					
						
							|  |  |  |       final response = await ApiService.getMySignature( ); | 
					
						
							|  |  |  |       if (response['result'] == 'success') { | 
					
						
							|  |  |  |         setState(() { | 
					
						
							|  |  |  |           imagePath= ApiService.baseImgPath +response['IMGURL']; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							|  |  |  |      print("错误:${e.toString()}"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |   Future<void> refreshSign() async { | 
					
						
							|  |  |  |     if (imagePath.isEmpty) { | 
					
						
							|  |  |  |       ToastUtil.showNormal(context, '请签字'); | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-09-06 16:52:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if(imagePath.startsWith('http')){ | 
					
						
							|  |  |  |       ToastUtil.showSuccess(context, '保存成功'); | 
					
						
							|  |  |  |       Navigator.pop(context); | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |     LoadingDialogHelper.show(); | 
					
						
							|  |  |  |     final result = await ApiService.refreshSignInfo(imagePath); | 
					
						
							|  |  |  |     LoadingDialogHelper.hide(); | 
					
						
							|  |  |  |     if (result['result'] == 'success') { | 
					
						
							|  |  |  |       ToastUtil.showSuccess(context, '保存成功'); | 
					
						
							|  |  |  |       Navigator.pop(context); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   Widget build(BuildContext context) { | 
					
						
							|  |  |  |     return Scaffold( | 
					
						
							|  |  |  |       appBar: MyAppbar(title: "更新签字信息"), | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |       body: Container( | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |         margin: EdgeInsets.all(16), | 
					
						
							|  |  |  |         child: Column( | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |           crossAxisAlignment: CrossAxisAlignment.start, | 
					
						
							|  |  |  |           children: [ | 
					
						
							|  |  |  |             Row( | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |               mainAxisAlignment: MainAxisAlignment.spaceBetween, | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |               children: [ | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |                 Text("用户", style: TextStyle(color: Colors.black, fontSize: 16)), | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |                 _buildConfirmButton(), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |               ], | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |             const SizedBox(height: 8), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |             Row( | 
					
						
							|  |  |  |               children: [ | 
					
						
							|  |  |  |                 if (imagePath.isNotEmpty) | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |                   Text( | 
					
						
							|  |  |  |                     '签字照片:', | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |                     style: TextStyle( | 
					
						
							|  |  |  |                       fontSize: 14, | 
					
						
							|  |  |  |                       fontWeight: FontWeight.bold, | 
					
						
							|  |  |  |                       color: Colors.grey, | 
					
						
							|  |  |  |                     ), | 
					
						
							|  |  |  |                   ), | 
					
						
							|  |  |  |                 const SizedBox(width: 15), | 
					
						
							| 
									
										
										
										
											2025-09-06 16:52:08 +08:00
										 |  |  |                 if (imagePath.isNotEmpty&&!imagePath.startsWith('http')) | 
					
						
							| 
									
										
										
										
											2025-09-15 15:53:47 +08:00
										 |  |  |                   GestureDetector( | 
					
						
							|  |  |  |                     onTap: () { | 
					
						
							|  |  |  |                       presentOpaque(SingleImageViewer(imageUrl: imagePath), context); | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                     child: Image.file( | 
					
						
							|  |  |  |                       File(imagePath), | 
					
						
							|  |  |  |                       width: 200, | 
					
						
							|  |  |  |                       height: 100, | 
					
						
							|  |  |  |                       fit: BoxFit.contain , | 
					
						
							|  |  |  |                     ), | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2025-09-15 15:53:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-06 16:52:08 +08:00
										 |  |  |                 if (imagePath.isNotEmpty&&imagePath.startsWith('http')) | 
					
						
							| 
									
										
										
										
											2025-09-15 15:53:47 +08:00
										 |  |  |                   GestureDetector( | 
					
						
							|  |  |  |                     onTap: () { | 
					
						
							|  |  |  |                       presentOpaque(SingleImageViewer(imageUrl: imagePath), context); | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                     child: Image.network( | 
					
						
							|  |  |  |                           imagePath, | 
					
						
							|  |  |  |                           width: 200, | 
					
						
							|  |  |  |                           height: 100, | 
					
						
							|  |  |  |                           fit: BoxFit.contain , | 
					
						
							|  |  |  |                         ), | 
					
						
							| 
									
										
										
										
											2025-09-06 16:52:08 +08:00
										 |  |  |                   ), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |               ], | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |             ), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |             const SizedBox(height: 8), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |             // 确认按钮
 | 
					
						
							|  |  |  |             // const Spacer(),
 | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |             _buildTrueButton(), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |           ], | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |       ), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |   Widget _buildTrueButton() { | 
					
						
							|  |  |  |     return Center( | 
					
						
							|  |  |  |       child: ElevatedButton( | 
					
						
							|  |  |  |         onPressed: () { | 
					
						
							|  |  |  |           refreshSign(); | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         style: ElevatedButton.styleFrom( | 
					
						
							|  |  |  |           backgroundColor: const Color(0xFF4285F4), | 
					
						
							|  |  |  |           padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 80), | 
					
						
							|  |  |  |           shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         child: Text('确认', style: TextStyle(fontSize: 14, color: Colors.white)), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |   Widget _buildConfirmButton() { | 
					
						
							|  |  |  |     return SizedBox( | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |       width: 80, | 
					
						
							|  |  |  |       height: 30, | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |       child: ElevatedButton( | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |         onPressed: () async { | 
					
						
							| 
									
										
										
										
											2025-08-21 16:44:24 +08:00
										 |  |  |           await NativeOrientation.setLandscape(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |           final path = await Navigator.push( | 
					
						
							|  |  |  |             context, | 
					
						
							|  |  |  |             MaterialPageRoute(builder: (context) => MineSignPage()), | 
					
						
							|  |  |  |           ); | 
					
						
							| 
									
										
										
										
											2025-08-21 16:44:24 +08:00
										 |  |  |           await NativeOrientation.setPortrait(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |           // 更新状态(当子页面关闭时)
 | 
					
						
							|  |  |  |           setState(() { | 
					
						
							|  |  |  |             imagePath = path ?? ''; | 
					
						
							|  |  |  |           }); | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |         style: ElevatedButton.styleFrom( | 
					
						
							|  |  |  |           backgroundColor: const Color(0xFF4285F4), | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |           padding: const EdgeInsets.symmetric(vertical: 5), | 
					
						
							| 
									
										
										
										
											2025-08-25 14:34:20 +08:00
										 |  |  |           shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |         ), | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  |         child: Text( | 
					
						
							|  |  |  |           '手写签字', | 
					
						
							|  |  |  |           style: TextStyle(fontSize: 12, color: Colors.white), | 
					
						
							| 
									
										
										
										
											2025-07-14 18:01:16 +08:00
										 |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-07-16 08:38:10 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |