master
jack ning 3 years ago
parent 8c7df6205d
commit dcd34c17ed

@ -122,4 +122,22 @@ class _UserInfoPageState extends State<UserInfoPage> {
Fluttertoast.showToast(msg: "设置备注成功") Fluttertoast.showToast(msg: "设置备注成功")
}); });
} }
//
void _updateProfile() {
//
String mynickname = '自定义APP昵称flutter';
String myavatarurl =
'https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png'; // url
String mydescription = '自定义用户备注';
BytedeskKefu.updateProfile(mynickname, myavatarurl, mydescription)
.then((user) => {
setState(() {
_nickname = mynickname;
_avatar = myavatarurl;
_description = mydescription;
}),
Fluttertoast.showToast(msg: "设置成功")
});
}
} }

@ -46,7 +46,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.2.8 bytedesk_kefu: ^1.2.9
# 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.

@ -1,5 +1,9 @@
# Upgrade Log # Upgrade Log
## 1.2.9
* optimize user experience
## 1.2.8 ## 1.2.8
* optimize user experience * optimize user experience

@ -102,8 +102,7 @@ class _UserInfoPageState extends State<UserInfoPage> {
void _setAvatar() { void _setAvatar() {
// url- // url-
String myavatarurl = String myavatarurl = 'https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png'; // url
'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;
@ -122,4 +121,20 @@ class _UserInfoPageState extends State<UserInfoPage> {
Fluttertoast.showToast(msg: "设置备注成功") Fluttertoast.showToast(msg: "设置备注成功")
}); });
} }
//
void _updateProfile() {
//
String mynickname = '自定义APP昵称flutter';
String myavatarurl = 'https://bytedesk.oss-cn-shenzhen.aliyuncs.com/avatars/girl.png'; // url
String mydescription = '自定义用户备注';
BytedeskKefu.updateProfile(mynickname, myavatarurl, mydescription).then((user) => {
setState(() {
_nickname = mynickname;
_avatar = myavatarurl;
_description = mydescription;
}),
Fluttertoast.showToast(msg: "设置成功")
});
}
} }

@ -394,8 +394,13 @@ class BytedeskKefu {
} }
// //
static Future<User> updateDescription(String avatar) async { static Future<User> updateDescription(String description) async {
return BytedeskUserHttpApi().updateDescription(avatar); return BytedeskUserHttpApi().updateDescription(description);
}
//
static Future<User> updateProfile(String nickname, String avatar, String description) async {
return BytedeskUserHttpApi().updateProfile(nickname, avatar, description);
} }
// 线 // 线

@ -334,7 +334,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json //string json
final responseJson = final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes)); json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson"); print("updateNickname:");
print(responseJson);
// //
SpUtil.putString(BytedeskConstants.nickname, nickname!); SpUtil.putString(BytedeskConstants.nickname, nickname!);
@ -355,7 +356,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json //string json
final responseJson = final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes)); json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson"); print("updateAvatar:");
print(responseJson);
// //
SpUtil.putString(BytedeskConstants.avatar, avatar!); SpUtil.putString(BytedeskConstants.avatar, avatar!);
@ -376,13 +378,37 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json //string json
final responseJson = final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes)); json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("updateDescription $responseJson"); print("updateDescription:");
print(responseJson);
// //
SpUtil.putString(BytedeskConstants.description, description!); SpUtil.putString(BytedeskConstants.description, description!);
return User.fromJson(responseJson['data']); return User.fromJson(responseJson['data']);
} }
//
Future<User> updateProfile(String? nickname, String? avatar, String? description) async {
//
var body = json.encode({"nickname": nickname, "avatar": avatar, "description": description, "client": client});
//
final initUrl = Uri.http(BytedeskConstants.host, '/api/user/update/visitor/profile');
final initResponse =
await this.httpClient.post(initUrl, headers: getHeaders(), body: body);
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("updateProfile:");
print(responseJson);
//
SpUtil.putString(BytedeskConstants.nickname, nickname!);
SpUtil.putString(BytedeskConstants.avatar, avatar!);
SpUtil.putString(BytedeskConstants.description, description!);
return User.fromJson(responseJson['data']);
}
// //
Future<User> updateSex(bool? sex) async { Future<User> updateSex(bool? sex) async {
// //

@ -1,9 +1,9 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; // import 'dart:convert';
import 'package:bytedesk_kefu/model/answer.dart'; import 'package:bytedesk_kefu/model/answer.dart';
import 'package:bytedesk_kefu/model/category.dart'; import 'package:bytedesk_kefu/model/category.dart';
import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; // import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart'; import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:path/path.dart'; import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart'; import 'package:sqflite/sqflite.dart';

@ -1,33 +1,34 @@
import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart'; import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:sp_util/sp_util.dart';
class Thread extends Equatable { class Thread extends Equatable {
// //
String? tid; final String? tid;
String? topic; final String? topic;
String? wid; final String? wid;
String? uid; final String? uid;
String? nickname; final String? nickname;
String? avatar; final String? avatar;
String? content; final String? content;
String? timestamp; final String? timestamp;
int? unreadCount; final int? unreadCount;
String? type; final String? type;
// //
bool? current; final bool? current;
// //
bool? top; final bool? top;
bool? topVisitor; final bool? topVisitor;
// //
bool? nodisturb; final bool? nodisturb;
bool? nodisturbVisitor; final bool? nodisturbVisitor;
// //
bool? unread; final bool? unread;
bool? unreadVisitor; final bool? unreadVisitor;
// //
String? client; final String? client;
String? currentUid; final String? currentUid;
Thread( Thread(
{this.tid, {this.tid,
@ -177,8 +178,10 @@ class Thread extends Equatable {
tid: json['tid'], tid: json['tid'],
topic: json['topic'], topic: json['topic'],
uid: json['visitor']['uid'], uid: json['visitor']['uid'],
nickname: json['visitor']['nickname'], // nickname: json['visitor']['nickname'],
avatar: json['visitor']['avatar'], nickname: SpUtil.getString(BytedeskConstants.nickname)!,
// avatar: json['visitor']['avatar'],
avatar: SpUtil.getString(BytedeskConstants.avatar)!,
content: json['content'], content: json['content'],
timestamp: BytedeskUtils.getTimeDuration(json['timestamp']), timestamp: BytedeskUtils.getTimeDuration(json['timestamp']),
unreadCount: json['unreadCount'], unreadCount: json['unreadCount'],
@ -262,26 +265,26 @@ class Thread extends Equatable {
}; };
} }
Thread.fromMap(Map<String, dynamic> map) { // Thread.fromMap(Map<String, dynamic> map) {
tid = map['tid']; // tid = map['tid'];
topic = map['topic']; // topic = map['topic'];
wid = map['wid']; // wid = map['wid'];
uid = map['uid']; // uid = map['uid'];
nickname = map['nickname']; // nickname = map['nickname'];
avatar = map['avatar']; // avatar = map['avatar'];
content = map['content']; // content = map['content'];
timestamp = map['timestamp']; // timestamp = map['timestamp'];
unreadCount = map['unreadCount']; // unreadCount = map['unreadCount'];
type = map['type']; // type = map['type'];
current = map['current']; // current = map['current'];
client = map['client']; // client = map['client'];
top = map['top']; // top = map['top'];
topVisitor = map['topVisitor']; // topVisitor = map['topVisitor'];
nodisturb = map['nodisturb']; // nodisturb = map['nodisturb'];
nodisturbVisitor = map['nodisturbVisitor']; // nodisturbVisitor = map['nodisturbVisitor'];
unread = map['unread']; // unread = map['unread'];
unreadVisitor = map['unreadVisitor']; // unreadVisitor = map['unreadVisitor'];
currentUid = map['currentUid']; // currentUid = map['currentUid'];
client = map['client']; // client = map['client'];
} // }
} }

@ -659,11 +659,11 @@ class _ChatIMPageState extends State<ChatIMPage>
print( print(
'aid ${event.aid}, question ${event.question}, answer ${event.answer}'); 'aid ${event.aid}, question ${event.question}, answer ${event.answer}');
// //
BlocProvider.of<MessageBloc>(context) // BlocProvider.of<MessageBloc>(context)
..add(QueryAnswerEvent( // ..add(QueryAnswerEvent(
tid: _currentThread!.tid, // tid: _currentThread!.tid,
aid: event.aid, // aid: event.aid,
)); // ));
} }
}); });
// , https://learnku.com/articles/30338 // , https://learnku.com/articles/30338

@ -198,8 +198,6 @@ class _ChatKFPageState extends State<ChatKFPage>
if (state.threadResult.statusCode == 200 || if (state.threadResult.statusCode == 200 ||
state.threadResult.statusCode == 201) { state.threadResult.statusCode == 201) {
print('创建新会话'); print('创建新会话');
//
// _messageProvider.insert(state.threadResult.msg!);
// TODO: pop // TODO: pop
// //
if (widget.custom != null && if (widget.custom != null &&
@ -218,7 +216,6 @@ class _ChatKFPageState extends State<ChatKFPage>
// //
_messageProvider.insert(state.threadResult.msg!); _messageProvider.insert(state.threadResult.msg!);
// //
// _getMessages(_page, _size);
_appendMessage(state.threadResult.msg!); _appendMessage(state.threadResult.msg!);
// //
if (widget.custom != null && if (widget.custom != null &&
@ -240,7 +237,6 @@ class _ChatKFPageState extends State<ChatKFPage>
// //
_messageProvider.insert(state.threadResult.msg!); _messageProvider.insert(state.threadResult.msg!);
// TODO: // TODO:
// _getMessages(_page, _size);
_appendMessage(state.threadResult.msg!); _appendMessage(state.threadResult.msg!);
// TODO: // TODO:
Navigator.of(context) Navigator.of(context)
@ -358,10 +354,8 @@ class _ChatKFPageState extends State<ChatKFPage>
// _messageProvider.insert(state.answer!); // _messageProvider.insert(state.answer!);
// _appendMessage(state.answer!); // _appendMessage(state.answer!);
} else if (state is QueryCategorySuccess) { } else if (state is QueryCategorySuccess) {
_messageProvider.insert(state.answer!); _messageProvider.insert(state.answer!);
_appendMessage(state.answer!); _appendMessage(state.answer!);
} else if (state is MessageAnswerSuccess) { } else if (state is MessageAnswerSuccess) {
// Message queryMessage = state.query!; // Message queryMessage = state.query!;
// queryMessage.isSend = 1; // queryMessage.isSend = 1;
@ -859,8 +853,7 @@ class _ChatKFPageState extends State<ChatKFPage>
appendQueryMessage(event.name); appendQueryMessage(event.name);
// //
BlocProvider.of<MessageBloc>(context) BlocProvider.of<MessageBloc>(context)
..add(QueryCategoryEvent( ..add(QueryCategoryEvent(tid: _currentThread!.tid, cid: event.cid));
tid: _currentThread!.tid, cid: event.cid));
} }
}); });
// //
@ -1109,6 +1102,8 @@ class _ChatKFPageState extends State<ChatKFPage>
if (message.status != BytedeskConstants.MESSAGE_STATUS_READ) { if (message.status != BytedeskConstants.MESSAGE_STATUS_READ) {
// //
if (message.isSend == 0) { if (message.isSend == 0) {
print('message.mid ${message.mid}');
print('_currentThread ${_currentThread!.tid}');
_bdMqtt.sendReceiptReadMessage(message.mid!, _currentThread!); _bdMqtt.sendReceiptReadMessage(message.mid!, _currentThread!);
} }
} }

@ -571,11 +571,11 @@ class _ChatLSPageState extends State<ChatLSPage>
print( print(
'aid ${event.aid}, question ${event.question}, answer ${event.answer}'); 'aid ${event.aid}, question ${event.question}, answer ${event.answer}');
// //
BlocProvider.of<MessageBloc>(context) // BlocProvider.of<MessageBloc>(context)
..add(QueryAnswerEvent( // ..add(QueryAnswerEvent(
tid: _currentThread!.tid, // tid: _currentThread!.tid,
aid: event.aid, // aid: event.aid,
)); // ));
} }
}); });
// , https://learnku.com/articles/30338 // , https://learnku.com/articles/30338

@ -86,8 +86,8 @@ class _RenderExpandedViewport extends RenderViewport {
p = childAfter(p); p = childAfter(p);
} }
if (expand! != null && size.height > totalLayoutExtent) { if (size.height > totalLayoutExtent) {
_attemptLayout(expand, size.height, size.width, _attemptLayout(expand!, size.height, size.width,
offset.pixels - frontExtent - (size.height - totalLayoutExtent)); offset.pixels - frontExtent - (size.height - totalLayoutExtent));
} }
} }

@ -12,9 +12,9 @@ class MyButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FlatButton( return TextButton( // FlatButton
onPressed: onPressed, onPressed: onPressed,
textColor: Colors.white, // textColor: Colors.white,
child: Container( child: Container(
height: 48, height: 48,
width: double.infinity, width: double.infinity,

@ -1,6 +1,6 @@
name: bytedesk_kefu name: bytedesk_kefu
description: the best app chat sdk in china, you can chat with the agent freely at anytime. the agent can chat with the visitor by web/pc/mac/ios/android client. description: the best app chat sdk in china, you can chat with the agent freely at anytime. the agent can chat with the visitor by web/pc/mac/ios/android client.
version: 1.2.8 version: 1.2.9
homepage: https://www.weikefu.net homepage: https://www.weikefu.net
environment: environment:

Loading…
Cancel
Save