提交 d43154ef authored 作者: yueweilu's avatar yueweilu

add

上级 ad49261f
......@@ -133,6 +133,7 @@ abstract class CommonAPI {
}
/// 9、收藏 取消收藏
///
static Future <bool> love({
required String bookId,
required String love
......@@ -150,5 +151,15 @@ abstract class CommonAPI {
return false;
}
/// 10、上传文件
static Future upload({
required String path
}) async {
final result = await HttpService.to.upload(
'/v1/members/Information/uploadFile',
path: path
);
print(result.data);
}
}
\ No newline at end of file
......@@ -177,5 +177,32 @@ abstract class MineAPI {
});
}
/// 11、修改用户信息
///
static Future <bool> changeInfo({
String? name,
String? sex,
String? headImg
}) async {
Map<String,dynamic> params = {};
if (name != null){
params['name'] = name;
}
if (sex != null){
params['sex'] = sex;
}
if (headImg != null){
params['head_img'] = headImg;
}
final result = await HttpService.to.post(
'/v1/members/Information/editInformation',
params: params
);
if (result.data is Map && result.data['is_success'] == 1){
return true;
}
return false;
}
}
\ No newline at end of file
......@@ -68,7 +68,7 @@ class _MinePageState extends State<MinePage> {
child: Column(
children: [
BuildUser(userInfo:controller.userInfo,onTap: (){
context.pushNamed(Routes.userInfo);
context.pushNamed(Routes.userInfo,extra: controller.userInfo);
},),
Gaps.vGaps10,
BuildRead(items: controller.reads,onTap: (ReadModel model) async{
......
part of user_info;
class UserInfoController extends GetxController {
/// 上传头像
void upload({
required String path
}) async {
var result = await CommonAPI.upload(path:path);
print(result);
update();
}
/// 修改用用户信息
}
\ No newline at end of file
......@@ -3,9 +3,16 @@ library user_info;
import 'package:flutter/material.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
import '../../routes/index.dart';
part 'view.dart';
\ No newline at end of file
part 'view.dart';
part 'controller.dart';
\ No newline at end of file
part of user_info;
class UserInfoPage extends StatefulWidget {
const UserInfoPage({Key? key}) : super(key: key);
final UserInfoModel userInfo;
const UserInfoPage({
Key? key,
required this.userInfo
}) : super(key: key);
@override
State<UserInfoPage> createState() => _UserInfoPageState();
......@@ -10,98 +14,117 @@ class UserInfoPage extends StatefulWidget {
class _UserInfoPageState extends State<UserInfoPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('个人信息'),
centerTitle: true,
),
body: Container(
margin: const EdgeInsets.symmetric(horizontal: AppTheme.margin),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
return GetBuilder<UserInfoController>(
init: UserInfoController(),
builder: (controller) =>Scaffold(
appBar: AppBar(
title: const Text('个人信息'),
centerTitle: true,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
/// 头像
Container(
height: 52,
padding: const EdgeInsets.only(left: 18,right: 15),
child: GestureDetector(
onTap: (){
body: Container(
margin: const EdgeInsets.symmetric(horizontal: AppTheme.margin,vertical: AppTheme.margin),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
boxShadow: [
BoxShadow(
color: const Color(0xFFC7C7C7).withOpacity(0.5),
offset: const Offset(3, 0),
blurRadius: 10.w,
spreadRadius: 0.w,
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
/// 头像
Container(
height: 52,
padding: const EdgeInsets.only(left: 18,right: 15),
child: GestureDetector(
onTap: () async {
final assets = await AssetsPicker.image(
context: context,
source: ImageSource.gallery,
maxWidth: 512,
maxHeight: 512,
);
controller.upload(path: assets!.path);
},
child: Container(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('头像',style: TextStyle(color: Colours.c3,fontSize: 14,height: 1.6),),
Row(
},
child: Container(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: 33.w,
height: 33.w,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.cyan,
),
),
Gaps.hGaps10,
Container(
width: 5,
height: 8,
color: Colors.cyan,
const Text('头像',style: TextStyle(color: Colours.c3,fontSize: 14,height: 1.6),),
Row(
children: [
Container(
width: 33.w,
height: 33.w,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.cyan,
),
child: CustomImage.network(url: widget.userInfo.headImg??''),
),
Gaps.hGaps10,
SizedBox(
width: 5,
height: 8,
child: Image.asset('assets/images/right_arrow.png'),
)
],
)
],
)
],
),
),
),
),
),
Container(color: Colours.cLine,margin: const EdgeInsets.symmetric(horizontal: 15),height: 1,),
GestureDetector(
onTap: (){
context.pushNamed(Routes.nike);
},
child: _buildItem('昵称', widget.userInfo.name??'', )
),
Container(color: Colours.cLine,margin: const EdgeInsets.symmetric(horizontal: 15),height: 1,),
_buildItem('性别', widget.userInfo.sex ==1?'男':'女',),
],
),
Container(color: Colours.cLine,margin: const EdgeInsets.symmetric(horizontal: 15),height: 1,),
_buildItem('昵称', '随便起个名字', Routes.nike),
Container(color: Colours.cLine,margin: const EdgeInsets.symmetric(horizontal: 15),height: 1,),
_buildItem('性别', '男', 'linkTo'),
],
),
)
),
)
),
);
}
Widget _buildItem(String title, String value,String linkTo,{VoidCallback? onTap}) {
return GestureDetector(
onTap: (){
if (linkTo.isNotEmpty){
context.pushNamed(linkTo);
if (onTap !=null) onTap;
}
},
child: Container(
padding: const EdgeInsets.only(left: 18,right: 15),
color: Colors.transparent,
height: 52,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(title,style: const TextStyle(fontSize: 14,color: Colours.c3,),),
Row(
children: [
Text(value,style: const TextStyle(fontSize:14,color: Colours.c9,),),
Gaps.hGaps10,
Container(
width: 5,
height: 8,
color: Colors.cyan,
)
],
)
Widget _buildItem(String title, String value) {
return Container(
padding: const EdgeInsets.only(left: 18,right: 15),
color: Colors.transparent,
height: 52,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(title,style: const TextStyle(fontSize: 14,color: Colours.c3,),),
Row(
children: [
Text(value,style: const TextStyle(fontSize:14,color: Colours.c9,),),
Gaps.hGaps10,
SizedBox(
width: 5,
height: 8,
child: Image.asset('assets/images/right_arrow.png'),
)
],
)
],
),
],
),
);
}
......
......@@ -205,7 +205,7 @@ abstract class Routes {
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: const UserInfoPage()
child: UserInfoPage(userInfo: state.extra as UserInfoModel,)
)
),
GoRoute(
......
......@@ -38,8 +38,12 @@ class HttpService extends GetxService {
}
if (params != null) {
params.addAll(headers);
headers['Sign'] = SignTool.createSign(params!);
}
headers['Sign'] = SignTool.createSign(params!);
else {
headers['Sign'] = SignTool.createSign(headers);
}
// Console.log(headers);
return headers;
}
......@@ -114,7 +118,7 @@ class HttpService extends GetxService {
requestOptions.headers = _getHeaders(excludeToken: excludeToken,url:url);
final name = path.substring(path.lastIndexOf('/') + 1,path.length);
final image = await MultipartFile.fromFile(path, filename: name);
final formData = FormData.fromMap({'file':image});
final formData = FormData.fromMap({'files':image});
final response = await _dio.post(
url,
data:formData,
......
......@@ -71,7 +71,7 @@ abstract class AppTheme {
static ThemeData get light {
var scheme = ColorScheme.light(
background: Colors.white,
background: Colours.cF9,
onBackground: const Color(0xFF333333),
surface: Colors.white,
onSurface: const Color(0xFF333333),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论