|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:recook/base/base_store_state.dart';
|
|
|
|
|
import 'package:recook/manager/user_manager.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:velocity_x/velocity_x.dart';
|
|
|
|
|
|
|
|
|
@ -17,16 +19,31 @@ class AccountAndSafetyPage extends StatefulWidget {
|
|
|
|
|
_AccountAndSafetyPageState createState() => _AccountAndSafetyPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _AccountAndSafetyPageState extends State<AccountAndSafetyPage> {
|
|
|
|
|
class _AccountAndSafetyPageState extends BaseStoreState<AccountAndSafetyPage> {
|
|
|
|
|
bool secureValue = false;
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
//TODO 初始化手机号显示开关数值
|
|
|
|
|
secureValue = UserManager.instance.userBrief.secretValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future updateProfile() async {
|
|
|
|
|
await UserManager.instance.updateUserBriefInfo(getStore()).then((success) {
|
|
|
|
|
if (success) {
|
|
|
|
|
if (UserManager.instance.user.info.roleLevel !=
|
|
|
|
|
getStore().state.userBrief.roleLevel) {
|
|
|
|
|
UserManager.instance.user.info.roleLevel =
|
|
|
|
|
getStore().state.userBrief.roleLevel;
|
|
|
|
|
UserManager.instance.refreshUserRole.value =
|
|
|
|
|
!UserManager.instance.refreshUserRole.value;
|
|
|
|
|
UserManager.updateUserInfo(getStore());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
Widget buildContext(BuildContext context, {store}) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: AppColor.frenchColor,
|
|
|
|
|
appBar: CustomAppBar(
|
|
|
|
@ -92,10 +109,11 @@ class _AccountAndSafetyPageState extends State<AccountAndSafetyPage> {
|
|
|
|
|
secureValue = !secureValue;
|
|
|
|
|
await HttpManager.post(
|
|
|
|
|
APIV2.userAPI.securePhone,
|
|
|
|
|
{'secure': secureValue ? 1 : 0},
|
|
|
|
|
{'secret': secureValue ? 1 : 0},
|
|
|
|
|
);
|
|
|
|
|
await updateProfile();
|
|
|
|
|
cancel();
|
|
|
|
|
ReToast.success(text: '修改成功');
|
|
|
|
|
ReToast.success(text: secureValue ? '已开启' : '已关闭');
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|