mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-26 05:16:01 +08:00
@@ -73,40 +73,45 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
'statistics': Constants.statistics,
|
||||
};
|
||||
Request()
|
||||
.get('${HttpString.appBaseUrl}/x/v2/account/myinfo',
|
||||
queryParameters: data)
|
||||
.get(
|
||||
'${HttpString.appBaseUrl}/x/v2/account/myinfo',
|
||||
queryParameters: data,
|
||||
)
|
||||
.then((res) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
if (res.data['code'] == 0) {
|
||||
AccountMyInfoData data =
|
||||
AccountMyInfoData.fromJson(res.data['data']);
|
||||
_loadingState = Success(data);
|
||||
accountService
|
||||
..name.value = data.name!
|
||||
..face.value = data.face!;
|
||||
try {
|
||||
UserInfoData userInfo = GStorage.userInfo.get('userInfoCache')
|
||||
..uname = data.name
|
||||
..face = data.face;
|
||||
GStorage.userInfo.put('userInfoCache', userInfo);
|
||||
} catch (_) {}
|
||||
try {
|
||||
Get.find<MineController>().userInfo
|
||||
..value.uname = data.name
|
||||
..value.face = data.face
|
||||
..refresh();
|
||||
} catch (_) {}
|
||||
} else {
|
||||
_loadingState = Error(res.data['message']);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
if (res.data['code'] == 0) {
|
||||
AccountMyInfoData data = AccountMyInfoData.fromJson(
|
||||
res.data['data'],
|
||||
);
|
||||
_loadingState = Success(data);
|
||||
accountService
|
||||
..name.value = data.name!
|
||||
..face.value = data.face!;
|
||||
try {
|
||||
UserInfoData userInfo = GStorage.userInfo.get('userInfoCache')
|
||||
..uname = data.name
|
||||
..face = data.face;
|
||||
GStorage.userInfo.put('userInfoCache', userInfo);
|
||||
} catch (_) {}
|
||||
try {
|
||||
Get.find<MineController>().userInfo
|
||||
..value.uname = data.name
|
||||
..value.face = data.face
|
||||
..refresh();
|
||||
} catch (_) {}
|
||||
} else {
|
||||
_loadingState = Error(res.data['message']);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme, LoadingState<AccountMyInfoData> loadingState) {
|
||||
ThemeData theme,
|
||||
LoadingState<AccountMyInfoData> loadingState,
|
||||
) {
|
||||
late final divider = Divider(
|
||||
height: 1,
|
||||
color: theme.dividerColor.withValues(alpha: 0.1),
|
||||
@@ -120,114 +125,121 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success(:var response) => ListView(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 25),
|
||||
children: [
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '头像',
|
||||
widget: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: ClipOval(
|
||||
child: CachedNetworkImage(
|
||||
width: 55,
|
||||
height: 55,
|
||||
imageUrl: ImageUtil.thumbnailUrl(response.face),
|
||||
),
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 25,
|
||||
),
|
||||
children: [
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '头像',
|
||||
widget: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: ClipOval(
|
||||
child: CachedNetworkImage(
|
||||
width: 55,
|
||||
height: 55,
|
||||
imageUrl: ImageUtil.thumbnailUrl(response.face),
|
||||
),
|
||||
),
|
||||
onTap: () => EasyThrottle.throttle(
|
||||
'imagePicker', const Duration(milliseconds: 500), () {
|
||||
_pickImg(theme);
|
||||
}),
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '昵称',
|
||||
text: response.name,
|
||||
onTap: () {
|
||||
if (response.coins! < 6) {
|
||||
SmartDialog.showToast('硬币不足');
|
||||
} else {
|
||||
_editDialog(
|
||||
type: ProfileType.uname,
|
||||
title: '昵称',
|
||||
text: response.name!,
|
||||
);
|
||||
}
|
||||
onTap: () => EasyThrottle.throttle(
|
||||
'imagePicker',
|
||||
const Duration(milliseconds: 500),
|
||||
() {
|
||||
_pickImg(theme);
|
||||
},
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '性别',
|
||||
text: _sex(response.sex!),
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (context_) => _sexDialog(response.sex!),
|
||||
),
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '昵称',
|
||||
text: response.name,
|
||||
onTap: () {
|
||||
if (response.coins! < 6) {
|
||||
SmartDialog.showToast('硬币不足');
|
||||
} else {
|
||||
_editDialog(
|
||||
type: ProfileType.uname,
|
||||
title: '昵称',
|
||||
text: response.name!,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '性别',
|
||||
text: _sex(response.sex!),
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (context_) => _sexDialog(response.sex!),
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '出生年月',
|
||||
text: response.birthday,
|
||||
onTap: () => showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.parse(response.birthday!),
|
||||
firstDate: DateTime(0001, 1, 1),
|
||||
lastDate: DateTime.now(),
|
||||
).then((res) {
|
||||
if (res != null) {
|
||||
_update(
|
||||
type: ProfileType.birthday,
|
||||
datum: DateUtil.longFormat.format(res),
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '出生年月',
|
||||
text: response.birthday,
|
||||
onTap: () =>
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.parse(response.birthday!),
|
||||
firstDate: DateTime(0001, 1, 1),
|
||||
lastDate: DateTime.now(),
|
||||
).then((res) {
|
||||
if (res != null) {
|
||||
_update(
|
||||
type: ProfileType.birthday,
|
||||
datum: DateUtil.longFormat.format(res),
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
divider,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '个性签名',
|
||||
text: response.sign,
|
||||
onTap: () => _editDialog(
|
||||
type: ProfileType.sign,
|
||||
title: '个性签名',
|
||||
text: response.sign,
|
||||
onTap: () => _editDialog(
|
||||
type: ProfileType.sign,
|
||||
title: '个性签名',
|
||||
text: response.sign ?? '',
|
||||
),
|
||||
text: response.sign ?? '',
|
||||
),
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '头像挂件',
|
||||
onTap: () => PageUtils.inAppWebview(
|
||||
'https://www.bilibili.com/h5/mall/pendant/home'),
|
||||
),
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '头像挂件',
|
||||
onTap: () => PageUtils.inAppWebview(
|
||||
'https://www.bilibili.com/h5/mall/pendant/home',
|
||||
),
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: 'UID',
|
||||
needIcon: false,
|
||||
text: response.mid.toString(),
|
||||
onTap: () => Utils.copyText(response.mid.toString()),
|
||||
),
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: 'UID',
|
||||
needIcon: false,
|
||||
text: response.mid.toString(),
|
||||
onTap: () => Utils.copyText(response.mid.toString()),
|
||||
),
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '哔哩哔哩认证',
|
||||
onTap: () => PageUtils.inAppWebview(
|
||||
'https://account.bilibili.com/official/mobile/home',
|
||||
),
|
||||
divider1,
|
||||
_item(
|
||||
theme: theme,
|
||||
title: '哔哩哔哩认证',
|
||||
onTap: () => PageUtils.inAppWebview(
|
||||
'https://account.bilibili.com/official/mobile/home'),
|
||||
),
|
||||
divider1,
|
||||
],
|
||||
),
|
||||
),
|
||||
divider1,
|
||||
],
|
||||
),
|
||||
Error(:var errMsg) => scrollErrorWidget(
|
||||
errMsg: errMsg,
|
||||
onReload: _getInfo,
|
||||
),
|
||||
errMsg: errMsg,
|
||||
onReload: _getInfo,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -288,11 +300,13 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
maxLines: lines,
|
||||
autofocus: true,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
textInputAction:
|
||||
type == ProfileType.sign ? TextInputAction.newline : null,
|
||||
textInputAction: type == ProfileType.sign
|
||||
? TextInputAction.newline
|
||||
: null,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(
|
||||
type == ProfileType.uname ? 16 : 70),
|
||||
type == ProfileType.uname ? 16 : 70,
|
||||
),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
hintText: text,
|
||||
@@ -359,48 +373,48 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
AppSign.appSign(data);
|
||||
Request()
|
||||
.post(
|
||||
'/x/member/app/${type.name}/update',
|
||||
data: data,
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
)
|
||||
'/x/member/app/${type.name}/update',
|
||||
data: data,
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
)
|
||||
.then((res) {
|
||||
if (res.data['code'] == 0) {
|
||||
AccountMyInfoData data = _loadingState.data;
|
||||
if (type == ProfileType.uname) {
|
||||
data
|
||||
..name = _textController.text
|
||||
..coins = data.coins! - 6;
|
||||
accountService.name.value = _textController.text;
|
||||
try {
|
||||
UserInfoData userInfo = GStorage.userInfo.get('userInfoCache')
|
||||
..uname = _textController.text;
|
||||
GStorage.userInfo.put('userInfoCache', userInfo);
|
||||
} catch (_) {}
|
||||
try {
|
||||
Get.find<MineController>().userInfo
|
||||
..value.uname = _textController.text
|
||||
..refresh();
|
||||
} catch (_) {}
|
||||
} else if (type == ProfileType.sign) {
|
||||
data.sign = _textController.text;
|
||||
} else if (type == ProfileType.birthday) {
|
||||
data.birthday = datum;
|
||||
} else if (type == ProfileType.sex) {
|
||||
data.sex = datum;
|
||||
}
|
||||
SmartDialog.showToast('修改成功');
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
if (type == ProfileType.uname || type == ProfileType.sign) {
|
||||
Get.back();
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(res.data['message']);
|
||||
}
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
AccountMyInfoData data = _loadingState.data;
|
||||
if (type == ProfileType.uname) {
|
||||
data
|
||||
..name = _textController.text
|
||||
..coins = data.coins! - 6;
|
||||
accountService.name.value = _textController.text;
|
||||
try {
|
||||
UserInfoData userInfo = GStorage.userInfo.get('userInfoCache')
|
||||
..uname = _textController.text;
|
||||
GStorage.userInfo.put('userInfoCache', userInfo);
|
||||
} catch (_) {}
|
||||
try {
|
||||
Get.find<MineController>().userInfo
|
||||
..value.uname = _textController.text
|
||||
..refresh();
|
||||
} catch (_) {}
|
||||
} else if (type == ProfileType.sign) {
|
||||
data.sign = _textController.text;
|
||||
} else if (type == ProfileType.birthday) {
|
||||
data.birthday = datum;
|
||||
} else if (type == ProfileType.sex) {
|
||||
data.sex = datum;
|
||||
}
|
||||
SmartDialog.showToast('修改成功');
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
if (type == ProfileType.uname || type == ProfileType.sign) {
|
||||
Get.back();
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(res.data['message']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String _sex(int sex) {
|
||||
@@ -446,14 +460,15 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
),
|
||||
),
|
||||
)
|
||||
else ?widget,
|
||||
else
|
||||
?widget,
|
||||
if (needIcon)
|
||||
Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: theme.colorScheme.outline,
|
||||
)
|
||||
else
|
||||
const SizedBox(width: 24)
|
||||
const SizedBox(width: 24),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -466,8 +481,9 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
imageQuality: 100,
|
||||
);
|
||||
if (pickedFile != null && mounted) {
|
||||
String? mimeType =
|
||||
lookupMimeType(pickedFile.path)?.split('/').getOrNull(1);
|
||||
String? mimeType = lookupMimeType(
|
||||
pickedFile.path,
|
||||
)?.split('/').getOrNull(1);
|
||||
if (mimeType == 'gif') {
|
||||
SmartDialog.showToast('不能选GIF');
|
||||
return;
|
||||
@@ -502,25 +518,26 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
if (croppedFile != null) {
|
||||
Request()
|
||||
.post(
|
||||
'/x/member/web/face/update',
|
||||
queryParameters: {
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
data: FormData.fromMap({
|
||||
'dopost': 'save',
|
||||
'DisplayRank': 10000,
|
||||
'face': await MultipartFile.fromFile(croppedFile.path),
|
||||
}),
|
||||
)
|
||||
'/x/member/web/face/update',
|
||||
queryParameters: {
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
data: FormData.fromMap({
|
||||
'dopost': 'save',
|
||||
'DisplayRank': 10000,
|
||||
'face': await MultipartFile.fromFile(croppedFile.path),
|
||||
}),
|
||||
)
|
||||
.then((res) {
|
||||
if (res.data['code'] == 0) {
|
||||
SmartDialog.showToast('修改成功');
|
||||
Future.delayed(const Duration(milliseconds: 500))
|
||||
.whenComplete(_getInfo);
|
||||
} else {
|
||||
SmartDialog.showToast(res.data['message']);
|
||||
}
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
SmartDialog.showToast('修改成功');
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 500),
|
||||
).whenComplete(_getInfo);
|
||||
} else {
|
||||
SmartDialog.showToast(res.data['message']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user