master
jack ning 3 years ago
parent 54316e06b5
commit 4773ee0f0e

@ -5,7 +5,7 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.1.1))
connection.project.dir= connection.project.dir=
eclipse.preferences.version=1 eclipse.preferences.version=1
gradle.user.home= gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
jvm.arguments= jvm.arguments=
offline.mode=false offline.mode=false
override.workspace.settings=true override.workspace.settings=true

@ -22,7 +22,7 @@ void main() {
))); )));
// https://github.com/Bytedesk/bytedesk-flutter // https://github.com/Bytedesk/bytedesk-flutter
// https://www.bytedesk.com/antv/user/login // https://www.bytedesk.com/admin
// appkeysubDomain // appkeysubDomain
// appkey->->Flutter->->appkey // appkey->->Flutter->->appkey
String _appKey = '81f427ea-4467-4c7c-b0cd-5c0e4b51456f'; String _appKey = '81f427ea-4467-4c7c-b0cd-5c0e4b51456f';

@ -12,9 +12,13 @@ class UserInfoPage extends StatefulWidget {
_UserInfoPageState createState() => _UserInfoPageState(); _UserInfoPageState createState() => _UserInfoPageState();
} }
class _UserInfoPageState extends State<UserInfoPage> { class _UserInfoPageState extends State<UserInfoPage> {
String _nickname = ''; String _uid = ''; // uid
String _avatar = BytedeskConstants.DEFAULT_AVATA; String _username = ''; //
String _nickname = ''; //
String _avatar = BytedeskConstants.DEFAULT_AVATA; //
String _description = ''; //
@override @override
void initState() { void initState() {
_getProfile(); _getProfile();
@ -52,6 +56,14 @@ class _UserInfoPageState extends State<UserInfoPage> {
_setAvatar(); _setAvatar();
}, },
), ),
ListTile(
title: Text('设置备注(见代码)'),
subtitle: Text(_description),
onTap: () {
//
_setDescription();
},
),
], ],
).toList()), ).toList()),
); );
@ -60,32 +72,47 @@ class _UserInfoPageState extends State<UserInfoPage> {
void _getProfile() { void _getProfile() {
// //
BytedeskKefu.getProfile().then((user) => { BytedeskKefu.getProfile().then((user) => {
setState(() { setState(() {
_nickname = user.nickname!; _uid = user.uid!;
_avatar = user.avatar!; _username = user.username!;
}) _nickname = user.nickname!;
}); _avatar = user.avatar!;
_description = user.description!;
})
});
} }
void _setNickname() { void _setNickname() {
// - // -
String mynickname = '自定义APP昵称flutter'; String mynickname = '自定义APP昵称flutter';
BytedeskKefu.updateNickname(mynickname).then((user) => { BytedeskKefu.updateNickname(mynickname).then((user) => {
setState(() { setState(() {
_nickname = mynickname; _nickname = mynickname;
}), }),
Fluttertoast.showToast(msg: "设置昵称成功") Fluttertoast.showToast(msg: "设置昵称成功")
}); });
} }
void _setAvatar() { void _setAvatar() {
// url- // url-
String myavatarurl = 'https://chainsnow.oss-cn-shenzhen.aliyuncs.com/avatars/visitor_default_avatar.png'; // url String myavatarurl =
'https://chainsnow.oss-cn-shenzhen.aliyuncs.com/avatars/visitor_default_avatar.png'; // url
BytedeskKefu.updateAvatar(myavatarurl).then((user) => { BytedeskKefu.updateAvatar(myavatarurl).then((user) => {
setState(() { setState(() {
_avatar = myavatarurl; _avatar = myavatarurl;
}), }),
Fluttertoast.showToast(msg: "设置头像成功") Fluttertoast.showToast(msg: "设置头像成功")
}); });
}
void _setDescription() {
// -
String description = '自定义用户备注';
BytedeskKefu.updateDescription(description).then((user) => {
setState(() {
description = description;
}),
Fluttertoast.showToast(msg: "设置备注成功")
});
} }
} }

@ -40,7 +40,7 @@ dependencies:
# 请在ios/Podfile中添加use_frameworks! # 请在ios/Podfile中添加use_frameworks!
vibration: ^1.7.3 vibration: ^1.7.3
# 在线客服 https://pub.dev/packages/bytedesk_kefu # 在线客服 https://pub.dev/packages/bytedesk_kefu
bytedesk_kefu: ^1.1.8 bytedesk_kefu: ^1.2.0
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.

Loading…
Cancel
Save