xhj环境新增设置—微信公众号推送功能

This commit is contained in:
Daisy 2024-06-14 09:15:07 +08:00
parent 282bae9f7c
commit 9d6259cf4c
5 changed files with 39 additions and 28 deletions

View File

@ -5,6 +5,7 @@ import 'package:star_lock/appRouters.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart';
import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart';
import 'package:star_lock/mine/mineSet/mineSet/weChatQRCodeEntity.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart';
import 'package:star_lock/tools/storage.dart';
@ -20,7 +21,8 @@ class MineSetLogic extends BaseGetXController {
final MineSetState state = MineSetState();
//
Future<void> userSettingsInfoRequest() async {
var entity = await ApiRepository.to.userSettingsInfo();
final UserSettingInfoEntity entity =
await ApiRepository.to.userSettingsInfo();
if (entity.errorCode!.codeIsSuccessful) {
state.userInfoData.value = entity.data!;
state.userSetting.value = entity.data!.userSettings!;
@ -51,21 +53,22 @@ class MineSetLogic extends BaseGetXController {
//
Future<void> updatePrompToneRequest() async {
ExpireLockListEntity entity = await ApiRepository.to
final ExpireLockListEntity entity = await ApiRepository.to
.setAlertMode('1', state.isPrompTone.value == true ? '1' : '2');
if (entity.errorCode!.codeIsSuccessful) {
showToast("设置成功".tr);
showToast('设置成功'.tr);
userSettingsInfoRequest();
}
}
//
Future<void> setMpWechatPushSwitchRequest(BuildContext widgetContext) async {
VersionUndateEntity entity = await ApiRepository.to.setMpWechatPushSwitch(
mpWechatPushSwitch:
state.isWechatPublicAccountPush.value == true ? 1 : 2);
final VersionUndateEntity entity = await ApiRepository.to
.setMpWechatPushSwitch(
mpWechatPushSwitch:
state.isWechatPublicAccountPush.value == true ? 1 : 2);
if (entity.errorCode!.codeIsSuccessful) {
showToast("设置成功".tr);
showToast('设置成功'.tr);
userSettingsInfoRequest();
} else if (entity.errorCode! == 421) {
if (state.isWechatPublicAccountPush.value == true) {
@ -77,15 +80,18 @@ class MineSetLogic extends BaseGetXController {
//
Future<void> getMpWechatQrCodeRequest(BuildContext widgetContext) async {
GetWechatQrCodeEntity entity = await ApiRepository.to.getMpWechatQrCode();
final GetWechatQrCodeEntity entity =
await ApiRepository.to.getMpWechatQrCode();
if (entity.errorCode!.codeIsSuccessful) {
state.qrCodeUrl.value = entity.data!.qrCodeUrl!;
state.qrCodeText.value = entity.data!.mpName ?? '';
showQRImageAlert(state.qrCodeUrl.value, widgetContext);
}
}
void showQRImageAlert(String qrCodeUrl, BuildContext widgetContext) {
ShowCupertinoAlertView().showQRImageAlert(widgetContext, qrCodeUrl);
ShowCupertinoAlertView()
.showQRImageAlert(widgetContext, qrCodeUrl, state.qrCodeText.value);
}
//退
@ -117,7 +123,7 @@ class MineSetLogic extends BaseGetXController {
ExpireLockListEntity entity = await ApiRepository.to
.setTouchUnlockFlag(state.isTouchUnlock.value == true ? '1' : '2');
if (entity.errorCode!.codeIsSuccessful) {
showToast("设置成功".tr);
showToast('设置成功'.tr);
userSettingsInfoRequest();
}
}

View File

@ -191,18 +191,18 @@ class _MineSetPageState extends State<MineSetPage>
width: 60.w,
height: 50.h,
child: Obx(_isPushNotificationSwitch))),
if (F.appFlavor == Flavor.sky)
CommonItem(
leftTitel: '微信公众号推送'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(_isWechatPublicAccountPushSwitch)))
else
Container(),
// if (F.appFlavor == Flavor.sky)
CommonItem(
leftTitel: '微信公众号推送'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(_isWechatPublicAccountPushSwitch))),
// else
// Container(),
SizedBox(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockUserManagement!.tr,

View File

@ -11,6 +11,7 @@ class MineSetState {
var isPushNotification = false.obs; //
var isWechatPublicAccountPush = false.obs; //
var qrCodeUrl = ''.obs; //
var qrCodeText = ''.obs; //
var lockScreen = 2.obs; //
var hideExpiredAccessFlag = 2.obs; //

View File

@ -28,16 +28,19 @@ class GetWechatQrCodeEntity {
class Data {
String? qrCodeUrl;
String? mpName;
Data({this.qrCodeUrl});
Data({this.qrCodeUrl, this.mpName});
Data.fromJson(Map<String, dynamic> json) {
qrCodeUrl = json['qrCodeUrl'];
mpName = json['mpName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['qrCodeUrl'] = qrCodeUrl;
data['mpName'] = mpName;
return data;
}
}

View File

@ -13,19 +13,20 @@ class ShowCupertinoAlertView {
bool isSystemEmailSelected = true; //
//
void showQRImageAlert(BuildContext widgetContext, String qrCodeUrl) {
void showQRImageAlert(
BuildContext widgetContext, String qrCodeUrl, String qrCodeText) {
showCupertinoModalPopup(
context: widgetContext,
builder: (context) {
builder: (BuildContext context) {
return CupertinoActionSheet(
actions: [
actions: <Widget>[
Container(
color: Colors.white, //
child: CupertinoActionSheetAction(
child: Container(
margin: const EdgeInsets.all(0),
child: Column(
children: [
children: <Widget>[
SizedBox(
height: 60.h,
),
@ -40,7 +41,7 @@ class ShowCupertinoAlertView {
Padding(
padding: EdgeInsets.only(left: 60.w, right: 60.w),
child: Text(
'开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置'.tr,
'开启微信接收报警消息需要先关注$qrCodeText微信公众号,请保存二维码并使用微信扫一扫设置',
style:
TextStyle(fontSize: 24.sp, color: Colors.black),
)),