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

View File

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

View File

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

View File

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

View File

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