master
jack ning 2 years ago
parent e92afc3bd4
commit 77f769862e

@ -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.3.2 bytedesk_kefu: ^1.3.3
# 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.3.3
* optimize user experience
## 1.3.2 ## 1.3.2
* optimize user experience * optimize user experience

@ -79,6 +79,7 @@ class Message {
// //
return Message( return Message(
mid: json['mid'], mid: json['mid'],
// topic: json['thread']['topic'],
content: json['content'], content: json['content'],
imageUrl: json['imageUrl'], imageUrl: json['imageUrl'],
voiceUrl: json['voiceUrl'], voiceUrl: json['voiceUrl'],
@ -112,6 +113,7 @@ class Message {
// //
return Message( return Message(
mid: json['mid'], mid: json['mid'],
// topic: json['thread']['topic'],
content: json['content'], content: json['content'],
imageUrl: json['imageUrl'], imageUrl: json['imageUrl'],
voiceUrl: json['voiceUrl'], voiceUrl: json['voiceUrl'],
@ -150,6 +152,7 @@ class Message {
// //
return Message( return Message(
mid: json['mid'], mid: json['mid'],
// topic: json['thread']['topic'],
content: json['content'], content: json['content'],
imageUrl: json['imageUrl'], imageUrl: json['imageUrl'],
voiceUrl: json['voiceUrl'], voiceUrl: json['voiceUrl'],
@ -169,7 +172,9 @@ class Message {
answersJson: json['answers'].toString()); answersJson: json['answers'].toString());
} }
static Message fromJson(dynamic json) { static Message fromJson(dynamic json) {
//
List<Answer> robotQaList = []; List<Answer> robotQaList = [];
if (json['type'] == BytedeskConstants.MESSAGE_TYPE_ROBOT) { if (json['type'] == BytedeskConstants.MESSAGE_TYPE_ROBOT) {
robotQaList = json['answers'] == null robotQaList = json['answers'] == null
@ -180,6 +185,7 @@ class Message {
} }
return Message( return Message(
mid: json['mid'], mid: json['mid'],
// topic: json['thread']['topic'],
content: json['content'], content: json['content'],
imageUrl: json['imageUrl'], imageUrl: json['imageUrl'],
voiceUrl: json['voiceUrl'], voiceUrl: json['voiceUrl'],
@ -191,6 +197,7 @@ class Message {
timestamp: json['createdAt'], timestamp: json['createdAt'],
client: json['client'], client: json['client'],
currentUid: SpUtil.getString(BytedeskConstants.uid), currentUid: SpUtil.getString(BytedeskConstants.uid),
thread: Thread.fromUnreadJson(json['thread']),
answers: robotQaList, answers: robotQaList,
answersJson: json['answers'].toString()); answersJson: json['answers'].toString());
} }

@ -236,6 +236,12 @@ class Thread extends Equatable {
unreadVisitor: json['unreadVisitor']); unreadVisitor: json['unreadVisitor']);
} }
static Thread fromUnreadJson(dynamic json) {
return Thread(
tid: json['tid'],
topic: json['topic']);
}
@override @override
List<Object> get props => [topic!]; List<Object> get props => [topic!];

@ -138,8 +138,8 @@ class _ChatKFPageState extends State<ChatKFPage>
// // 1 // // 1
// // timer.cancel(); // // timer.cancel();
}); });
BlocProvider.of<MessageBloc>(context) // BlocProvider.of<MessageBloc>(context)
..add(LoadUnreadVisitorMessagesEvent(page: 0, size: 10)); // ..add(LoadUnreadVisitorMessagesEvent(page: 0, size: 10));
} }
// //
@ -196,7 +196,10 @@ class _ChatKFPageState extends State<ChatKFPage>
}); });
// TODO: // TODO:
_getMessages(_page, _size); _getMessages(_page, _size);
// //
BlocProvider.of<MessageBloc>(context)
..add(LoadUnreadVisitorMessagesEvent(page: 0, size: 10));
//
if (state.threadResult.statusCode == 200 || if (state.threadResult.statusCode == 200 ||
state.threadResult.statusCode == 201) { state.threadResult.statusCode == 201) {
BytedeskUtils.printLog('创建新会话'); BytedeskUtils.printLog('创建新会话');
@ -385,9 +388,18 @@ class _ChatKFPageState extends State<ChatKFPage>
} }
} else if (state is LoadUnreadVisitorMessageSuccess) { } else if (state is LoadUnreadVisitorMessageSuccess) {
// //
for (var i = 0; i < state.messageList!.length; i++) { if (state.messageList!.length > 0) {
Message message = state.messageList![i]; // for (var i = 0; i < state.messageList!.length; i++) {
_appendMessage(message); for (var i = state.messageList!.length - 1; i >= 0; i--) {
Message message = state.messageList![i];
//
_messageProvider.insert(message);
//
_appendMessage(message);
//
_bdMqtt.sendReceiptReadMessage(
message.mid!, _currentThread!);
}
} }
} }
}, },
@ -1110,7 +1122,7 @@ 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 && _currentThread != null) {
// BytedeskUtils.printLog('message.mid ${message.mid}'); // BytedeskUtils.printLog('message.mid ${message.mid}');
// BytedeskUtils.printLog('_currentThread ${_currentThread!.tid}'); // BytedeskUtils.printLog('_currentThread ${_currentThread!.tid}');
_bdMqtt.sendReceiptReadMessage(message.mid!, _currentThread!); _bdMqtt.sendReceiptReadMessage(message.mid!, _currentThread!);

@ -8,17 +8,17 @@ class BytedeskConstants {
// //
// TODO: // TODO:
// debug // debug
// static const bool isDebug = true; static const bool isDebug = true;
// static const bool isSecure = false; static const bool isSecure = false;
// static const bool isWebSocketWss = false; static const bool isWebSocketWss = false;
// static const String webSocketWssUrl = 'wss://www.bytedesk.com/websocket'; static const String webSocketWssUrl = 'wss://www.bytedesk.com/websocket';
// static const String httpBaseUrl = 'http://' + mqttHost + ':8000'; static const String httpBaseUrl = 'http://' + mqttHost + ':8000';
// static const String httpBaseUrlAndroid = 'http://' + mqttHost + ':8000'; static const String httpBaseUrlAndroid = 'http://' + mqttHost + ':8000';
// static const String httpBaseUrliOS = 'http://' + mqttHost + ':8000'; static const String httpBaseUrliOS = 'http://' + mqttHost + ':8000';
// static const String httpUploadUrl = 'http://' + mqttHost + ':8000'; static const String httpUploadUrl = 'http://' + mqttHost + ':8000';
// static const String host = mqttHost + ':8000'; static const String host = mqttHost + ':8000';
// static const int mqttPort = 3883; // not secure static const int mqttPort = 3883; // not secure
// static const String mqttHost = '172.20.10.7'; static const String mqttHost = '172.16.0.78';
// //
// static const bool isDebug = true; // static const bool isDebug = true;
@ -48,17 +48,17 @@ class BytedeskConstants {
// static const String mqttHost = '192.168.0.106'; // static const String mqttHost = '192.168.0.106';
// 线 // 线
static const bool isDebug = false; // false; // static const bool isDebug = false; // false;
static const bool isSecure = true; // secure // static const bool isSecure = true; // secure
static const bool isWebSocketWss = true; // static const bool isWebSocketWss = true;
static const String webSocketWssUrl = 'wss://' + mqttHost + '/websocket'; // static const String webSocketWssUrl = 'wss://' + mqttHost + '/websocket';
static const int mqttPort = 13883; // secure // static const int mqttPort = 13883; // secure
static const String httpBaseUrl = 'https://' + mqttHost; // static const String httpBaseUrl = 'https://' + mqttHost;
static const String httpBaseUrlAndroid = 'https://' + mqttHost; // static const String httpBaseUrlAndroid = 'https://' + mqttHost;
static const String httpBaseUrliOS = 'https://' + mqttHost; // static const String httpBaseUrliOS = 'https://' + mqttHost;
static const String httpUploadUrl = 'https://upload.bytedesk.com'; // static const String httpUploadUrl = 'https://upload.bytedesk.com';
static const String host = mqttHost; // static const String host = mqttHost;
static const String mqttHost = 'flutter.bytedesk.com'; // static const String mqttHost = 'flutter.bytedesk.com';
// //
static const String WORKGROUP_WID_LIANGSHIBAO = '201808101819291'; static const String WORKGROUP_WID_LIANGSHIBAO = '201808101819291';

@ -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.3.2 version: 1.3.3
homepage: https://www.weikefu.net homepage: https://www.weikefu.net
environment: environment:

Loading…
Cancel
Save