You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

177 lines
5.6 KiB

import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/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<StatefulWidget> createState() {
return _AccountSecurityPage();
}
}
class _AccountSecurityPage extends State<AccountSecurityPage> {
ApiService? apiService;
UserInfo? userInfo;
@override
void initState() {
super.initState();
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString("token") ?? "",),
queryUser(),
});
}
queryUser() async {
BaseData<UserInfo>? baseDate = await apiService?.queryInfo().catchError((onError) {
});
if (baseDate?.isSuccess ?? false) {
userInfo = baseDate!.data;
setState(() {});
SharedPreferences.getInstance().then(
(value) => {
value.setString('user', jsonEncode(baseDate.data)),
},
);
EasyLoading.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,
),
],
),
),
),
],
),
),
);
}
}