diff --git a/android/app/build.gradle b/android/app/build.gradle index 09658ad..31d0601 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -61,7 +61,6 @@ flutter { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation files('libs/AIKit.aar') // rxjava implementation 'io.reactivex.rxjava2:rxjava:2.2.9' diff --git a/android/app/libs/AIKit.aar b/android/app/libs/AIKit.aar deleted file mode 100644 index ca6f61f..0000000 Binary files a/android/app/libs/AIKit.aar and /dev/null differ diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 2d05769..9afaf69 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -22,8 +22,8 @@ android:name="${applicationName}" android:icon="@mipmap/ic_launcher" android:label="智慧食堂" - android:requestLegacyExternalStorage="true" - android:requestRawExternalStorageAccess="true"> + android:largeHeap="true" + android:requestLegacyExternalStorage="true"> + android:theme="@style/Theme.AppCompat.NoActionBar" /> context.startActivity(intent)); result.success(true); } catch (Exception e) { result.success(false); diff --git a/android/app/src/main/java/io/flutter/plugins/facediscern/ui/FaceDiscern.java b/android/app/src/main/java/io/flutter/plugins/facediscern/ui/FaceDiscern.java index 0548c62..414b866 100644 --- a/android/app/src/main/java/io/flutter/plugins/facediscern/ui/FaceDiscern.java +++ b/android/app/src/main/java/io/flutter/plugins/facediscern/ui/FaceDiscern.java @@ -4,7 +4,10 @@ import android.Manifest; import android.content.Intent; import android.graphics.Point; import android.hardware.Camera; +import android.os.AsyncTask; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; @@ -15,10 +18,12 @@ import androidx.core.app.ActivityCompat; import androidx.databinding.DataBindingUtil; import androidx.lifecycle.ViewModelProvider; +import com.example.pj_supermarket_cloud.MainActivity; import com.example.pj_supermarket_cloud.R; import com.example.pj_supermarket_cloud.databinding.ActivityFaceDiscernBinding; import io.flutter.Log; +import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.facediscern.flutter.FlutterFaceDiscernPlugin; import io.flutter.plugins.facediscern.tool.camera.DualCameraHelper; import io.flutter.plugins.facediscern.tool.camera.callback.CameraListener; @@ -40,10 +45,7 @@ public class FaceDiscern extends BaseActivity implements ViewTreeObserver.OnGlob private static final String TAG = "人脸识别页面"; - private static final String[] NEEDED_PERMISSIONS = new String[]{ - Manifest.permission.CAMERA, - Manifest.permission.READ_PHONE_STATE - }; + private static final String[] NEEDED_PERMISSIONS = new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_PHONE_STATE}; private FaceRectTransformer rgbFaceRectTransformer; @@ -131,13 +133,10 @@ public class FaceDiscern extends BaseActivity implements ViewTreeObserver.OnGlob if (Objects.nonNull(channel)) { channel.invokeMethod("faceDiscernPageInit", null); } - if (rgbCameraHelper != null) { - rgbCameraHelper.resumePreview(); - } scheduler.schedule(() -> { try { - if (viewModel != null) { - viewModel.stop(); + if (rgbCameraHelper != null) { + rgbCameraHelper.resumePreview(); previewLock = false; Log.i(TAG, "相机开始识别"); } @@ -156,17 +155,26 @@ public class FaceDiscern extends BaseActivity implements ViewTreeObserver.OnGlob } } + // 以前的方式 + // intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + // 推荐的方式 + // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + // 手机返回按钮 @Override public void onBackPressed() { - Log.e(TAG, "相机onBackPressed"); + + MethodChannel channel = FlutterFaceDiscernPlugin.staticChannel; + if (Objects.nonNull(channel)) { + channel.invokeMethod("faceDiscernBack", null); + } + Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.setClassName(this.getPackageName(), this.getPackageName() + ".MainActivity"); this.startActivity(intent); - MethodChannel channel = FlutterFaceDiscernPlugin.staticChannel; - if (Objects.isNull(channel)) return; - channel.invokeMethod("faceDiscernBack", null); + } @@ -187,25 +195,8 @@ public class FaceDiscern extends BaseActivity implements ViewTreeObserver.OnGlob public void onCameraOpened(Camera camera, int cameraId, int displayOrientation, boolean isMirror) { runOnUiThread(() -> { Camera.Size previewSizeRgb = camera.getParameters().getPreviewSize(); - ViewGroup.LayoutParams layoutParams = adjustPreviewViewSize( - binding.dualCameraTexturePreviewRgb, - binding.dualCameraTexturePreviewRgb, - binding.dualCameraFaceRectView, - previewSizeRgb, - displayOrientation, - 1.0f - ); - rgbFaceRectTransformer = new FaceRectTransformer( - previewSizeRgb.width, - previewSizeRgb.height, - layoutParams.width, - layoutParams.height, - displayOrientation, - cameraId, - isMirror, - true, - true - ); + ViewGroup.LayoutParams layoutParams = adjustPreviewViewSize(binding.dualCameraTexturePreviewRgb, binding.dualCameraTexturePreviewRgb, binding.dualCameraFaceRectView, previewSizeRgb, displayOrientation, 1.0f); + rgbFaceRectTransformer = new FaceRectTransformer(previewSizeRgb.width, previewSizeRgb.height, layoutParams.width, layoutParams.height, displayOrientation, cameraId, isMirror, true, true); viewModel.onRgbCameraOpened(camera); viewModel.setRgbFaceRectTransformer(rgbFaceRectTransformer); Log.e(TAG, "相机打开,宽:" + previewSizeRgb.width + ",高:" + previewSizeRgb.height + ";layout宽:" + layoutParams.width + ",layout高:" + layoutParams.height + ";"); @@ -249,16 +240,7 @@ public class FaceDiscern extends BaseActivity implements ViewTreeObserver.OnGlob } } Point previewSize = new Point(binding.dualCameraTexturePreviewRgb.getMeasuredWidth(), binding.dualCameraTexturePreviewRgb.getMeasuredHeight()); - rgbCameraHelper = new DualCameraHelper.Builder() - .previewViewSize(previewSize) - .previewSize(previewSize) - .rotation(getWindowManager().getDefaultDisplay().getRotation()) - .additionalRotation(0) - .specificCameraId(mCameraId) - .isMirror(false) - .previewOn(binding.dualCameraTexturePreviewRgb) - .cameraListener(cameraListener) - .build(); + rgbCameraHelper = new DualCameraHelper.Builder().previewViewSize(previewSize).previewSize(previewSize).rotation(getWindowManager().getDefaultDisplay().getRotation()).additionalRotation(0).specificCameraId(mCameraId).isMirror(false).previewOn(binding.dualCameraTexturePreviewRgb).cameraListener(cameraListener).build(); rgbCameraHelper.init(); rgbCameraHelper.start(); viewModel.setRgbCameraHelper(rgbCameraHelper); diff --git a/android/app/src/main/java/io/flutter/plugins/facediscern/ui/viewmodel/FaceDiscernViewModel.java b/android/app/src/main/java/io/flutter/plugins/facediscern/ui/viewmodel/FaceDiscernViewModel.java index dbe491c..c256799 100644 --- a/android/app/src/main/java/io/flutter/plugins/facediscern/ui/viewmodel/FaceDiscernViewModel.java +++ b/android/app/src/main/java/io/flutter/plugins/facediscern/ui/viewmodel/FaceDiscernViewModel.java @@ -20,8 +20,10 @@ import com.arcsoft.face.LivenessInfo; import com.arcsoft.face.LivenessParam; import com.arcsoft.face.enums.DetectFaceOrientPriority; import com.arcsoft.face.enums.DetectMode; +import com.example.pj_supermarket_cloud.MainActivity; import com.google.gson.Gson; +import io.flutter.embedding.android.FlutterActivity; import io.flutter.plugins.facediscern.tool.camera.DualCameraHelper; import io.flutter.plugins.facediscern.tool.camera.config.PreviewConfig; import io.flutter.plugins.facediscern.tool.face.constants.FaceBrodConstant; @@ -36,6 +38,7 @@ import io.flutter.plugins.facediscern.tool.face.model.FaceEntity; import io.flutter.plugins.facediscern.tool.face.model.FacePreviewInfo; import io.flutter.plugins.facediscern.tool.face.model.RecognizeConfiguration; import io.flutter.plugins.facediscern.tool.face.widget.FaceRectView; +import io.flutter.plugins.facediscern.ui.FaceDiscern; import java.util.ArrayList; import java.util.HashMap; @@ -290,17 +293,15 @@ public class FaceDiscernViewModel extends ViewModel implements RecognizeCallback if (flutterFaceCallbackIntent == null) { flutterFaceCallbackIntent = new Intent(FaceBrodConstant.FACE_GLOBAL_INTENT); } - Log.i(TAG, "人脸识别成功json:" + new Gson().toJson(faceDiscern)); flutterFaceCallbackIntent.putExtra("json", new Gson().toJson(faceDiscern)); - context.sendBroadcast(flutterFaceCallbackIntent); - faceDiscern = null; + Log.i(TAG, "人脸识别成功json:" + new Gson().toJson(faceDiscern)); if (context instanceof Activity) { Thread.sleep(500); - String packageName = context.getPackageName(); - Intent intent = new Intent(); - intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - intent.setClassName(packageName, packageName + ".MainActivity"); + Intent intent = new Intent(context, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); context.startActivity(intent); + context.sendBroadcast(flutterFaceCallbackIntent); + faceDiscern = null; } } catch (Exception e) { Log.e(TAG, "提示文字变更的回调,错误error:" + e.getMessage(), e); diff --git a/android/app/src/main/kotlin/com/example/pj_supermarket_cloud/MainActivity.kt b/android/app/src/main/kotlin/com/example/pj_supermarket_cloud/MainActivity.kt index 6c2d09d..b4a924c 100644 --- a/android/app/src/main/kotlin/com/example/pj_supermarket_cloud/MainActivity.kt +++ b/android/app/src/main/kotlin/com/example/pj_supermarket_cloud/MainActivity.kt @@ -2,13 +2,19 @@ package com.example.pj_supermarket_cloud import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugins.GeneratedPluginRegistrant import io.flutter.plugins.facediscern.flutter.FlutterFaceDiscernPlugin class MainActivity : FlutterActivity() { + override fun configureFlutterEngine(flutterEngine: FlutterEngine) { super.configureFlutterEngine(flutterEngine) + // 人脸识别插件 val flutterFaceDiscernPlugin = FlutterFaceDiscernPlugin() flutterEngine.plugins.add(flutterFaceDiscernPlugin) + + GeneratedPluginRegistrant.registerWith(flutterEngine) } + } diff --git a/lib/app.dart b/lib/app.dart index 5526d49..f7e8ee2 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -50,14 +50,9 @@ class MainApp extends StatelessWidget { localizationsDelegates: FLocalizations.localizationsDelegates, supportedLocales: FLocalizations.supportedLocales, builder: EasyLoading.init( - builder: (context, child) => FTheme( + builder: (_, childSecond) => FTheme( data: themeData, - child: MediaQuery( - data: MediaQuery.of(context).copyWith( - viewInsets: MediaQuery.of(context).viewInsets, - ), - child: child!, - ), + child: childSecond!, ), ), ); diff --git a/lib/common/routers/pages.dart b/lib/common/routers/pages.dart index 195699a..f292013 100644 --- a/lib/common/routers/pages.dart +++ b/lib/common/routers/pages.dart @@ -35,8 +35,8 @@ class RoutePages { page: () => const CanteenProductPage(), binding: BindingsBuilder(() { Get.lazyPut(() => SelectPayTypeDialogController()); - Get.lazyPut(() => PanelController()); Get.lazyPut(() => CanteenProductController()); + Get.lazyPut(() => PanelController()); }), ), GetPage( diff --git a/lib/common/utils/app/app_face_tool.dart b/lib/common/utils/app/app_face_tool.dart index 6301843..80960f4 100644 --- a/lib/common/utils/app/app_face_tool.dart +++ b/lib/common/utils/app/app_face_tool.dart @@ -11,8 +11,6 @@ abstract class AppFaceTool { // 跳转到人脸识别页面 static Future jumpFacePage() async { - final faceCount = await FaceDiscernPlugs.getFaceCount(); - if (faceCount == 0) return false; final isJump = await FaceDiscernPlugs.jumpFaceDiscernPage(); if (!isJump) return false; Future.delayed(const Duration(seconds: 2), () { @@ -40,8 +38,6 @@ abstract class AppFaceTool { String? userId, bool forceRegister = false, }) async { - final isActive = await AppFaceTool.isActiveSdk(); - if (!isActive) return false; var faceCount = await FaceDiscernPlugs.getFaceCount(); if (faceCount == 0 || forceRegister) { final list = await FaceDiscernPlugs.registerFaceByDatabase( diff --git a/lib/common/utils/app/app_file_tool.dart b/lib/common/utils/app/app_file_tool.dart index c6dd9a5..d2280b0 100644 --- a/lib/common/utils/app/app_file_tool.dart +++ b/lib/common/utils/app/app_file_tool.dart @@ -8,7 +8,7 @@ import 'package:sqflite/sqflite.dart'; abstract class AppFileTool { static const _tag = "app文件工具"; - static const _baseDir = "pj"; + static const _baseDir = "pj_cashier"; static const _baseBackupDir = "backup"; static const _backupDatabaseDir = "database"; static const _backupLoggerDir = "logger"; @@ -47,13 +47,6 @@ abstract class AppFileTool { return dir; } - /// 保存数据库文件地址 - static Future setDatabasePath(String sqlAddress) async { - final appSetting = await AppSettingTool.getSysSetting(); - appSetting.sqlAddress = sqlAddress; - await AppSettingTool.setSysSetting(appSetting); - } - /// 创建数据库文件备份地址 static Future getDatabaseBackupPath() async { String backupDir = await getExternalPath(backupExternalPath: false); diff --git a/lib/common/utils/app/control/app_control.dart b/lib/common/utils/app/control/app_control.dart index f8e3ba2..f87b848 100644 --- a/lib/common/utils/app/control/app_control.dart +++ b/lib/common/utils/app/control/app_control.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:get/get.dart'; -import 'package:sqflite/sqflite.dart'; import 'package:pj_supermarket_cloud/common/index.dart'; @@ -35,7 +34,7 @@ class AppControl extends GetxController { serialCardManage.close(); srialSteelyardManage.close(); AppNetworkTool.closeListenNetwork(); - TtsManage.dispose(); + // TtsManage.dispose(); } Future initAsync() async { @@ -44,11 +43,8 @@ class AppControl extends GetxController { serialCardManage = SerialCardManage(); srialSteelyardManage = SerialSteelyardManage(); AppNetworkTool.listenNetwork(); - await AppFileTool.setDatabasePath( - await getDatabasesPath(), - ); - await AppFileTool.backupSqlFile(); - await TtsManage.initialize(); + // await AppFileTool.backupSqlFile(); + // await TtsManage.initialize(); Get.offAllNamed(RouteNames.login); } } diff --git a/lib/common/values/index.dart b/lib/common/values/index.dart index e2fc4fc..817d5ce 100644 --- a/lib/common/values/index.dart +++ b/lib/common/values/index.dart @@ -3,4 +3,5 @@ library; export './constants.dart'; export './crt.dart'; export './images.dart'; +export 'keys.dart'; export './svgs.dart'; diff --git a/lib/common/widgets/app/app_img.dart b/lib/common/widgets/app/app_img.dart index f30b80d..dffb946 100644 --- a/lib/common/widgets/app/app_img.dart +++ b/lib/common/widgets/app/app_img.dart @@ -1,6 +1,5 @@ import 'dart:io'; -import 'package:cached_network_image/cached_network_image.dart'; import 'package:common_utils/common_utils.dart'; import 'package:ducafe_ui_core/ducafe_ui_core.dart'; import 'package:flutter/material.dart'; @@ -16,11 +15,31 @@ Widget appNetworkImg( double imgHeight = 60, BoxFit fit = BoxFit.cover, }) { - return CachedNetworkImage( - imageUrl: AppNetworkTool.ossImage(src), - placeholder: (context, url) => - CircularProgressIndicator().width(50.w).height(50.w), - errorWidget: (context, url, error) { + return Image.network( + src, + width: imgWidth, + height: imgHeight, + fit: fit, + loadingBuilder: + (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) { + return child; + } else { + return Center( + child: SizedBox( + width: imgHeight, + height: imgHeight, + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / + (loadingProgress.expectedTotalBytes ?? 1) + : null, + ), + ), + ); + } + }, + errorBuilder: (BuildContext context, Object error, StackTrace? stackTrace) { final theme = FTheme.of(context); return FIcon( FAssets.icons.globeLock, @@ -29,6 +48,19 @@ Widget appNetworkImg( ).width(imgWidth * 0.5).height(imgHeight * 0.5); }, ); + // return CachedNetworkImage( + // imageUrl: AppNetworkTool.ossImage(src), + // placeholder: (context, url) => + // CircularProgressIndicator().width(50.w).height(50.w), + // errorWidget: (context, url, error) { + // final theme = FTheme.of(context); + // return FIcon( + // FAssets.icons.globeLock, + // color: theme.colorScheme.error, + // size: theme.typography.base.fontSize, + // ).width(imgWidth * 0.5).height(imgHeight * 0.5); + // }, + // ); } Widget appFileImg( diff --git a/lib/common/widgets/order/order_common.dart b/lib/common/widgets/order/order_common.dart index e82b755..d8633d1 100644 --- a/lib/common/widgets/order/order_common.dart +++ b/lib/common/widgets/order/order_common.dart @@ -103,15 +103,15 @@ Widget orderSelectPanel( appPrice(context, price), SizedBox(width: 10.w), FIcon( - FAssets.icons.minus, + FAssets.icons.plus, color: theme.colorScheme.secondary, ) .width(height.w) .height(double.infinity) .decorated(color: theme.colorScheme.primary) .onTap(() { - if (total > 0) { - onChange(total - 1, index); + if (total < 100) { + onChange(total + 1, index); } }), Text( @@ -122,15 +122,15 @@ Widget orderSelectPanel( borderRadius: theme.style.borderRadius / 2, ), FIcon( - FAssets.icons.plus, + FAssets.icons.minus, color: theme.colorScheme.secondary, ) .width(height.w) .height(double.infinity) .decorated(color: theme.colorScheme.error) .onTap(() { - if (total < 100) { - onChange(total + 1, index); + if (total > 0) { + onChange(total - 1, index); } }), ].toRow(mainAxisAlignment: MainAxisAlignment.end).expanded(), diff --git a/lib/common/widgets/order/select_pay_type_dialog.dart b/lib/common/widgets/order/select_pay_type_dialog.dart index a8fc444..27dd118 100644 --- a/lib/common/widgets/order/select_pay_type_dialog.dart +++ b/lib/common/widgets/order/select_pay_type_dialog.dart @@ -38,6 +38,8 @@ class SelectPayTypeDialogController extends GetxController { final app = Get.find(); + late SysSetting appSetting; + final payTypeRadioC = FRadioSelectGroupController(); Rxn payUser = Rxn(null); @@ -64,6 +66,8 @@ class SelectPayTypeDialogController extends GetxController { @override void onInit() async { super.onInit(); + appSetting = await AppSettingTool.getSysSetting(); + _listenAndroidFaceBack(); // 监听支付方式变化 payTypeRadioC.addValueListener((v) { final payType = OrderPayDisplayType.values.fromCode( @@ -83,15 +87,8 @@ class SelectPayTypeDialogController extends GetxController { payTypeRadioC.dispose(); } - _closeStatus() { - payUser.value = null; - isRecognition.value = false; - globalQrCode = null; - _faceCallbackLock = false; - } - - Future initPayType() async { - final appSetting = await AppSettingTool.getSysSetting(); + void initPayType() { + _closeStatus(); if (appSetting.defaultPayDisplayType != null) { payTypeRadioC.value = {appSetting.defaultPayDisplayType!}; } @@ -100,13 +97,20 @@ class SelectPayTypeDialogController extends GetxController { } } - _closeFacility() { + _closeStatus() { + payUser.value = null; + isRecognition.value = false; + globalQrCode = null; + _faceCallbackLock = false; + // 设备 BarcodeScanManage.instance.dispose(); app.serialCardManage.close(); - } - _closeFaceDiscern() { + // 取消人脸监听 faceDiscernListen?.cancel(); + + // 关闭加载提示 + EasyLoading.dismiss(); } // |开始识别|点击 @@ -138,10 +142,8 @@ class SelectPayTypeDialogController extends GetxController { orderPayDisplayType.value!, globalQrCode, ); - Navigator.of(Get.context!).pop(); _closeStatus(); - _closeFacility(); - _closeFaceDiscern(); + Navigator.of(Get.context!, rootNavigator: true).pop(); } // |取消|点击 @@ -149,17 +151,12 @@ class SelectPayTypeDialogController extends GetxController { if (isRecognition.value) { final flag = await appMessageDialog(Get.context!, "是否取消识别"); if (!flag) return; - _closeStatus(); - _closeFacility(); - _closeFaceDiscern(); - Navigator.of(Get.context!).pop(); + Navigator.of(Get.context!, rootNavigator: true).pop(); return; } _closeStatus(); - _closeFacility(); - _closeFaceDiscern(); onCancel?.call(); - Navigator.of(Get.context!).pop(); + Navigator.of(Get.context!, rootNavigator: true).pop(); } // ************************************************************************** @@ -332,7 +329,6 @@ class SelectPayTypeDialogController extends GetxController { Toast.error(msg: "跳转到人脸检测页面失败"); throw Error(); } - _listenAndroidFaceBack(); faceDiscernListen = FaceDiscernPlugs.faceStream.listen((event) { if (event == null) return; if (_faceCallbackLock) return; @@ -353,7 +349,6 @@ class SelectPayTypeDialogController extends GetxController { // android人脸识别成功回调 Future _faceDiscernAfter(FaceStream event) async { try { - EasyLoading.dismiss(); EasyLoading.show( status: '获取用户信息中...', maskType: EasyLoadingMaskType.black, @@ -422,99 +417,104 @@ class SelectPayTypeDialogController extends GetxController { } } -Future selectPayTypeDialog(BuildContext context) async { +Future selectPayTypeDialog() async { + final context = Get.context!; final payTypeC = Get.find(); - await payTypeC.initPayType(); + payTypeC.initPayType(); final theme = FTheme.of(context); final width = context.width; final height = context.height; - showDialog( - context: context, + return showDialog( + context: Get.context!, barrierDismissible: false, - builder: (BuildContext context) => FDialog( - direction: Axis.vertical, - title: Text("选择支付方式", style: theme.typography.lg), - body: [ - Obx( - () => FSelectGroup( - enabled: payTypeC.payUser.value == null, - controller: payTypeC.payTypeRadioC, - style: theme.selectGroupStyle.copyWith( - labelLayoutStyle: - theme.selectGroupStyle.labelLayoutStyle.copyWith( - childPadding: EdgeInsets.symmetric( - vertical: 10.h, - ), - ), - radioStyle: theme.selectGroupStyle.radioStyle.copyWith( - padding: EdgeInsets.symmetric( - vertical: 10.h, - ), - ), - ), - items: payTypeC.usePayDisplayTypeList - .map>( - (v) => FSelectGroupItem.radio( - value: v, - label: Text( - v.title, - style: theme.typography.xl, + builder: (BuildContext _) { + return PopScope( + child: FDialog( + direction: Axis.vertical, + title: Text("选择支付方式", style: theme.typography.lg), + body: [ + Obx( + () => FSelectGroup( + enabled: payTypeC.payUser.value == null, + controller: payTypeC.payTypeRadioC, + style: theme.selectGroupStyle.copyWith( + labelLayoutStyle: + theme.selectGroupStyle.labelLayoutStyle.copyWith( + childPadding: EdgeInsets.symmetric( + vertical: 10.h, ), ), - ) - .toList(), - ), - ), - SizedBox(height: 20.h), - Obx( - () => Visibility( - visible: payTypeC.payUser.value == null, - replacement: selectPayTypeUser( - context, - payTypeC.payUser.value, + radioStyle: theme.selectGroupStyle.radioStyle.copyWith( + padding: EdgeInsets.symmetric( + vertical: 10.h, + ), + ), + ), + items: payTypeC.usePayDisplayTypeList + .map>( + (v) => FSelectGroupItem.radio( + value: v, + label: Text( + v.title, + style: theme.typography.xl, + ), + ), + ) + .toList(), + ), ), - child: selectPayTypeHint( - context, - payTypeC.orderPayDisplayType.value, - ), - ), - ).center().expanded(), - ].toColumn().width(width * 0.5).height(height * 0.6), - actions: [ - [ - Obx( - () => FButton( - label: Text( - payTypeC.payUser.value == null ? "开始识别" : "确定支付", - style: theme.typography.xl.copyWith( - color: theme.colorScheme.secondary, + SizedBox(height: 20.h), + Obx( + () => Visibility( + visible: payTypeC.payUser.value == null, + replacement: selectPayTypeUser( + context, + payTypeC.payUser.value, + ), + child: selectPayTypeHint( + context, + payTypeC.orderPayDisplayType.value, ), ), - onPress: () { - if (payTypeC.payUser.value == null) { - payTypeC.doRecognition(); - } else { - payTypeC.doSubmit(); - } - }, - ), - ).flexible(flex: 1), - SizedBox(width: 20.w), - FButton( - style: FButtonStyle.destructive, - label: Text( - "取消", - style: theme.typography.xl.copyWith( - color: theme.colorScheme.secondary, - ), - ), - onPress: () { - payTypeC.doCancel(); - }, - ).flexible(flex: 1), - ].toRow(), - ], - ), + ).center().expanded(), + ].toColumn().width(width * 0.5).height(height * 0.6), + actions: [ + [ + Obx( + () => FButton( + label: Text( + payTypeC.payUser.value == null ? "开始识别" : "确定支付", + style: theme.typography.xl.copyWith( + color: theme.colorScheme.secondary, + ), + ), + onPress: () { + if (payTypeC.payUser.value == null) { + payTypeC.doRecognition(); + } else { + payTypeC.doSubmit(); + } + }, + ), + ).flexible(flex: 1), + SizedBox(width: 20.w), + FButton( + style: FButtonStyle.destructive, + label: Text( + "取消", + style: theme.typography.xl.copyWith( + color: theme.colorScheme.secondary, + ), + ), + onPress: () { + payTypeC.doCancel(); + }, + ).flexible(flex: 1), + ].toRow(), + ], + ), + ); + }, ); } diff --git a/lib/pages/canteen_product/controller.dart b/lib/pages/canteen_product/controller.dart index 98bb026..e603e35 100644 --- a/lib/pages/canteen_product/controller.dart +++ b/lib/pages/canteen_product/controller.dart @@ -103,23 +103,13 @@ class CanteenProductController extends GetxController with OrderMixin { hourTypeC.dispose(); } - // |下单|点击识别按钮 - doRecognition() { - final payTypeC = Get.find(); - payTypeC.payUser.value = payUser.value; - payTypeC.orderPayDisplayType.value = orderPayDisplayType.value; - } - // |下单|点击购买 - doPay() async { + Future doPay() async { final validShopCar = _validateShopCar(); if (!validShopCar) return; // 创建本地订单 await createSqlOrder(); - final payTypeC = Get.find(); - payTypeC.payUser.value = payUser.value; - payTypeC.orderPayDisplayType.value = orderPayDisplayType.value; - selectPayTypeDialog(Get.context!); + await selectPayTypeDialog(); } // |下单|点击取消下单 diff --git a/lib/pages/canteen_product/view.dart b/lib/pages/canteen_product/view.dart index bf4a0de..2a62a1b 100644 --- a/lib/pages/canteen_product/view.dart +++ b/lib/pages/canteen_product/view.dart @@ -219,6 +219,16 @@ class CanteenProductPage extends GetView { [ SizedBox(height: 20.h), [ + FButton( + label: Text( + "支付", + style: theme.typography.xl.copyWith( + color: theme.colorScheme.secondary, + ), + ), + onPress: () => controller.doPay(), + ).flexible(flex: 1), + SizedBox(width: 20.w), FButton( style: FButtonStyle.destructive, label: Text( @@ -229,18 +239,6 @@ class CanteenProductPage extends GetView { ), onPress: () => controller.doCancelPay(), ).flexible(flex: 1), - SizedBox(width: 20.w), - FButton( - label: Text( - "支付", - style: theme.typography.xl.copyWith( - color: theme.colorScheme.secondary, - ), - ), - onPress: () => controller.payUser.value?.userId == null - ? controller.doPay() - : controller.doRecognition(), - ).flexible(flex: 1), ].toRow(mainAxisAlignment: MainAxisAlignment.spaceBetween), ].toColumn(), ].toColumn().padding(vertical: 10.h, horizontal: 10.w); diff --git a/lib/pages/panel/controller.dart b/lib/pages/panel/controller.dart index 4d7a3eb..16f915b 100644 --- a/lib/pages/panel/controller.dart +++ b/lib/pages/panel/controller.dart @@ -75,7 +75,7 @@ class PanelController extends GetxController { Get.offAndToNamed(RouteNames.login); break; case PanelType.test: - await TtsManage.speak("购买成功,总金额100元"); + await AppFaceTool.jumpFacePage(); break; default: break; diff --git a/lib/pages/setting/widgets/setting_baseInfo.dart b/lib/pages/setting/widgets/setting_baseInfo.dart index 760bc5c..a11a579 100644 --- a/lib/pages/setting/widgets/setting_baseInfo.dart +++ b/lib/pages/setting/widgets/setting_baseInfo.dart @@ -16,9 +16,9 @@ Future _bindServiceDialog(BuildContext context, SysSetting sys) async { uniqueCodeC.text = sys.serviceId ?? ""; } else if (AppSysTool.isDev()) { // 超市 - // uniqueCodeC.text = "1894303392833716226"; + uniqueCodeC.text = "1894303392833716226"; // 测试 - uniqueCodeC.text = "1896157295523049473"; + // uniqueCodeC.text = "1896157295523049473"; } await showAdaptiveDialog( context: context, diff --git a/pubspec.lock b/pubspec.lock index 7b423dc..19c75a9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -142,30 +142,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "8.9.4" - cached_network_image: - dependency: "direct main" - description: - name: cached_network_image - sha256: "28ea9690a8207179c319965c13cd8df184d5ee721ae2ce60f398ced1219cea1f" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.3.1" - cached_network_image_platform_interface: - dependency: transitive - description: - name: cached_network_image_platform_interface - sha256: ff0c949e323d2a1b52be73acce5b4a7b04063e61414c8ca542dbba47281630a7 - url: "https://pub.flutter-io.cn" - source: hosted - version: "4.1.0" - cached_network_image_web: - dependency: transitive - description: - name: cached_network_image_web - sha256: "6322dde7a5ad92202e64df659241104a43db20ed594c41ca18de1014598d7996" - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.3.0" characters: dependency: transitive description: @@ -435,14 +411,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_cache_manager: - dependency: transitive - description: - name: flutter_cache_manager - sha256: a77f77806a790eb9ba0118a5a3a936e81c4fea2b61533033b2b0c3d50bbde5ea - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.4.0" flutter_easyloading: dependency: "direct main" description: @@ -834,14 +802,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.6" - octo_image: - dependency: transitive - description: - name: octo_image - sha256: "34faa6639a78c7e3cbe79be6f9f96535867e879748ade7d17c9b1ae7536293bd" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.0" package_config: dependency: transitive description: @@ -1058,14 +1018,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.2.3" - rxdart: - dependency: transitive - description: - name: rxdart - sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.28.0" shelf: dependency: transitive description: @@ -1119,14 +1071,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.10.0" - sprintf: - dependency: transitive - description: - name: sprintf - sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" - url: "https://pub.flutter-io.cn" - source: hosted - version: "7.0.0" sqflite: dependency: "direct main" description: @@ -1295,14 +1239,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.2.2" - uuid: - dependency: transitive - description: - name: uuid - sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff - url: "https://pub.flutter-io.cn" - source: hosted - version: "4.5.1" vector_graphics: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a7a55b1..99e48aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: # 图片处理 image: ^4.3.0 # 图片缓存 - cached_network_image: 3.3.1 + # cached_network_image: 3.3.1 # 表格 data_table_2: ^2.5.18 # 分页