Browse Source

0018647: 【web客户端】web客户端登录工作站账号,需要支持可导入签名图片的功能

finlay 10 months ago
parent
commit
1528e120c8

+ 15 - 5
lib/pages/home/personal_center/controller.dart

@@ -101,15 +101,25 @@ class PersonalCenterController extends FControllerBase {
 
   Future<void> chooseImage() async {
     final files = await FilePicker.platform.pickFiles(type: FileType.image);
-    if (files != null && files.files.first.path.isNotNullOrEmpty) {
+    if (files != null && files.files.first.bytes != null) {
       // 这里获取到的是一个File对象,你可以根据需要进行处理
       // 例如,将文件路径传递给Image组件进行显示
-      String imagePath = files.files.first.path!;
+      var imageBytes = files.files.first.bytes!;
       // 接下来,你可以将imagePath传递给Image组件
       //  if (kIsWeb) {
-      var imageBase64 = await imageToBase64(imagePath);
-      final file = convertBase64ToFile(imageBase64);
-      var url = await rpc.storage.webUpload(file!);
+      print(imageBytes);
+      String base64String = base64Encode(imageBytes);
+      final file = convertBase64ToFile(base64String);
+      var result = await rpc.storage.webUpload(file!);
+      if (result != null) {
+        final saved = await Get.find<IDoctorManager>().setSignature(result);
+        if (saved) {
+          _updateSignature(result);
+        } else {
+          PromptBox.toast("设置签名失败");
+        }
+      }
+
       // }
     }
   }

+ 22 - 14
lib/pages/home/personal_center/widgets/signature.dart

@@ -1,3 +1,4 @@
+import 'package:flutter/foundation.dart';
 import 'package:get/get.dart';
 import 'package:flutter/material.dart';
 import 'package:vitalapp/components/button.dart';
@@ -22,22 +23,29 @@ class SignaturePage extends GetView<PersonalCenterController> {
     return Row(
       mainAxisAlignment: MainAxisAlignment.center,
       children: [
-        VButton(
-          label: "签  名",
-          onTap: controller.rewrite,
+        SizedBox(
+          width: 120,
+          child: VButton(
+            label: "签  名",
+            onTap: controller.rewrite,
+          ),
         ),
         SizedBox(width: 20),
-        // SizedBox(
-        //   width: 120,
-        //   child: VButton(
-        //     label: "导  入",
-        //     onTap: controller.chooseImage,
-        //   ),
-        // ),
-        // SizedBox(width: 20),
-        VButton(
-          label: "清  空",
-          onTap: controller.clear,
+        if (kIsWeb)
+          SizedBox(
+            width: 120,
+            child: VButton(
+              label: "导  入",
+              onTap: controller.chooseImage,
+            ),
+          ),
+        if (kIsWeb) SizedBox(width: 20),
+        SizedBox(
+          width: 120,
+          child: VButton(
+            label: "清  空",
+            onTap: controller.clear,
+          ),
         ),
       ],
     );