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

add

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