更新微信登录
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -11,6 +12,7 @@ import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
@@ -122,7 +124,20 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
|
||||
Future<void> _requestBluetoothPermission() async {
|
||||
Map<Permission, PermissionStatus> statuses = {};
|
||||
bool dialogShown = false; // 标记是否弹过权限提示弹窗
|
||||
|
||||
if (Platform.isIOS) {
|
||||
PermissionStatus isBleGranted = await Permission.bluetooth.request();
|
||||
print('checkBlePermissions-ios, isBleGranted=$isBleGranted');
|
||||
if (isBleGranted.isGranted) {
|
||||
// startBluetoothScanning();
|
||||
_startScanning();
|
||||
_startPeriodicScan();
|
||||
} else {
|
||||
// showToast("蓝牙开关或蓝牙权限未开启,请开启蓝牙开关与蓝牙权限".tr, closeTime: 7);
|
||||
TopSlideNotification.show(context,
|
||||
text: "蓝牙开关或蓝牙权限未开启,请开启蓝牙开关与蓝牙权限".tr,
|
||||
textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
} else if (Platform.isAndroid) {
|
||||
try {
|
||||
// 检查是否已授权
|
||||
bool alreadyGranted = await Permission.bluetoothScan.isGranted &&
|
||||
@@ -160,7 +175,6 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
|
||||
Navigator.of(Get.context!, rootNavigator: true).pop();
|
||||
}
|
||||
}
|
||||
|
||||
bool allGranted = statuses[Permission.bluetoothScan]?.isGranted == true &&
|
||||
statuses[Permission.bluetoothConnect]?.isGranted == true &&
|
||||
statuses[Permission.location]?.isGranted == true;
|
||||
@@ -169,28 +183,19 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
|
||||
_startScanning();
|
||||
_startPeriodicScan();
|
||||
} else {
|
||||
_showPermissionDeniedDialog();
|
||||
_showPermissionDeniedDialog(context);
|
||||
}
|
||||
} else {
|
||||
TopSlideNotification.show(context,
|
||||
text: "当前系统不支持蓝牙,无法使用此功能".tr,
|
||||
textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
}
|
||||
|
||||
void _showPermissionDeniedDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("权限提示".tr),
|
||||
content: Text("应用需要蓝牙和位置权限才能扫描设备。请授予权限。".tr),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text("确定".tr),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
void _showPermissionDeniedDialog(BuildContext context) {
|
||||
TopSlideNotification.show(context,
|
||||
text: "应用需要蓝牙和位置权限才能扫描设备。请授予权限。".tr,
|
||||
textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
|
||||
void _startScanning() async {
|
||||
|
||||
@@ -222,7 +222,7 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
|
||||
}
|
||||
|
||||
//微信登录
|
||||
Future<void> wxLoginSendAuth() async {
|
||||
Future<void> wxLoginSendAuth(BuildContext context) async {
|
||||
/*
|
||||
1、目前移动应用上微信登录只提供原生的登录方式,需要用户安装微信客户端才能配合使用。
|
||||
2、对于Android应用,建议总是显示微信登录按钮,当用户手机没有安装微信客户端时,请引导用户下载安装微信客户端。
|
||||
@@ -233,7 +233,9 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
|
||||
bool isWeChatInstalled = await fluwx.isWeChatInstalled;
|
||||
debugPrint('is wechat installed: $isWeChatInstalled');
|
||||
if (!isWeChatInstalled) {
|
||||
showToast("请先安装微信APP,再使用微信登录".tr);
|
||||
TopSlideNotification.show(context,
|
||||
text: "请先安装微信APP,再使用微信登录".tr,
|
||||
textColor: themeController.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -255,6 +257,7 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
|
||||
}
|
||||
|
||||
Future<int> loginByWechatCode(String code) async {
|
||||
try {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.login;
|
||||
@@ -271,6 +274,7 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
|
||||
queryUrl: queryUrl,
|
||||
data: data);
|
||||
if (apiResponse.code == HttpStatusCodes.ok) {
|
||||
ef.log("微信登录授权成功:${apiResponse}");
|
||||
UserInfoController userInfoController = Get.find();
|
||||
userInfoController.model.user = UserModel.fromJson(apiResponse.data);
|
||||
userInfoController.model.login = 1;
|
||||
@@ -291,6 +295,10 @@ class MHTLoginController extends GetControllerEx<LoginModel> {
|
||||
EasyDartModule.logger.error("[微信登录]:失败-》${apiResponse}");
|
||||
}
|
||||
return apiResponse.code!;
|
||||
} catch (e) {
|
||||
ef.log("微信登录:$e");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//注销账号
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
@@ -17,7 +14,6 @@ import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/time/countdown_controller.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/user/controller/mht_register_controller.dart';
|
||||
|
||||
@@ -68,9 +64,9 @@ class MHTLoginPage extends GetView<MHTLoginController> {
|
||||
debugPrint('is wechat installed: $isWeChatInstalled');
|
||||
if (!isWeChatInstalled) {
|
||||
// TODO ios未安装微信 隐藏微信一键登录按钮
|
||||
controller.model.isWeChatNotInstalled = false;
|
||||
} else {
|
||||
controller.model.isWeChatNotInstalled = true;
|
||||
} else {
|
||||
controller.model.isWeChatNotInstalled = false;
|
||||
}
|
||||
controller.updateAll();
|
||||
});
|
||||
@@ -1860,7 +1856,7 @@ class MHTLoginPage extends GetView<MHTLoginController> {
|
||||
final loginController =
|
||||
Get.find<MHTLoginController>();
|
||||
await loginController
|
||||
.wxLoginSendAuth();
|
||||
.wxLoginSendAuth(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 90.rpx,
|
||||
|
||||
Reference in New Issue
Block a user