import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/constant.dart'; import 'package:huixiang/data/base_data.dart'; import 'package:huixiang/data/user_info.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/shared_preference.dart'; class AccountSecurityPage extends StatefulWidget { @override State createState() { return _AccountSecurityPage(); } } class _AccountSecurityPage extends State { ApiService? apiService; UserInfo? userInfo; @override void initState() { super.initState(); apiService = ApiService( Dio(), context: context, token: SharedInstance.instance.token ?? "", ); queryUser(); } queryUser() async { S.current.zhengzaijiazai.loading; BaseData? baseDate = await apiService?.queryInfo().catchError((onError) { return BaseData()..isSuccess = false; }); if ((baseDate?.isSuccess ?? false) && baseDate!.data != null) { userInfo = baseDate.data; setState(() {}); SharedInstance.instance.saveUser(baseDate.data!); SmartDialog.dismiss(); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.white, leading: GestureDetector( child: Icon( Icons.arrow_back_ios, color: Colors.black, ), onTap: () { Navigator.of(context).pop(); }, ), title: Text( S.of(context).zhanghaoanquan, style: TextStyle( fontWeight: MyFontWeight.regular, fontSize: 17.sp, color: Color(0xFF0D0D0D), ), ), centerTitle: true, elevation: 0.0, ), body: Container( decoration: new BoxDecoration( border: Border( bottom: BorderSide( color: Color(0xffF7F7F7), width: 0.0, ), ), color: Color(0xffF7F7F7), ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ GestureDetector( onTap: () { Navigator.of(context).pushNamed( '/router/binding_phone_page', arguments: { "userInfo": userInfo }, ).then((value) => { queryUser() }); }, child: Container( padding: EdgeInsets.all(15), margin: EdgeInsets.only(top: 14.h), decoration: BoxDecoration( color: Colors.white, ), child: Row( children: [ Expanded( child: Text( S.of(context).bangdingshouji, style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: 15.sp, color: Color(0xFF353535), ), ), flex: 1, ), Text( "+86 ${userInfo?.phone ?? ""}", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF4D4D4D)), ), SizedBox( width: 8.w, ), Icon( Icons.keyboard_arrow_right, size: 20, ), ], ), ), ), GestureDetector( onTap: () { Navigator.of(context).pushReplacementNamed( '/router/platform_code_page', arguments: {"userInfo": userInfo}); }, child: Container( padding: EdgeInsets.all(15), margin: EdgeInsets.only(top: 14.h), decoration: BoxDecoration( color: Colors.white, ), child: Row( children: [ Expanded( child: Text( "平台支付密码", style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: 15.sp, color: Color(0xFF353535), ), ), flex: 1, ), Text( (userInfo?.hasPayPassword ?? true) ? S.of(context).xiugai : S.of(context).shezhi, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF4D4D4D), ), ), SizedBox( width: 8.w, ), Icon( Icons.keyboard_arrow_right, size: 20, ), ], ), ), ), ], ), ), ); } }