import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:shared_preferences/shared_preferences.dart'; class AccountSecurityPage extends StatefulWidget { @override State createState() { return _AccountSecurityPage(); } } class _AccountSecurityPage extends State { ApiService apiService; UserInfo userInfo; @override void initState() { super.initState(); SharedPreferences.getInstance().then((value) => { apiService = ApiService(Dio(), context: context, token: value.getString("token"), showLoading: true), queryUser(), }); } queryUser() async { BaseData baseDate = await apiService.queryInfo().catchError((onError) { }); if (baseDate != null && baseDate.isSuccess) { userInfo = baseDate.data; setState(() {}); SharedPreferences.getInstance().then( (value) => { value.setString('user', jsonEncode(baseDate.data)), }, ); } } @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( "绑定手机", 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, ), if(userInfo?.hasPayPassword != null) Text( (userInfo?.hasPayPassword ?? true)? "修改" :"设置", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF4D4D4D)), ), SizedBox( width:8.w, ), Icon( Icons.keyboard_arrow_right, size: 20, ), ], ), ), ), ], ), ), ); } }