From 4773ee0f0ece5cb9be2ab43c1f25b0ce5aee08c4 Mon Sep 17 00:00:00 2001 From: jack ning Date: Tue, 22 Mar 2022 17:10:14 +0800 Subject: [PATCH] 1..2.0 --- .../org.eclipse.buildship.core.prefs | 2 +- bytedesk_demo/lib/main.dart | 2 +- bytedesk_demo/lib/page/user_info_page.dart | 63 +++++++++++++------ bytedesk_demo/pubspec.yaml | 2 +- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/bytedesk_demo/android/.settings/org.eclipse.buildship.core.prefs b/bytedesk_demo/android/.settings/org.eclipse.buildship.core.prefs index fa9b365..5fc6763 100644 --- a/bytedesk_demo/android/.settings/org.eclipse.buildship.core.prefs +++ b/bytedesk_demo/android/.settings/org.eclipse.buildship.core.prefs @@ -5,7 +5,7 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.1.1)) connection.project.dir= eclipse.preferences.version=1 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= offline.mode=false override.workspace.settings=true diff --git a/bytedesk_demo/lib/main.dart b/bytedesk_demo/lib/main.dart index a55928a..23f41aa 100644 --- a/bytedesk_demo/lib/main.dart +++ b/bytedesk_demo/lib/main.dart @@ -22,7 +22,7 @@ void main() { ))); // 参考文档:https://github.com/Bytedesk/bytedesk-flutter - // 管理后台:https://www.bytedesk.com/antv/user/login + // 管理后台:https://www.bytedesk.com/admin // appkey和subDomain请替换为真实值 // 获取appkey,登录后台->渠道管理->Flutter->添加应用->获取appkey String _appKey = '81f427ea-4467-4c7c-b0cd-5c0e4b51456f'; diff --git a/bytedesk_demo/lib/page/user_info_page.dart b/bytedesk_demo/lib/page/user_info_page.dart index 5af3308..cb831cc 100755 --- a/bytedesk_demo/lib/page/user_info_page.dart +++ b/bytedesk_demo/lib/page/user_info_page.dart @@ -12,9 +12,13 @@ class UserInfoPage extends StatefulWidget { _UserInfoPageState createState() => _UserInfoPageState(); } + class _UserInfoPageState extends State { - String _nickname = ''; - String _avatar = BytedeskConstants.DEFAULT_AVATA; + String _uid = ''; // 用户唯一uid + String _username = ''; // 用户唯一用户名 + String _nickname = ''; // 用户昵称 + String _avatar = BytedeskConstants.DEFAULT_AVATA; // 用户头像 + String _description = ''; // 用户备注 @override void initState() { _getProfile(); @@ -52,6 +56,14 @@ class _UserInfoPageState extends State { _setAvatar(); }, ), + ListTile( + title: Text('设置备注(见代码)'), + subtitle: Text(_description), + onTap: () { + // + _setDescription(); + }, + ), ], ).toList()), ); @@ -60,32 +72,47 @@ class _UserInfoPageState extends State { void _getProfile() { // 查询当前用户信息:昵称、头像 BytedeskKefu.getProfile().then((user) => { - setState(() { - _nickname = user.nickname!; - _avatar = user.avatar!; - }) - }); + setState(() { + _uid = user.uid!; + _username = user.username!; + _nickname = user.nickname!; + _avatar = user.avatar!; + _description = user.description!; + }) + }); } void _setNickname() { // 可自定义用户昵称-客服端可见 String mynickname = '自定义APP昵称flutter'; BytedeskKefu.updateNickname(mynickname).then((user) => { - setState(() { - _nickname = mynickname; - }), - Fluttertoast.showToast(msg: "设置昵称成功") - }); + setState(() { + _nickname = mynickname; + }), + Fluttertoast.showToast(msg: "设置昵称成功") + }); } void _setAvatar() { // 可自定义用户头像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) => { - setState(() { - _avatar = myavatarurl; - }), - Fluttertoast.showToast(msg: "设置头像成功") - }); + setState(() { + _avatar = myavatarurl; + }), + Fluttertoast.showToast(msg: "设置头像成功") + }); + } + + void _setDescription() { + // 可自定义用户昵称-客服端可见 + String description = '自定义用户备注'; + BytedeskKefu.updateDescription(description).then((user) => { + setState(() { + description = description; + }), + Fluttertoast.showToast(msg: "设置备注成功") + }); } } diff --git a/bytedesk_demo/pubspec.yaml b/bytedesk_demo/pubspec.yaml index 2882fc0..8c36ec4 100644 --- a/bytedesk_demo/pubspec.yaml +++ b/bytedesk_demo/pubspec.yaml @@ -40,7 +40,7 @@ dependencies: # 请在ios/Podfile中添加:use_frameworks! vibration: ^1.7.3 # 在线客服 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. # Use with the CupertinoIcons class for iOS style icons.