master
jack ning 3 years ago
parent 6771eb9950
commit e92afc3bd4

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

@ -1,5 +1,9 @@
# Upgrade Log
## 1.3.2
* optimize user experience
## 1.3.1
* optimize user experience

@ -41,8 +41,9 @@ class _HistoryThreadPageState extends State<HistoryThreadPage> {
subtitle: Text('${_historyThreadList[index].content}'),
onTap: () {
//
BytedeskKefu.startChatThread(
context, _historyThreadList[index]);
// BytedeskKefu.startChatThread(
// context, _historyThreadList[index]);
BytedeskKefu.startChatThreadIM(context, _historyThreadList[index]);
},
),
itemCount: _historyThreadList.length,

@ -2,6 +2,7 @@
import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/blocs/contact_bloc/bloc.dart';
import 'package:bytedesk_kefu/repositories/contact_repository.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
class ContactBloc extends Bloc<ContactEvent, ContactState> {
final ContactRepository contactRepository = new ContactRepository();
@ -27,7 +28,7 @@ class ContactBloc extends Bloc<ContactEvent, ContactState> {
// final List<Contact> contactList = await contactRepository.getContacts();
// yield ContactLoadSuccess(contactList);
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ContactLoadError());
}
}

@ -2,6 +2,7 @@
import 'package:bytedesk_kefu/blocs/feedback_bloc/bloc.dart';
import 'package:bytedesk_kefu/model/helpCategory.dart';
// import 'package:bytedesk_kefu/model/jsonResult.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:bytedesk_kefu/repositories/feedback_repository.dart';
import 'package:bloc/bloc.dart';
@ -36,7 +37,7 @@ class FeedbackBloc extends Bloc<FeedbackEvent, FeedbackState> {
await feedbackRepository.getHelpFeedbackCategories(event.uid);
emit(FeedbackCategoryState(categoryList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(FeedbackLoadError());
}
}
@ -48,18 +49,19 @@ class FeedbackBloc extends Bloc<FeedbackEvent, FeedbackState> {
await feedbackRepository.submitFeedback(event.content, event.imageUrls);
emit(FeedbackSubmitSuccess());
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(FeedbackSubmitError());
}
}
void _mapUploadImageToState(UploadImageEvent event, Emitter<FeedbackState> emit) async {
void _mapUploadImageToState(
UploadImageEvent event, Emitter<FeedbackState> emit) async {
emit(ImageUploading());
try {
final String url = await feedbackRepository.upload(event.filePath);
emit(UploadImageSuccess(url));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}

@ -2,6 +2,7 @@
import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/blocs/friend_bloc/bloc.dart';
import 'package:bytedesk_kefu/model/friend.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:bytedesk_kefu/repositories/friend_repository.dart';
class FriendBloc extends Bloc<FriendEvent, FriendState> {
@ -31,14 +32,15 @@ class FriendBloc extends Bloc<FriendEvent, FriendState> {
// }
// }
void _mapQueryFriendToState(QueryFriendEvent event, Emitter<FriendState> emit) async {
void _mapQueryFriendToState(
QueryFriendEvent event, Emitter<FriendState> emit) async {
emit(FriendLoading());
try {
final List<Friend> friendList =
await friendRepository.getFriends(event.page, event.size);
emit(FriendLoadSuccess(friendList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ErrorFriendState('friend error'));
}
}
@ -51,7 +53,7 @@ class FriendBloc extends Bloc<FriendEvent, FriendState> {
await friendRepository.getFriendsAddress(event.page, event.size);
emit(FriendLoadSuccess(friendList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ErrorFriendState('friend error'));
}
}
@ -64,7 +66,7 @@ class FriendBloc extends Bloc<FriendEvent, FriendState> {
await friendRepository.uploadAddress(event.nickname, event.mobile);
emit(FriendCreateSuccess(friend: friend));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ErrorFriendState('friend error'));
}
}
@ -77,7 +79,7 @@ class FriendBloc extends Bloc<FriendEvent, FriendState> {
await friendRepository.getFriendsNearby(event.page, event.size);
emit(FriendLoadSuccess(friendList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ErrorFriendState('friend error'));
}
}
@ -89,7 +91,7 @@ class FriendBloc extends Bloc<FriendEvent, FriendState> {
await friendRepository.updateLocation(event.latitude, event.longtitude);
emit(FriendUpdateSuccess());
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ErrorFriendState('friend error'));
}
}

@ -3,6 +3,7 @@ import 'package:bytedesk_kefu/blocs/help_bloc/bloc.dart';
import 'package:bytedesk_kefu/model/helpArticle.dart';
import 'package:bytedesk_kefu/model/helpCategory.dart';
import 'package:bytedesk_kefu/repositories/help_repository.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:bloc/bloc.dart';
class HelpBloc extends Bloc<HelpEvent, HelpState> {
@ -31,7 +32,7 @@ class HelpBloc extends Bloc<HelpEvent, HelpState> {
await helpRepository.getHelpCategories(event.uid);
emit(HelpCategoryState(categoryList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(HelpLoadError());
}
}
@ -44,7 +45,7 @@ class HelpBloc extends Bloc<HelpEvent, HelpState> {
await helpRepository.getCategoryArticles(event.categoryId);
emit(HelpArticleState(categoryList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(HelpLoadError());
}
}

@ -2,6 +2,7 @@
import 'package:bytedesk_kefu/blocs/leavemsg_bloc/bloc.dart';
import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/repositories/leavemsg_repository.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
class LeaveMsgBloc extends Bloc<LeaveMsgEvent, LeaveMsgState> {
//
@ -27,21 +28,23 @@ class LeaveMsgBloc extends Bloc<LeaveMsgEvent, LeaveMsgState> {
SubmitLeaveMsgEvent event, Emitter<LeaveMsgState> emit) async {
emit(LeaveMsgSubmiting());
try {
await leaveMsgRepository.submitLeaveMsg(event.wid, event.aid, event.type, event.mobile, event.email, event.content);
await leaveMsgRepository.submitLeaveMsg(event.wid, event.aid, event.type,
event.mobile, event.email, event.content);
emit(LeaveMsgSubmitSuccessState());
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(LeaveMsgSubmitError());
}
}
void _mapUploadImageToState(UploadImageEvent event, Emitter<LeaveMsgState> emit) async {
void _mapUploadImageToState(
UploadImageEvent event, Emitter<LeaveMsgState> emit) async {
emit(ImageUploading());
try {
final String url = await leaveMsgRepository.upload(event.filePath);
emit(UploadImageSuccess(url));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}

@ -5,6 +5,7 @@ import 'package:bytedesk_kefu/model/requestAnswer.dart';
import 'package:bytedesk_kefu/model/requestCategory.dart';
import 'package:bytedesk_kefu/model/uploadJsonResult.dart';
import 'package:bytedesk_kefu/repositories/message_repository.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:bloc/bloc.dart';
import './bloc.dart';
@ -18,6 +19,9 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
on<UploadVideoEvent>(_mapUploadVideoToState);
on<SendMessageRestEvent>(_mapSendMessageRestToState);
on<LoadHistoryMessageEvent>(_mapLoadHistoryMessageToState);
on<LoadUnreadMessagesEvent>(_mapLoadUnreadMessageToState);
on<LoadUnreadVisitorMessagesEvent>(_mapLoadUnreadVisitorMessageToState);
on<LoadUnreadAgentMessagesEvent>(_mapLoadUnreadAgentMessageToState);
on<LoadTopicMessageEvent>(_mapLoadTopicMessageToState);
on<LoadChannelMessageEvent>(_mapLoadChannelMessageToState);
@ -52,95 +56,143 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
// }
// }
void _mapRefreshCourseToState(ReceiveMessageEvent event, Emitter<MessageState> emit) async {
void _mapRefreshCourseToState(
ReceiveMessageEvent event, Emitter<MessageState> emit) async {
try {
emit(ReceiveMessageState(message: event.message));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
}
}
void _mapUploadImageToState(UploadImageEvent event, Emitter<MessageState> emit) async {
void _mapUploadImageToState(
UploadImageEvent event, Emitter<MessageState> emit) async {
emit(MessageUpLoading());
try {
final UploadJsonResult uploadJsonResult =
await messageRepository.uploadImage(event.filePath);
emit(UploadImageSuccess(uploadJsonResult));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUploadVideoToState(UploadVideoEvent event, Emitter<MessageState> emit) async {
void _mapUploadVideoToState(
UploadVideoEvent event, Emitter<MessageState> emit) async {
emit(MessageUpLoading());
try {
final UploadJsonResult uploadJsonResult =
await messageRepository.uploadVideo(event.filePath);
emit(UploadVideoSuccess(uploadJsonResult));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapSendMessageRestToState(SendMessageRestEvent event, Emitter<MessageState> emit) async {
void _mapSendMessageRestToState(
SendMessageRestEvent event, Emitter<MessageState> emit) async {
emit(RestMessageSending());
try {
final JsonResult jsonResult =
await messageRepository.sendMessageRest(event.json);
emit(SendMessageRestSuccess(jsonResult));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(SendMessageRestError());
}
}
void _mapLoadHistoryMessageToState(LoadHistoryMessageEvent event, Emitter<MessageState> emit) async {
void _mapLoadHistoryMessageToState(
LoadHistoryMessageEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final List<Message> messageList = await messageRepository
.loadHistoryMessages(event.uid, event.page, event.size);
emit(LoadHistoryMessageSuccess(messageList: messageList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(LoadHistoryMessageError());
}
}
void _mapLoadTopicMessageToState(LoadTopicMessageEvent event, Emitter<MessageState> emit) async {
void _mapLoadTopicMessageToState(
LoadTopicMessageEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final List<Message> messageList = await messageRepository
.loadTopicMessages(event.topic, event.page, event.size);
emit(LoadTopicMessageSuccess(messageList: messageList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(LoadTopicMessageError());
}
}
void _mapLoadChannelMessageToState(LoadChannelMessageEvent event, Emitter<MessageState> emit) async {
void _mapLoadChannelMessageToState(
LoadChannelMessageEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final List<Message> messageList = await messageRepository
.loadChannelMessages(event.cid, event.page, event.size);
emit(LoadChannelMessageSuccess(messageList: messageList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(LoadChannelMessageError());
}
}
void _mapQueryAnswerToState(QueryAnswerEvent event, Emitter<MessageState> emit) async {
void _mapLoadUnreadMessageToState(
LoadUnreadMessagesEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final List<Message> messageList = await messageRepository
.loadUnreadMessages(event.wid, event.page, event.size);
emit(LoadUnreadMessageSuccess(messageList: messageList));
} catch (error) {
BytedeskUtils.printLog(error);
emit(LoadUnreadMessageError());
}
}
void _mapLoadUnreadVisitorMessageToState(
LoadUnreadVisitorMessagesEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final List<Message> messageList = await messageRepository
.loadUnreadVisitorMessages(event.page, event.size);
emit(LoadUnreadVisitorMessageSuccess(messageList: messageList));
} catch (error) {
BytedeskUtils.printLog(error);
emit(LoadUnreadMessageError());
}
}
void _mapLoadUnreadAgentMessageToState(
LoadUnreadAgentMessagesEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final List<Message> messageList = await messageRepository
.loadUnreadAgentMessages(event.page, event.size);
emit(LoadUnreadAgentMessageSuccess(messageList: messageList));
} catch (error) {
BytedeskUtils.printLog(error);
emit(LoadUnreadAgentMessageError());
}
}
void _mapQueryAnswerToState(
QueryAnswerEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final RequestAnswerResult requestAnswerResult =
await messageRepository.queryAnswer(event.tid, event.aid, event.mid);
emit(QueryAnswerSuccess(
query: requestAnswerResult.query, answer: requestAnswerResult.anwser));
query: requestAnswerResult.query,
answer: requestAnswerResult.anwser));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
@ -155,32 +207,35 @@ class MessageBloc extends Bloc<MessageEvent, MessageState> {
query: requestAnswerResult.query,
answer: requestAnswerResult.anwser));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapMessageAnswerToState(MessageAnswerEvent event, Emitter<MessageState> emit) async {
void _mapMessageAnswerToState(
MessageAnswerEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final RequestAnswerResult requestAnswerResult = await messageRepository
.messageAnswer(event.wid, event.content);
final RequestAnswerResult requestAnswerResult =
await messageRepository.messageAnswer(event.wid, event.content);
emit(MessageAnswerSuccess(
query: requestAnswerResult.query, answer: requestAnswerResult.anwser));
query: requestAnswerResult.query,
answer: requestAnswerResult.anwser));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapRateAnswerToState(RateAnswerEvent event, Emitter<MessageState> emit) async {
void _mapRateAnswerToState(
RateAnswerEvent event, Emitter<MessageState> emit) async {
emit(MessageLoading());
try {
final RequestAnswerResult requestAnswerResult =
await messageRepository.rateAnswer(event.aid, event.mid, event.rate);
emit(RateAnswerSuccess(result: requestAnswerResult.anwser));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}

@ -64,6 +64,33 @@ class LoadChannelMessageEvent extends MessageEvent {
: super();
}
class LoadUnreadMessagesEvent extends MessageEvent {
final String? wid;
final int? page;
final int? size;
LoadUnreadMessagesEvent(
{@required this.wid, @required this.page, @required this.size})
: super();
}
class LoadUnreadVisitorMessagesEvent extends MessageEvent {
final int? page;
final int? size;
LoadUnreadVisitorMessagesEvent(
{@required this.page, @required this.size})
: super();
}
class LoadUnreadAgentMessagesEvent extends MessageEvent {
final int? page;
final int? size;
LoadUnreadAgentMessagesEvent({@required this.page, @required this.size})
: super();
}
class QueryAnswerEvent extends MessageEvent {
final String? tid;
final String? aid;

@ -84,6 +84,21 @@ class LoadChannelMessageError extends MessageState {
String toString() => 'LoadChannelMessageError';
}
class LoadUnreadMessageError extends MessageState {
@override
String toString() => 'LoadUnreadMessageError';
}
class LoadUnreadVisitorMessageError extends MessageState {
@override
String toString() => 'LoadUnreadVisitorMessageError';
}
class LoadUnreadAgentMessageError extends MessageState {
@override
String toString() => 'LoadUnreadAgentMessageError';
}
class UploadVideoSuccess extends MessageState {
final UploadJsonResult uploadJsonResult;
@ -119,6 +134,24 @@ class LoadChannelMessageSuccess extends MessageState {
LoadChannelMessageSuccess({@required this.messageList}) : super();
}
class LoadUnreadMessageSuccess extends MessageState {
final List<Message>? messageList;
LoadUnreadMessageSuccess({@required this.messageList}) : super();
}
class LoadUnreadVisitorMessageSuccess extends MessageState {
final List<Message>? messageList;
LoadUnreadVisitorMessageSuccess({@required this.messageList}) : super();
}
class LoadUnreadAgentMessageSuccess extends MessageState {
final List<Message>? messageList;
LoadUnreadAgentMessageSuccess({@required this.messageList}) : super();
}
class QueryAnswerSuccess extends MessageState {
final Message? query;
final Message? answer;

@ -3,6 +3,7 @@ import 'package:bytedesk_kefu/model/jsonResult.dart';
import 'package:bytedesk_kefu/model/user.dart';
import 'package:bytedesk_kefu/repositories/user_repository.dart';
import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import './bloc.dart';
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
@ -24,7 +25,6 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
on<UserFollowEvent>(_mapUserFollowToState);
on<UserUnfollowEvent>(_mapUserUnfollowToState);
}
// @override
@ -57,7 +57,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
// }
// }
void _mapProfileState(GetProfileEvent event, Emitter<ProfileState> emit) async {
void _mapProfileState(
GetProfileEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
User user = await userRepository.getProfile();
@ -68,124 +69,135 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
}
}
void _mapUploadImageToState(UploadImageEvent event, Emitter<ProfileState> emit) async {
void _mapUploadImageToState(
UploadImageEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final String url = await userRepository.upload(event.filePath);
emit(UploadImageSuccess(url));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUpdateAvatarToState(UpdateAvatarEvent event, Emitter<ProfileState> emit) async {
void _mapUpdateAvatarToState(
UpdateAvatarEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final User user = await userRepository.updateAvatar(event.avatar);
emit(UpdateAvatarSuccess(user));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUpdateNicknameToState(UpdateNicknameEvent event, Emitter<ProfileState> emit) async {
void _mapUpdateNicknameToState(
UpdateNicknameEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final User user = await userRepository.updateNickname(event.nickname);
emit(UpdateNicknameSuccess(user));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUpdateDescriptionToState(UpdateDescriptionEvent event, Emitter<ProfileState> emit) async {
void _mapUpdateDescriptionToState(
UpdateDescriptionEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final User user =
await userRepository.updateDescription(event.description);
emit(UpdateDescriptionSuccess(user));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUpdateMobileToState(UpdateMobileEvent event, Emitter<ProfileState> emit) async {
void _mapUpdateMobileToState(
UpdateMobileEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final User user = await userRepository.updateMobile(event.mobile);
emit(UpdateMobileSuccess(user));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUpdateSexToState(UpdateSexEvent event, Emitter<ProfileState> emit) async {
void _mapUpdateSexToState(
UpdateSexEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final User user = await userRepository.updateSex(event.sex);
emit(UpdateSexSuccess(user));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUpdateLocationToState(UpdateLocationEvent event, Emitter<ProfileState> emit) async {
void _mapUpdateLocationToState(
UpdateLocationEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final User user = await userRepository.updateLocation(event.location);
emit(UpdateLocationSuccess(user));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapUpdateBirthdayToState(UpdateBirthdayEvent event, Emitter<ProfileState> emit) async {
void _mapUpdateBirthdayToState(
UpdateBirthdayEvent event, Emitter<ProfileState> emit) async {
emit(ProfileInProgress());
try {
final User user = await userRepository.updateBirthday(event.birthday);
emit(UpdateBirthdaySuccess(user));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}
void _mapQueryFollowToState(QueryFollowEvent event, Emitter<ProfileState> emit) async {
void _mapQueryFollowToState(
QueryFollowEvent event, Emitter<ProfileState> emit) async {
emit(QueryFollowing());
try {
final bool isFollowed = await userRepository.isFollowed(event.uid);
emit(QueryFollowSuccess(isFollowed));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(QueryFollowError());
}
}
void _mapUserFollowToState(UserFollowEvent event, Emitter<ProfileState> emit) async {
void _mapUserFollowToState(
UserFollowEvent event, Emitter<ProfileState> emit) async {
emit(Following());
try {
final JsonResult jsonResult = await userRepository.follow(event.uid);
emit(FollowResultSuccess(jsonResult));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(FollowError());
}
}
void _mapUserUnfollowToState(UserUnfollowEvent event, Emitter<ProfileState> emit) async {
void _mapUserUnfollowToState(
UserUnfollowEvent event, Emitter<ProfileState> emit) async {
emit(Following());
try {
final JsonResult jsonResult = await userRepository.unfollow(event.uid);
emit(UnfollowResultSuccess(jsonResult));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UnFollowError());
}
}

@ -4,6 +4,7 @@ import 'package:bloc/bloc.dart';
import './bloc.dart';
import 'package:bytedesk_kefu/repositories/repositories.dart';
import 'package:bytedesk_kefu/model/model.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
//
@ -39,7 +40,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
final List<Thread> threadList = await threadRepository.getThreads();
emit(ThreadLoadSuccess(threadList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -52,7 +53,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.getHistoryThreads(event.page, event.size);
emit(ThreadLoadSuccess(threadList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -65,7 +66,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.getVisitorThreads(event.page, event.size);
emit(ThreadLoadSuccess(threadList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -78,7 +79,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.getVisitorThreadsAll();
emit(ThreadLoadSuccess(threadList));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -91,7 +92,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
event.wid, event.type, event.aid, event.isV2Robot);
emit(RequestThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(RequestThreadError());
}
}
@ -104,7 +105,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.requestAgent(event.wid, event.type, event.aid);
emit(RequestAgentSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(RequestAgentThreadError());
}
}
@ -117,7 +118,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.requestContactThread(event.cid);
emit(RequestContactThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -130,7 +131,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.requestGroupThread(event.gid);
emit(RequestGroupThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -142,7 +143,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
final MarkThreadResult thread = await threadRepository.markTop(event.tid);
emit(MarkTopThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -155,7 +156,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.unmarkTop(event.tid);
emit(UnMarkTopThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -168,7 +169,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.markNodisturb(event.tid);
emit(MarkNodisturbThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -181,7 +182,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.unmarkNodisturb(event.tid);
emit(UnMarkNodisturbThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -194,7 +195,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.markUnread(event.tid);
emit(MarkUnreadThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -207,7 +208,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
await threadRepository.unmarkUnread(event.tid);
emit(UnMarkUnreadThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}
@ -219,7 +220,7 @@ class ThreadBloc extends Bloc<ThreadEvent, ThreadState> {
final MarkThreadResult thread = await threadRepository.delete(event.tid);
emit(DeleteThreadSuccess(thread));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(ThreadLoadError());
}
}

@ -1,6 +1,7 @@
// import 'dart:async';
import 'package:bytedesk_kefu/blocs/ticket_bloc/bloc.dart';
import 'package:bloc/bloc.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:bytedesk_kefu/repositories/ticket_repository.dart';
class TicketBloc extends Bloc<TicketEvent, TicketState> {
@ -26,37 +27,40 @@ class TicketBloc extends Bloc<TicketEvent, TicketState> {
// }
// }
void _mapGetTicketCategoryToState(GetTicketCategoryEvent event, Emitter<TicketState> emit) async {
void _mapGetTicketCategoryToState(
GetTicketCategoryEvent event, Emitter<TicketState> emit) async {
emit(TicketLoading());
try {
// final List<HelpCategory> categoryList =
// await feedbackRepository.getHelpTicketCategories();
// emit(TicketCategoryState(categoryList);
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(TicketLoadError());
}
}
void _mapSubmitTicketToState(SubmitTicketEvent event, Emitter<TicketState> emit) async {
void _mapSubmitTicketToState(
SubmitTicketEvent event, Emitter<TicketState> emit) async {
emit(TicketLoading());
try {
// final List<HelpCategory> categoryList =
// await feedbackRepository.getHelpTicketCategories();
// emit(TicketCategoryState(categoryList);
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(TicketLoadError());
}
}
void _mapUploadImageToState(UploadImageEvent event, Emitter<TicketState> emit) async {
void _mapUploadImageToState(
UploadImageEvent event, Emitter<TicketState> emit) async {
emit(TicketLoading());
try {
final String url = await feedbackRepository.upload(event.filePath);
emit(UploadImageSuccess(url));
} catch (error) {
print(error);
BytedeskUtils.printLog(error);
emit(UpLoadImageError());
}
}

@ -4,6 +4,7 @@ import 'package:bytedesk_kefu/http/bytedesk_base_api.dart';
import 'package:bytedesk_kefu/model/helpArticle.dart';
import 'package:bytedesk_kefu/model/helpCategory.dart';
import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
class BytedeskFaqHttpApi extends BytedeskBaseHttpApi {
//
@ -12,7 +13,7 @@ class BytedeskFaqHttpApi extends BytedeskBaseHttpApi {
//
final categoriesUrl = Uri.http(BytedeskConstants.host,
'/visitor/api/category/support', {'uid': uid, 'client': client});
print("categories Url $categoriesUrl");
BytedeskUtils.printLog("categories Url $categoriesUrl");
final initResponse = await this.httpClient.get(categoriesUrl);
//
//json
@ -20,7 +21,7 @@ class BytedeskFaqHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
//
List<HelpCategory> categories = (responseJson['data'] as List<dynamic>)
.map((item) => HelpCategory.fromJson(item))
@ -38,7 +39,7 @@ class BytedeskFaqHttpApi extends BytedeskBaseHttpApi {
BytedeskConstants.host,
'/visitor/api/category/articles',
{'categoryId': categoryId, 'client': client});
print("categories Url $categoriesUrl");
BytedeskUtils.printLog("categories Url $categoriesUrl");
final initResponse = await this.httpClient.get(categoriesUrl);
//
//json
@ -46,7 +47,7 @@ class BytedeskFaqHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
//
List<HelpArticle> articles = (responseJson['data'] as List<dynamic>)
.map((item) => HelpArticle.fromJson(item))

@ -5,6 +5,7 @@ import 'package:bytedesk_kefu/model/helpCategory.dart';
import 'package:bytedesk_kefu/model/jsonResult.dart';
import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_events.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:sp_util/sp_util.dart';
import 'package:http/http.dart' as http;
@ -17,7 +18,7 @@ class BytedeskFeedbackHttpApi extends BytedeskBaseHttpApi {
// '$baseUrl/visitor/api/category/feedback?uid=$uid&client=$client';
final categoriesUrl = Uri.http(BytedeskConstants.host,
'/visitor/api/category/feedback', {'uid': uid, 'client': client});
print("categories Url $categoriesUrl");
BytedeskUtils.printLog("categories Url $categoriesUrl");
final initResponse = await this.httpClient.get(categoriesUrl);
//
//json
@ -25,7 +26,7 @@ class BytedeskFeedbackHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
//
List<HelpCategory> categories = (responseJson['data'] as List<dynamic>)
.map((item) => HelpCategory.fromJson(item))
@ -49,7 +50,7 @@ class BytedeskFeedbackHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -65,7 +66,8 @@ class BytedeskFeedbackHttpApi extends BytedeskBaseHttpApi {
String? username = SpUtil.getString(BytedeskConstants.uid);
final uploadUrl = '$baseUrl/visitor/api/upload/image';
print("fileName $fileName, username $username, upload Url $uploadUrl");
BytedeskUtils.printLog(
"fileName $fileName, username $username, upload Url $uploadUrl");
var uri = Uri.parse(uploadUrl);
var request = http.MultipartRequest('POST', uri)
@ -75,16 +77,16 @@ class BytedeskFeedbackHttpApi extends BytedeskBaseHttpApi {
http.Response response =
await http.Response.fromStream(await request.send());
// print("Result: ${response.body}");
// BytedeskUtils.printLog("Result: ${response.body}");
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson = json.decode(utf8decoder.convert(response.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
String url = responseJson['data'];
print('url:' + url);
BytedeskUtils.printLog('url:' + url);
return url;
}
}

@ -14,7 +14,7 @@ class BytedeskFriendHttpApi extends BytedeskBaseHttpApi {
// '$baseUrl/api/friend/query?page=$page&size=$size&client=$client';
final friendsUrl = Uri.http(BytedeskConstants.host, '/api/friend/query',
{'page': page.toString(), 'size': size.toString(), 'client': client});
print("get friends Url $friendsUrl");
BytedeskUtils.printLog("get friends Url $friendsUrl");
final initResponse =
await this.httpClient.get(friendsUrl, headers: getHeaders());
@ -23,7 +23,7 @@ class BytedeskFriendHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -45,7 +45,7 @@ class BytedeskFriendHttpApi extends BytedeskBaseHttpApi {
BytedeskConstants.host,
'/api/friend/address/query',
{'page': page.toString(), 'size': size.toString(), 'client': client});
print("address Url $addressUrl");
BytedeskUtils.printLog("address Url $addressUrl");
final initResponse =
await this.httpClient.get(addressUrl, headers: getHeaders());
@ -54,7 +54,7 @@ class BytedeskFriendHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -83,7 +83,7 @@ class BytedeskFriendHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -108,7 +108,7 @@ class BytedeskFriendHttpApi extends BytedeskBaseHttpApi {
'size': size.toString(),
'client': client
});
print("address Url $addressUrl");
BytedeskUtils.printLog("address Url $addressUrl");
final initResponse =
await this.httpClient.get(addressUrl, headers: getHeaders());
@ -117,7 +117,7 @@ class BytedeskFriendHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());

@ -5,7 +5,7 @@ import 'package:bytedesk_kefu/model/helpCategory.dart';
import 'package:bytedesk_kefu/model/jsonResult.dart';
import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_events.dart';
// import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:http/http.dart' as http;
import 'package:sp_util/sp_util.dart';
@ -17,7 +17,7 @@ class BytedeskLeaveMsgHttpApi extends BytedeskBaseHttpApi {
// '$baseUrl/visitor/api/category/feedback?uid=$uid&client=$client';
final categoriesUrl = Uri.http(BytedeskConstants.host,
'/visitor/api/category/feedback', {'uid': uid, 'client': client});
print("categories Url $categoriesUrl");
BytedeskUtils.printLog("categories Url $categoriesUrl");
final initResponse = await this.httpClient.get(categoriesUrl);
//
//json
@ -37,7 +37,15 @@ class BytedeskLeaveMsgHttpApi extends BytedeskBaseHttpApi {
Future<JsonResult> submitLeaveMsg(String? wid, String? aid, String? type,
String? mobile, String? email, String? content) async {
//
var body = json.encode({"wid": wid, "aid": aid, "type": type, "mobile": mobile, "email": email,"content": content, "client": client});
var body = json.encode({
"wid": wid,
"aid": aid,
"type": type,
"mobile": mobile,
"email": email,
"content": content,
"client": client
});
final initUrl = Uri.http(BytedeskConstants.host, '/api/leavemsg/save');
final initResponse =
await this.httpClient.post(initUrl, headers: getHeaders(), body: body);
@ -46,8 +54,8 @@ class BytedeskLeaveMsgHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("submitLeaveMsg:");
print(responseJson);
BytedeskUtils.printLog("submitLeaveMsg:");
BytedeskUtils.printLog(responseJson);
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -63,7 +71,8 @@ class BytedeskLeaveMsgHttpApi extends BytedeskBaseHttpApi {
String? username = SpUtil.getString(BytedeskConstants.uid);
final uploadUrl = '$baseUrl/visitor/api/upload/image';
print("fileName $fileName, username $username, upload Url $uploadUrl");
BytedeskUtils.printLog(
"fileName $fileName, username $username, upload Url $uploadUrl");
var uri = Uri.parse(uploadUrl);
var request = http.MultipartRequest('POST', uri)
@ -73,16 +82,16 @@ class BytedeskLeaveMsgHttpApi extends BytedeskBaseHttpApi {
http.Response response =
await http.Response.fromStream(await request.send());
// print("Result: ${response.body}");
// BytedeskUtils.printLog("Result: ${response.body}");
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson = json.decode(utf8decoder.convert(response.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
String url = responseJson['data'];
print('url:' + url);
BytedeskUtils.printLog('url:' + url);
return url;
}
}

@ -9,6 +9,7 @@ import 'package:bytedesk_kefu/model/requestCategory.dart';
import 'package:bytedesk_kefu/model/uploadJsonResult.dart';
import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_events.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:sp_util/sp_util.dart';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
@ -30,7 +31,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(sendMessageResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -49,7 +50,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
'uid': uid,
'client': client
});
// print("loadHistoryMessages Url $loadHistoryMessages");
// BytedeskUtils.printLog("loadHistoryMessages Url $loadHistoryMessages");
final initResponse = await this
.httpClient
.get(loadHistoryMessagesUrl, headers: getHeaders());
@ -75,8 +76,6 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
Future<List<Message>> loadTopicMessages(
String? topic, int? page, int? size) async {
//
// final loadTopicMessagesUrl =
// '$baseUrl/api/messages/topic?topic=$topic&page=$page&size=$size&client=$client';
final loadTopicMessagesUrl =
Uri.http(BytedeskConstants.host, '/api/messages/topic', {
'page': page.toString(),
@ -84,7 +83,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
'topic': topic,
'client': client
});
// print("loadHistoryMessages Url $loadHistoryMessages");
// BytedeskUtils.printLog("loadHistoryMessages Url $loadHistoryMessages");
final initResponse =
await this.httpClient.get(loadTopicMessagesUrl, headers: getHeaders());
//
@ -118,7 +117,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
'cid': cid,
'client': client
});
// print("loadChannelMessagesUrl Url $loadHistoryMessages");
// BytedeskUtils.printLog("loadChannelMessagesUrl Url $loadHistoryMessages");
final initResponse = await this
.httpClient
.get(loadChannelMessagesUrl, headers: getHeaders());
@ -141,12 +140,108 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
return messageList;
}
/// -wid
/// widid
/// 访
Future<List<Message>> loadUnreadMessages(
String? wid, int? page, int? size) async {
//
final loadUnreadMessagesUrl = Uri.http(
BytedeskConstants.host, '/api/messages/unread/message', {
'page': page.toString(),
'size': size.toString(),
'wid': wid,
'client': client
});
// BytedeskUtils.printLog("loadHistoryMessages Url $loadHistoryMessages");
final initResponse = await this
.httpClient
.get(loadUnreadMessagesUrl, headers: getHeaders());
//
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
}
//
List<Message> messageList =
(responseJson['data']['content'] as List<dynamic>)
.map((item) => Message.fromJson(item))
.toList();
return messageList;
}
// 访-访
Future<List<Message>> loadUnreadMessagesVisitor(int? page, int? size) async {
//
final loadUnreadMessagesUrl = Uri.http(
BytedeskConstants.host, '/api/messages/unread/message/visitor', {
'page': page.toString(),
'size': size.toString(),
'client': client
});
// BytedeskUtils.printLog("loadHistoryMessages Url $loadHistoryMessages");
final initResponse =
await this.httpClient.get(loadUnreadMessagesUrl, headers: getHeaders());
//
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
}
//
List<Message> messageList =
(responseJson['data']['content'] as List<dynamic>)
.map((item) => Message.fromJson(item))
.toList();
return messageList;
}
// -
Future<List<Message>> loadUnreadMessagesAgent(int? page, int? size) async {
//
final loadUnreadMessagesAgentUrl = Uri.http(
BytedeskConstants.host,
'/api/messages/unread/message/agent',
{'page': page.toString(), 'size': size.toString(), 'client': client});
// BytedeskUtils.printLog("loadHistoryMessages Url $loadHistoryMessages");
final initResponse =
await this.httpClient.get(loadUnreadMessagesAgentUrl, headers: getHeaders());
//
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
}
//
List<Message> messageList =
(responseJson['data']['content'] as List<dynamic>)
.map((item) => Message.fromJson(item))
.toList();
return messageList;
}
//
Future<RequestAnswerResult> queryAnswer(String? tid, String? aid) async {
//
final queryAnswerUrl = Uri.http(BytedeskConstants.host, '/api/answer/query',
{'tid': tid, 'aid': aid, 'client': client});
print("query Url $queryAnswerUrl");
BytedeskUtils.printLog("query Url $queryAnswerUrl");
final initResponse =
await this.httpClient.get(queryAnswerUrl, headers: getHeaders());
//
@ -171,7 +266,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
BytedeskConstants.host,
'/api/v2/answer/query',
{'tid': tid, 'aid': aid, 'mid': mid, 'client': client});
print("query Url $queryAnswerUrl");
BytedeskUtils.printLog("query Url $queryAnswerUrl");
final initResponse =
await this.httpClient.get(queryAnswerUrl, headers: getHeaders());
//
@ -189,14 +284,11 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
}
//
Future<RequestCategoryResult> queryCategory(
String? tid, String? cid) async {
Future<RequestCategoryResult> queryCategory(String? tid, String? cid) async {
//
final queryCategoryUrl = Uri.http(
BytedeskConstants.host,
'/api/v2/answer/category',
{'tid': tid, 'cid': cid, 'client': client});
print("query Url $queryCategoryUrl");
final queryCategoryUrl = Uri.http(BytedeskConstants.host,
'/api/v2/answer/category', {'tid': tid, 'cid': cid, 'client': client});
BytedeskUtils.printLog("query Url $queryCategoryUrl");
final initResponse =
await this.httpClient.get(queryCategoryUrl, headers: getHeaders());
//
@ -225,7 +317,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
'content': content,
'client': client
});
print("message Url $messageAnswerUrl");
BytedeskUtils.printLog("message Url $messageAnswerUrl");
final initResponse =
await this.httpClient.get(messageAnswerUrl, headers: getHeaders());
//
@ -234,8 +326,8 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("messageAnswer:");
print(responseJson);
BytedeskUtils.printLog("messageAnswer:");
BytedeskUtils.printLog(responseJson);
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -252,7 +344,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
// '$baseUrl/api/answer/rate?aid=$aid&mid=$mid&rate=$rate&client=$client';
final rateAnswerUrl = Uri.http(BytedeskConstants.host, '/api/answer/rate',
{'aid': aid, 'mid': mid, 'rate': rate, 'client': client});
print("rate Url $rateAnswerUrl");
BytedeskUtils.printLog("rate Url $rateAnswerUrl");
final initResponse =
await this.httpClient.get(rateAnswerUrl, headers: getHeaders());
//
@ -277,7 +369,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
final uploadUrl =
'${BytedeskConstants.httpUploadUrl}/visitor/api/upload/image';
print(
BytedeskUtils.printLog(
"uploadImage fileName $fileName, username $username, upload Url $uploadUrl");
var uri = Uri.parse(uploadUrl);
@ -288,13 +380,13 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
http.Response response =
await http.Response.fromStream(await request.send());
// print("Result: ${response.body}");
// BytedeskUtils.printLog("Result: ${response.body}");
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson = json.decode(utf8decoder.convert(response.bodyBytes));
print("upload image responseJson $responseJson");
BytedeskUtils.printLog("upload image responseJson $responseJson");
//
return UploadJsonResult.fromJson(responseJson);
}
@ -306,7 +398,7 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
String? username = SpUtil.getString(BytedeskConstants.uid);
final uploadUrl =
'${BytedeskConstants.httpUploadUrl}/visitor/api/upload/video';
print(
BytedeskUtils.printLog(
"uploadVideo fileName $fileName, username $username, upload Url $uploadUrl");
//
Map<String, String> headers = {
@ -323,13 +415,13 @@ class BytedeskMessageHttpApi extends BytedeskBaseHttpApi {
http.Response response =
await http.Response.fromStream(await request.send());
// print("Result: ${response.body}");
// BytedeskUtils.printLog("Result: ${response.body}");
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson = json.decode(utf8decoder.convert(response.bodyBytes));
print("upload Video responseJson $responseJson");
BytedeskUtils.printLog("upload Video responseJson $responseJson");
//
return UploadJsonResult.fromJson(responseJson);
}

@ -7,6 +7,7 @@ import 'package:bytedesk_kefu/model/requestThread.dart';
import 'package:bytedesk_kefu/model/thread.dart';
import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_events.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:sp_util/sp_util.dart';
class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
@ -16,7 +17,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
// final threadUrl = '$baseUrl/api/thread/get?client=$client';
final threadUrl =
Uri.http(BytedeskConstants.host, '/api/thread/get', {'client': client});
// print("thread Url $threadUrl");
// BytedeskUtils.printLog("thread Url $threadUrl");
final initResponse =
await this.httpClient.get(threadUrl, headers: getHeaders());
@ -25,7 +26,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -63,7 +64,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
BytedeskConstants.host,
'/api/thread/history/records',
{'page': page.toString(), 'size': size.toString(), 'client': client});
// print("thread Url $threadUrl");
// BytedeskUtils.printLog("thread Url $threadUrl");
final initResponse =
await this.httpClient.get(threadUrl, headers: getHeaders());
@ -72,7 +73,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -104,7 +105,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("getVisitorThreads responseJson $responseJson");
// BytedeskUtils.printLog("getVisitorThreads responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -130,7 +131,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("getVisitorThreadsAll responseJson $responseJson");
BytedeskUtils.printLog("getVisitorThreadsAll responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -149,7 +150,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//
final threadUrl = Uri.http(BytedeskConstants.host, '/api/thread/request',
{'wId': wid, 'type': type, 'aId': aid, 'client': client});
print(threadUrl);
BytedeskUtils.printLog(threadUrl);
final initResponse =
await this.httpClient.get(threadUrl, headers: getHeaders());
@ -158,8 +159,8 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("requestThread:");
// print(responseJson);
// BytedeskUtils.printLog("requestThread:");
// BytedeskUtils.printLog(responseJson);
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -173,7 +174,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//
final threadUrl = Uri.http(BytedeskConstants.host,
'/api/v2/thread/workGroup', {'wId': wid, 'client': client});
print(threadUrl);
BytedeskUtils.printLog(threadUrl);
final initResponse =
await this.httpClient.get(threadUrl, headers: getHeaders());
@ -182,8 +183,8 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("requestWorkGroupThreadV2:");
print(responseJson);
BytedeskUtils.printLog("requestWorkGroupThreadV2:");
BytedeskUtils.printLog(responseJson);
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -200,7 +201,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
BytedeskConstants.host,
'/api/thread/request/agent',
{'wId': wid, 'type': type, 'aId': aid, 'client': client});
print("request agent Url $threadUrl");
BytedeskUtils.printLog("request agent Url $threadUrl");
final initResponse =
await this.httpClient.get(threadUrl, headers: getHeaders());
@ -209,7 +210,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -223,7 +224,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//
final threadUrl = Uri.http(BytedeskConstants.host, '/api/thread/contact',
{'cid': cid, 'client': client});
print("request contact thread Url $threadUrl");
BytedeskUtils.printLog("request contact thread Url $threadUrl");
final initResponse =
await this.httpClient.get(threadUrl, headers: getHeaders());
@ -232,7 +233,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -246,7 +247,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//
final threadUrl = Uri.http(BytedeskConstants.host, '/api/thread/group',
{'gid': gid, 'client': client});
print("request contact thread Url $threadUrl");
BytedeskUtils.printLog("request contact thread Url $threadUrl");
final initResponse =
await this.httpClient.get(threadUrl, headers: getHeaders());
@ -255,7 +256,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -283,7 +284,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -311,7 +312,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -339,7 +340,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -367,7 +368,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -395,7 +396,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -423,7 +424,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -445,7 +446,7 @@ class BytedeskThreadHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
// token
if (responseJson.toString().contains('invalid_token')) {

@ -18,7 +18,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//
Future<OAuth> oauth(String? username, String? password) async {
var oauthUrl = Uri.http(BytedeskConstants.host, '/oauth/token');
// print("http api client: oauthUrl $oauthUrl");
// BytedeskUtils.printLog("http api client: oauthUrl $oauthUrl");
Map<String, String> headers = {
"Authorization": "Basic Y2xpZW50OnNlY3JldA=="
};
@ -30,14 +30,14 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
};
final oauthResponse =
await this.httpClient.post(oauthUrl, headers: headers, body: bodyMap);
// print('oauth result: $oauthResponse');
// BytedeskUtils.printLog('oauth result: $oauthResponse');
// check the status code for the result
int statusCode = oauthResponse.statusCode;
// print("statusCode $statusCode");
// BytedeskUtils.printLog("statusCode $statusCode");
// 200:
final oauthJson = jsonDecode(oauthResponse.body);
// print('oauth:');
// print(oauthJson);
BytedeskUtils.printLog('oauth:');
BytedeskUtils.printLog(oauthJson);
SpUtil.putBool(BytedeskConstants.isLogin, true);
SpUtil.putString(BytedeskConstants.accessToken, oauthJson['access_token']);
//
@ -50,7 +50,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
// final oauthUrl = '$baseUrl/mobile/token';
// final oauthUrl = Uri.http(BytedeskConstants.host, '/mobile/token');
final oauthUrl = Uri.http(BytedeskConstants.host, '/mobile/token');
// print("http api client: oauthUrl $oauthUrl");
// BytedeskUtils.printLog("http api client: oauthUrl $oauthUrl");
Map<String, String> headers = {
"Authorization": "Basic Y2xpZW50OnNlY3JldA=="
};
@ -63,12 +63,12 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//
final oauthResponse =
await this.httpClient.post(oauthUrl, headers: headers, body: bodyMap);
// print('oauth result: $oauthResponse');
// BytedeskUtils.printLog('oauth result: $oauthResponse');
int statusCode = oauthResponse.statusCode;
// 200:
final oauthJson = jsonDecode(oauthResponse.body);
print('smsOAuth:');
print(oauthJson);
BytedeskUtils.printLog('smsOAuth:');
BytedeskUtils.printLog(oauthJson);
if (statusCode == 200) {
SpUtil.putBool(BytedeskConstants.isLogin, true);
SpUtil.putBool(BytedeskConstants.isAuthenticated, true);
@ -84,7 +84,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//
// final oauthUrl = '$baseUrl/wechat/token';
final oauthUrl = Uri.http(BytedeskConstants.host, '/wechat/token');
// print("http api client: oauthUrl $oauthUrl");
// BytedeskUtils.printLog("http api client: oauthUrl $oauthUrl");
Map<String, String> headers = {
"Authorization": "Basic Y2xpZW50OnNlY3JldA=="
};
@ -96,14 +96,14 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//
final oauthResponse =
await this.httpClient.post(oauthUrl, headers: headers, body: bodyMap);
// print('oauth result: $oauthResponse');
// BytedeskUtils.printLog('oauth result: $oauthResponse');
// check the status code for the result
int statusCode = oauthResponse.statusCode;
// print("statusCode $statusCode");
// BytedeskUtils.printLog("statusCode $statusCode");
// 200:
final oauthJson = jsonDecode(oauthResponse.body);
print('unionIdOAuth:');
print(oauthJson);
BytedeskUtils.printLog('unionIdOAuth:');
BytedeskUtils.printLog(oauthJson);
if (statusCode == 200) {
SpUtil.putBool(BytedeskConstants.isLogin, true);
SpUtil.putBool(BytedeskConstants.isAuthenticated, true);
@ -137,8 +137,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("register:");
// print(responseJson);
// BytedeskUtils.printLog("register:");
// BytedeskUtils.printLog(responseJson);
return JsonResult.fromJson(responseJson);
}
@ -157,8 +157,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("registerAnonymous:");
// print(responseJson);
// BytedeskUtils.printLog("registerAnonymous:");
// BytedeskUtils.printLog(responseJson);
//
User user = User.fromJson(responseJson['data']);
//
@ -196,8 +196,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("registerUser:");
print(responseJson);
BytedeskUtils.printLog("registerUser:");
BytedeskUtils.printLog(responseJson);
//
int statusCode = responseJson['status_code'];
if (statusCode == 200) {
@ -243,8 +243,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// final responseJson = json.decode(initResponse.body);
// print("changePassword");
// print(responseJson);
// BytedeskUtils.printLog("changePassword");
// BytedeskUtils.printLog(responseJson);
return JsonResult.fromJson(responseJson);
}
@ -261,8 +261,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("requestCode:");
// print(responseJson);
// BytedeskUtils.printLog("requestCode:");
// BytedeskUtils.printLog(responseJson);
SpUtil.putBool(BytedeskConstants.exist, responseJson['data']['exist']);
SpUtil.putString(BytedeskConstants.code, responseJson['data']['code']);
@ -284,7 +284,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
int statusCode = responseJson['status_code'];
if (statusCode == 200) {
SpUtil.putBool(BytedeskConstants.isAuthenticated, true);
@ -306,8 +306,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("getProfile:");
// print(responseJson);
// BytedeskUtils.printLog("getProfile:");
// BytedeskUtils.printLog(responseJson);
//
User user = User.fromJson(responseJson['data']);
//
@ -334,8 +334,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("updateNickname:");
print(responseJson);
BytedeskUtils.printLog("updateNickname:");
BytedeskUtils.printLog(responseJson);
//
SpUtil.putString(BytedeskConstants.nickname, nickname!);
@ -356,8 +356,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("updateAvatar:");
print(responseJson);
BytedeskUtils.printLog("updateAvatar:");
BytedeskUtils.printLog(responseJson);
//
SpUtil.putString(BytedeskConstants.avatar, avatar!);
@ -378,8 +378,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("updateDescription:");
print(responseJson);
BytedeskUtils.printLog("updateDescription:");
BytedeskUtils.printLog(responseJson);
//
SpUtil.putString(BytedeskConstants.description, description!);
@ -406,8 +406,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("updateProfile:");
print(responseJson);
BytedeskUtils.printLog("updateProfile:");
BytedeskUtils.printLog(responseJson);
//
SpUtil.putString(BytedeskConstants.nickname, nickname!);
SpUtil.putString(BytedeskConstants.avatar, avatar!);
@ -430,7 +430,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("updateSex $responseJson");
// BytedeskUtils.printLog("updateSex $responseJson");
//
SpUtil.putBool(BytedeskConstants.sex, sex!);
@ -451,7 +451,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("updateLocation $responseJson");
// BytedeskUtils.printLog("updateLocation $responseJson");
//
SpUtil.putString(BytedeskConstants.location, location!);
@ -472,7 +472,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("updateBirthday $responseJson");
// BytedeskUtils.printLog("updateBirthday $responseJson");
//
SpUtil.putString(BytedeskConstants.birthday, birthday!);
@ -493,7 +493,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("updateMobile $responseJson");
// BytedeskUtils.printLog("updateMobile $responseJson");
//
SpUtil.putString(BytedeskConstants.mobile, mobile!);
@ -507,7 +507,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
String? username = SpUtil.getString(BytedeskConstants.uid);
final uploadUrl = '$baseUrl/visitor/api/upload/image';
print("fileName $fileName, username $username, upload Url $uploadUrl");
BytedeskUtils.printLog("fileName $fileName, username $username, upload Url $uploadUrl");
var uri = Uri.parse(uploadUrl);
var request = http.MultipartRequest('POST', uri)
@ -517,17 +517,17 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
http.Response response =
await http.Response.fromStream(await request.send());
// print("Result: ${response.body}");
// BytedeskUtils.printLog("Result: ${response.body}");
//json
Utf8Decoder utf8decoder = Utf8Decoder(); // fix
//string json
final responseJson = json.decode(utf8decoder.convert(response.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// TODO: status_code
String? url = responseJson['data'];
// print('url:' + url);
// BytedeskUtils.printLog('url:' + url);
return url!;
}
@ -545,7 +545,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// TODO: status_code
//
return responseJson['data']['status'].toString();
@ -563,7 +563,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// TODO: status_code
//
return responseJson['data']['status'].toString();
@ -583,7 +583,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// TODO: status_code
//
return responseJson['data'].toString();
@ -601,7 +601,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// TODO: status_code
//
return responseJson['data'].toString();
@ -619,7 +619,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
// TODO: status_code
//
return responseJson['data'].toString();
@ -637,8 +637,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("checkAppVersion:");
print(responseJson);
BytedeskUtils.printLog("checkAppVersion:");
BytedeskUtils.printLog(responseJson);
// token
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
@ -663,7 +663,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
//
return responseJson['data'].toString();
}
@ -682,7 +682,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
//
return WeChatResult.fromJson(responseJson);
}
@ -714,7 +714,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
//
UserJsonResult userJsonResult = UserJsonResult.fromJson(responseJson);
if (userJsonResult.statusCode == 200) {
@ -749,7 +749,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
//
UserJsonResult userJsonResult = UserJsonResult.fromJson(responseJson);
if (userJsonResult.statusCode == 200) {
@ -773,7 +773,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("responseJson $responseJson");
// BytedeskUtils.printLog("responseJson $responseJson");
//
return responseJson['data'];
}
@ -790,7 +790,7 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("responseJson $responseJson");
BytedeskUtils.printLog("responseJson $responseJson");
//
return JsonResult.fromJson(responseJson);
}
@ -807,8 +807,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// print("unfollow:");
// print(responseJson);
// BytedeskUtils.printLog("unfollow:");
// BytedeskUtils.printLog(responseJson);
return JsonResult.fromJson(responseJson);
}
@ -827,8 +827,8 @@ class BytedeskUserHttpApi extends BytedeskBaseHttpApi {
//string json
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
print("logout:");
print(responseJson);
BytedeskUtils.printLog("logout:");
BytedeskUtils.printLog(responseJson);
BytedeskUtils.clearUserCache();
}
}

@ -9,8 +9,8 @@ class Answer extends Equatable {
Answer({this.aid, this.question, this.answer}) : super();
//
static Answer fromJson(dynamic json) {
// print('aid:' + json['aid']);
// print('question:' + json['question']);
// BytedeskUtils.printLog('aid:' + json['aid']);
// BytedeskUtils.printLog('question:' + json['question']);
return Answer(
aid: json['aid'], question: json['question'], answer: json['answer']);
}

@ -70,7 +70,7 @@ class MessageProvider {
version: 10,
);
// database path:/Users/ningjinpeng/Library/Developer/CoreSimulator/Devices/715CBA02-A602-4DE1-8C57-75A64B53BF03/data/Containers/Data/Application/8F46273D-9492-4C42-A618-4DF3815562BA/Documents/bytedesk-message-v9.db
// print('database path:' + database!.path);
BytedeskUtils.printLog('database path:' + database!.path);
}
Future<int> insert(Message message) async {
@ -78,19 +78,19 @@ class MessageProvider {
if (BytedeskUtils.isWeb) {
return 0;
}
// print('insert avatar:' + message.avatar + ' conten:' + message.content + ' timestamp:' + message.timestamp);
// BytedeskUtils.printLog('insert avatar:' + message.avatar + ' conten:' + message.content + ' timestamp:' + message.timestamp);
return await database!.insert(tableMessage!, message.toMap());
}
//
Future<List<Message>> getTopicMessages(
String? topic, String? currentUid, int? page, int? size) async {
// print('1: ' + topic! + ' currentUid:' + currentUid!);
// BytedeskUtils.printLog('1: ' + topic! + ' currentUid:' + currentUid!);
// FIXME: web
if (BytedeskUtils.isWeb) {
return [];
}
// print('2');
// BytedeskUtils.printLog('2');
//
List<Map> maps = await database!.query(tableMessage!,
columns: [
@ -117,8 +117,8 @@ class MessageProvider {
limit: size,
offset: page! * size!);
//
// print('3');
// print(maps.length);
// BytedeskUtils.printLog('3');
// BytedeskUtils.printLog(maps.length);
//
return List.generate(maps.length, (i) {
//
@ -140,7 +140,7 @@ class MessageProvider {
// .map((item) => Category.fromJson(item))
// .toList();
// }
// print('4');
// BytedeskUtils.printLog('4');
return Message(
mid: maps[i]['mid'],
content: maps[i]['content'],

@ -58,7 +58,7 @@ class ThreadProvider {
}
Future<int> insert(Thread thread) async {
// print('insert avatar:' + message.avatar + ' conten:' + message.content + ' timestamp:' + message.timestamp);
// BytedeskUtils.printLog('insert avatar:' + message.avatar + ' conten:' + message.content + ' timestamp:' + message.timestamp);
return await database!.insert(tableThread!, thread.toMap());
}

@ -117,9 +117,7 @@ class BytedeskMqtt {
// .withWillMessage('My Will message')
// .startClean() // Non persistent session for testing
// .withWillQos(MqttQos.atLeastOnce);
if (BytedeskConstants.isDebug) {
print('mqttClient connecting....');
}
BytedeskUtils.printLog('mqttClient connecting....');
mqttClient.connectionMessage = connMessage;
/// Connect the client, any errors here are communicated by raising of the appropriate exception. Note
@ -128,16 +126,16 @@ class BytedeskMqtt {
try {
await mqttClient.connect();
} on Exception catch (e) {
print('mqttClient exception - $e');
BytedeskUtils.printLog('mqttClient exception - $e');
mqttClient.disconnect();
}
/// Check we are connected
if (mqttClient.connectionStatus.state == MqttConnectionState.connected) {
print('mqttClient connected');
BytedeskUtils.printLog('mqttClient connected');
} else {
/// Use status here rather than state if you also want the broker return code.
print(
BytedeskUtils.printLog(
'ERROR mqttClient connection failed - disconnecting, status is ${mqttClient.connectionStatus}');
mqttClient.disconnect();
// exit(-1);
@ -149,14 +147,14 @@ class BytedeskMqtt {
// final MqttPublishMessage recMess = c[0].payload;
// final String pt =
// MqttPublishPayload.bytesToStringAsString(recMess.payload.message);
// // print('Change notification:: topic is <${c[0].topic}>, payload is <-- $pt -->');
// // BytedeskUtils.printLog('Change notification:: topic is <${c[0].topic}>, payload is <-- $pt -->');
// });
///
// if (mqttClient != null && mqttClient.published != null) {
//
mqttClient.published!.listen((MqttPublishMessage messageBinary) {
// print('Published notification:: topic is ${messageBinary.variableHeader.topicName}, with Qos ${messageBinary.header.qos}');
// BytedeskUtils.printLog('Published notification:: topic is ${messageBinary.variableHeader.topicName}, with Qos ${messageBinary.header.qos}');
//
protomsg.Message messageProto =
protomsg.Message.fromBuffer(messageBinary.payload.message);
@ -177,14 +175,12 @@ class BytedeskMqtt {
var timestamp = messageProto.timestamp;
var client = messageProto.client;
//
if (BytedeskConstants.isDebug) {
print('bytedesk_mqtt.dart receive type:' +
type +
' client:' +
client +
' mid:' +
mid);
}
BytedeskUtils.printLog('bytedesk_mqtt.dart receive type:' +
type +
' client:' +
client +
' mid:' +
mid);
// ,
if (type == BytedeskConstants.MESSAGE_TYPE_NOTIFICATION_NOTICE) {
// TODO:
@ -232,6 +228,7 @@ class BytedeskMqtt {
sendReceipt = true;
// TODO:
message.content = messageProto.text.content;
BytedeskUtils.printLog('receive text:' + message.content!);
break;
}
case BytedeskConstants.MESSAGE_TYPE_IMAGE:
@ -550,7 +547,7 @@ class BytedeskMqtt {
return;
}
default:
print('other message type:' + type);
BytedeskUtils.printLog('other message type:' + type);
}
// 使
// if (autoReply) {
@ -564,7 +561,7 @@ class BytedeskMqtt {
//
// final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
// final decrypted = encrypter.decrypt64(messageProto.text.content, iv: iv);
// print('content: ' + decrypted);
// BytedeskUtils.printLog('content: ' + decrypted);
//
//
if (message.content == 'visitorConnect' ||
@ -579,18 +576,18 @@ class BytedeskMqtt {
bytedeskEventBus.fire(ReceiveMessageEventBus(message));
// SDKdemo
if (BytedeskKefu.getPlayAudioOnReceiveMessage()! && message.isSend == 0) {
// print('play audio');
// BytedeskUtils.printLog('play audio');
SystemSound.play(SystemSoundType.click);
}
// SDKdemo
if (BytedeskKefu.getVibrateOnReceiveMessage()! && message.isSend == 0) {
// print('should vibrate');
// BytedeskUtils.printLog('should vibrate');
vibrate();
}
});
//
// } else {
// print('mqttClient.published is null');
// BytedeskUtils.printLog('mqttClient.published is null');
// }
}
@ -602,7 +599,7 @@ class BytedeskMqtt {
}
void subscribe(String topic) {
// print('Subscribing to the hello topic');
// BytedeskUtils.printLog('Subscribing to the hello topic');
mqttClient.subscribe(topic, MqttQos.exactlyOnce);
}
@ -673,16 +670,16 @@ class BytedeskMqtt {
void publish(String content, String type, Thread currentThread,
ExtraParam? extraParam) {
// if (currentThread == null) {
// print('连接客服失败,请退出页面重新进入。注意: 请在App启动的时候调用init接口');
// BytedeskUtils.printLog('连接客服失败,请退出页面重新进入。注意: 请在App启动的时候调用init接口');
// Fluttertoast.showToast(msg: '连接客服失败,请退出页面重新进入');
// return;
// }
// https://pub.dev/packages/encrypt#aes
// final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
// final encrypted = encrypter.encrypt(content, iv: iv);
// print(encrypted.base64);
// BytedeskUtils.printLog(encrypted.base64);
// final decrypted = encrypter.decrypt(encrypted, iv: iv);
// print(decrypted);
// BytedeskUtils.printLog(decrypted);
// thread
protothread.Thread thread = new protothread.Thread();
thread.tid = currentThread.tid!;
@ -958,8 +955,8 @@ class BytedeskMqtt {
//
return;
} else {
// TODO:
print('other type:' + type);
//
BytedeskUtils.printLog('other type:' + type);
}
//
messageProto.user = user;
@ -992,46 +989,46 @@ class BytedeskMqtt {
/// The subscribed callback
void _onSubscribed(String? topic) {
// print('Subscription confirmed for topic $topic');
// BytedeskUtils.printLog('Subscription confirmed for topic $topic');
}
/// The unsubscribed callback
void _onUnSubscribed(String? topic) {
// print('UnSubscription confirmed for topic $topic');
// BytedeskUtils.printLog('UnSubscription confirmed for topic $topic');
}
/// The subscribed callback
void _onSubscribeFailed(String? topic) {
// print('Subscribe Failed confirmed for topic $topic');
// BytedeskUtils.printLog('Subscribe Failed confirmed for topic $topic');
}
/// The unsolicited disconnect callback
void _onDisconnected() {
// _isConnected = false;
// print('OnDisconnected client callback - Client disconnection');
// BytedeskUtils.printLog('OnDisconnected client callback - Client disconnection');
// eventbus广
bytedeskEventBus
.fire(ConnectionEventBus(BytedeskConstants.USER_STATUS_DISCONNECTED));
// if (mqttClient.connectionStatus.returnCode == MqttConnectReturnCode.solicited) {
// print('OnDisconnected callback is solicited, this is correct');
// BytedeskUtils.printLog('OnDisconnected callback is solicited, this is correct');
// }
// 10s
Future.delayed(Duration(seconds: 10), () {
// print('start reconnecting');
// BytedeskUtils.printLog('start reconnecting');
// reconnect();
});
}
/// The unsolicited disconnect callback
// void _onAutoReconnect() {
// // print('EXAMPLE::onAutoReconnect client callback - Client auto reconnection sequence will start');
// // BytedeskUtils.printLog('EXAMPLE::onAutoReconnect client callback - Client auto reconnection sequence will start');
// // connect();
// }
/// The successful connect callback
void _onConnected() {
// _isConnected = true;
// print('OnConnected client callback - Client connection was sucessful');
// BytedeskUtils.printLog('OnConnected client callback - Client connection was sucessful');
// TODO: eventbus广
bytedeskEventBus
.fire(ConnectionEventBus(BytedeskConstants.USER_STATUS_CONNECTED));
@ -1039,7 +1036,7 @@ class BytedeskMqtt {
/// Pong callback
void _onPong() {
// print('Ping response client callback invoked');
// BytedeskUtils.printLog('Ping response client callback invoked');
}
bool isConnected() {

@ -38,7 +38,8 @@ class MqttServerConnection extends MqttConnectionBase {
try {
listener = client.listen(_onData, onError: onError, onDone: onDone);
} on Exception catch (e) {
print('MqttServerConnection::_startListening - exception raised $e');
print(
'MqttServerConnection::_startListening - exception raised $e');
}
}

@ -29,6 +29,19 @@ class MessageRepository {
return await bytedeskHttpApi.loadChannelMessages(cid, page, size);
}
Future<List<Message>> loadUnreadMessages(
String? wid, int? page, int? size) async {
return await bytedeskHttpApi.loadUnreadMessages(wid, page, size);
}
Future<List<Message>> loadUnreadVisitorMessages(int? page, int? size) async {
return await bytedeskHttpApi.loadUnreadMessagesVisitor(page, size);
}
Future<List<Message>> loadUnreadAgentMessages(int? page, int? size) async {
return await bytedeskHttpApi.loadUnreadMessagesAgent(page, size);
}
Future<RequestAnswerResult> queryAnswer(String? tid, String? aid, String? mid) async {
return await bytedeskHttpApi.queryAnswer2(tid, aid, mid);
}

@ -85,12 +85,12 @@ class UserRepository {
}
Future<void> logout() {
// print("user_repository logout");
// BytedeskUtils.printLog("user_repository logout");
return Future.wait([bytedeskHttpApi.logout()]);
}
// Future<bool> isLogin() {
// print("user_repository isSignedIn");
// BytedeskUtils.printLog("user_repository isSignedIn");
// // final currentUser = BytedeskHttpApi.currentUser();
// // return currentUser != null;
// }
@ -100,7 +100,7 @@ class UserRepository {
}
// Future<String> getUsername() {
// print("user_repository getUsername");
// BytedeskUtils.printLog("user_repository getUsername");
// return (BytedeskHttpApi.currentUser()).username;
// }

@ -102,7 +102,7 @@ class _ChatIMPageState extends State<ChatIMPage>
//
@override
void initState() {
// print('chat_kf_page init');
// BytedeskUtils.printLog('chat_kf_page init');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true);
//
if (widget.isThread! && widget.thread != null) {
@ -116,14 +116,14 @@ class _ChatIMPageState extends State<ChatIMPage>
WidgetsBinding.instance!.addObserver(this);
// buildhttps://blog.csdn.net/baoolong/article/details/85097318
// WidgetsBinding.instance.addPostFrameCallback((_) {
// print('addPostFrameCallback');
// BytedeskUtils.printLog('addPostFrameCallback');
// });
// Fluttertoast.showToast(msg: "请求中, 请稍后...");
_listener();
super.initState();
// 10s
_loadHistoryTimer = Timer.periodic(Duration(seconds: 10), (timer) {
// print('从服务器 load history');
// BytedeskUtils.printLog('从服务器 load history');
BlocProvider.of<MessageBloc>(context)
..add(LoadHistoryMessageEvent(uid: _currentUid, page: 0, size: 10));
// 1
@ -186,7 +186,7 @@ class _ChatIMPageState extends State<ChatIMPage>
//
if (state.threadResult.statusCode == 200 ||
state.threadResult.statusCode == 201) {
print('创建新会话');
BytedeskUtils.printLog('创建新会话');
//
// _messageProvider.insert(state.threadResult.msg!);
// TODO: pop
@ -203,7 +203,7 @@ class _ChatIMPageState extends State<ChatIMPage>
widget.postscript!, _currentThread!);
}
} else if (state.threadResult.statusCode == 202) {
print('提示排队中');
BytedeskUtils.printLog('提示排队中');
//
_messageProvider.insert(state.threadResult.msg!);
//
@ -222,7 +222,7 @@ class _ChatIMPageState extends State<ChatIMPage>
widget.postscript!, _currentThread!);
}
} else if (state.threadResult.statusCode == 203) {
print('当前非工作时间,请自助查询或留言');
BytedeskUtils.printLog('当前非工作时间,请自助查询或留言');
// TODO:
setState(() {
_currentThread = state.threadResult.msg!.thread;
@ -233,7 +233,7 @@ class _ChatIMPageState extends State<ChatIMPage>
_getMessages(_page, _size);
_appendMessage(state.threadResult.msg!);
} else if (state.threadResult.statusCode == 204) {
print('当前无客服在线,请自助查询或留言');
BytedeskUtils.printLog('当前无客服在线,请自助查询或留言');
// TODO:
setState(() {
_currentThread = state.threadResult.msg!.thread;
@ -244,7 +244,7 @@ class _ChatIMPageState extends State<ChatIMPage>
_getMessages(_page, _size);
_appendMessage(state.threadResult.msg!);
} else if (state.threadResult.statusCode == 205) {
print('咨询前问卷');
BytedeskUtils.printLog('咨询前问卷');
setState(() {
_currentThread = state.threadResult.msg!.thread;
});
@ -255,7 +255,7 @@ class _ChatIMPageState extends State<ChatIMPage>
_appendMessage(state.threadResult.msg!);
//
} else if (state.threadResult.statusCode == 206) {
print('返回机器人初始欢迎语 + 欢迎问题列表');
BytedeskUtils.printLog('返回机器人初始欢迎语 + 欢迎问题列表');
// TODO:
setState(() {
_isRobot = true;
@ -290,9 +290,10 @@ class _ChatIMPageState extends State<ChatIMPage>
),
BlocListener<MessageBloc, MessageState>(
listener: (context, state) {
// print('message state change');
// BytedeskUtils.printLog('message state change');
if (state is ReceiveMessageState) {
print('receive message:' + state.message!.content!);
BytedeskUtils.printLog(
'receive message:' + state.message!.content!);
} else if (state is UploadImageSuccess) {
_bdMqtt.sendImageMessage(
state.uploadJsonResult.url!, _currentThread!);
@ -327,14 +328,15 @@ class _ChatIMPageState extends State<ChatIMPage>
// TODO:
} else if (state is LoadHistoryMessageSuccess) {
// TODO:
// print('history ${state.messageList!.length}');
// BytedeskUtils.printLog('history ${state.messageList!.length}');
for (var i = 0; i < state.messageList!.length; i++) {
// Message message = state.messageList[i];
// _appendMessage(message);
}
} else if (state is LoadTopicMessageSuccess) {
// TODO:
print('topic history ${state.messageList!.length}');
BytedeskUtils.printLog(
'topic history ${state.messageList!.length}');
for (var i = 0; i < state.messageList!.length; i++) {
// Message message = state.messageList[i];
// _appendMessage(message);
@ -375,7 +377,7 @@ class _ChatIMPageState extends State<ChatIMPage>
child: SmartRefresher(
enablePullDown: false,
onLoading: () async {
print('TODO: 下拉刷新'); //
BytedeskUtils.printLog('TODO: 下拉刷新'); //
// await Future.delayed(Duration(milliseconds: 1000));
_getMessages(_page, _size);
setState(() {});
@ -457,7 +459,7 @@ class _ChatIMPageState extends State<ChatIMPage>
if (_debounce?.isActive ?? false) _debounce!.cancel();
// 500
_debounce = Timer(const Duration(milliseconds: 500), () {
print('send preview $value');
BytedeskUtils.printLog('send preview $value');
// value != null &&
if (value.trim().length > 0) {
_bdMqtt.sendPreviewMessage(value, _currentThread!);
@ -512,7 +514,7 @@ class _ChatIMPageState extends State<ChatIMPage>
//
_bdMqtt.sendTextMessage(text, _currentThread!);
} else {
print('长连接断开的情况下调用rest接口');
BytedeskUtils.printLog('长连接断开的情况下调用rest接口');
String? mid = BytedeskUuid.generateV4();
String? timestamp = BytedeskUtils.formatedDateNow();
String? client = BytedeskUtils.getClient();
@ -574,7 +576,7 @@ class _ChatIMPageState extends State<ChatIMPage>
_listener() {
//
bytedeskEventBus.on<ReceiveMessageReceiptEventBus>().listen((event) {
// print('更新状态:' + event.status);
// BytedeskUtils.printLog('更新状态:' + event.status);
if (!this.mounted) {
return;
}
@ -591,7 +593,7 @@ class _ChatIMPageState extends State<ChatIMPage>
}
});
bytedeskEventBus.on<ReceiveMessagePreviewEventBus>().listen((event) {
// print('消息预知');
// BytedeskUtils.printLog('消息预知');
if (this.mounted) {
setState(() {
// TODO:
@ -602,7 +604,7 @@ class _ChatIMPageState extends State<ChatIMPage>
Timer(
Duration(seconds: 3),
() {
// print('timer');
// BytedeskUtils.printLog('timer');
if (this.mounted) {
setState(() {
_title = widget.title;
@ -613,11 +615,11 @@ class _ChatIMPageState extends State<ChatIMPage>
});
// DeleteMessageEventBus
// bytedeskEventBus.on<ReceiveMessageRecallEventBus>().listen((event) {
// print('消息撤回');
// BytedeskUtils.printLog('消息撤回');
// });
//
bytedeskEventBus.on<ReceiveMessageEventBus>().listen((event) {
// print('receive message:' + event.message!.content);
// BytedeskUtils.printLog('receive message:' + event.message!.content);
if (_currentThread != null &&
(event.message.thread!.topic != _currentThread!.topic)) {
return;
@ -656,7 +658,7 @@ class _ChatIMPageState extends State<ChatIMPage>
bytedeskEventBus.on<QueryAnswerEventBus>().listen((event) {
//
if (this.mounted) {
print(
BytedeskUtils.printLog(
'aid ${event.aid}, question ${event.question}, answer ${event.answer}');
//
// BlocProvider.of<MessageBloc>(context)
@ -673,7 +675,7 @@ class _ChatIMPageState extends State<ChatIMPage>
//
// if (_scrollController.position.pixels ==
// _scrollController.position.maxScrollExtent) {
// print('已经到底了');
// BytedeskUtils.printLog('已经到底了');
// }
});
}
@ -685,7 +687,7 @@ class _ChatIMPageState extends State<ChatIMPage>
source: ImageSource.gallery, maxWidth: 800, imageQuality: 95);
//
if (pickedFile != null) {
print('pick image path: ${pickedFile.path}');
BytedeskUtils.printLog('pick image path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -694,7 +696,7 @@ class _ChatIMPageState extends State<ChatIMPage>
// "/" +
// BytedeskUtils.currentTimeMillis().toString() +
// ".jpg";
// print('targetPath: $targetPath');
// BytedeskUtils.printLog('targetPath: $targetPath');
// await BytedeskUtils.compressImage(File(pickedFile.path), targetPath);
// //
// BlocProvider.of<MessageBloc>(context)
@ -706,7 +708,7 @@ class _ChatIMPageState extends State<ChatIMPage>
Fluttertoast.showToast(msg: '未选取图片');
}
} catch (e) {
print('pick image error ${e.toString()}');
BytedeskUtils.printLog('pick image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -718,7 +720,7 @@ class _ChatIMPageState extends State<ChatIMPage>
source: ImageSource.camera, maxWidth: 800, imageQuality: 95);
//
if (pickedFile != null) {
print('take image path: ${pickedFile.path}');
BytedeskUtils.printLog('take image path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -727,7 +729,7 @@ class _ChatIMPageState extends State<ChatIMPage>
// "/" +
// BytedeskUtils.currentTimeMillis().toString() +
// ".jpg";
// print('targetPath: $targetPath');
// BytedeskUtils.printLog('targetPath: $targetPath');
// await BytedeskUtils.compressImage(File(pickedFile.path), targetPath);
// //
// BlocProvider.of<MessageBloc>(context)
@ -739,7 +741,7 @@ class _ChatIMPageState extends State<ChatIMPage>
Fluttertoast.showToast(msg: '未拍照');
}
} catch (e) {
print('take image error ${e.toString()}');
BytedeskUtils.printLog('take image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -751,7 +753,7 @@ class _ChatIMPageState extends State<ChatIMPage>
try {
// final PickedFile videoFile = await _picker.getVideo(
// source: ImageSource.gallery, maxDuration: const Duration(seconds: 10));
// print('pick video path: ${videoFile.path}');
// BytedeskUtils.printLog('pick video path: ${videoFile.path}');
// if (videoFile != null) {
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: videoFile.path));
@ -775,9 +777,9 @@ class _ChatIMPageState extends State<ChatIMPage>
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugPrint(info.toJson().toString());
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // print('video path: ${_paths[0].path}, compress path: $afterPath');
// // BytedeskUtils.printLog('video path: ${_paths[0].path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
@ -786,7 +788,7 @@ class _ChatIMPageState extends State<ChatIMPage>
..add(UploadVideoEvent(filePath: _paths[0].path));
}
} catch (e) {
print('pick video error ${e.toString()}');
BytedeskUtils.printLog('pick video error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取视频");
}
}
@ -798,7 +800,7 @@ class _ChatIMPageState extends State<ChatIMPage>
source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
//
if (pickedFile != null) {
print('take video path: ${pickedFile.path}');
BytedeskUtils.printLog('take video path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -808,9 +810,9 @@ class _ChatIMPageState extends State<ChatIMPage>
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugPrint(info.toJson().toString());
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // print('video path: ${pickedFile.path}, compress path: $afterPath');
// // BytedeskUtils.printLog('video path: ${pickedFile.path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
@ -821,14 +823,14 @@ class _ChatIMPageState extends State<ChatIMPage>
Fluttertoast.showToast(msg: '未录制视频');
}
} catch (e) {
print('take video error ${e.toString()}');
BytedeskUtils.printLog('take video error ${e.toString()}');
Fluttertoast.showToast(msg: "未录制视频");
}
}
//
// Future<void> _loadMoreMessages() async {
// print('load more');
// BytedeskUtils.printLog('load more');
// // TODO:
// _getMessages(_page, _size);
// }
@ -857,7 +859,7 @@ class _ChatIMPageState extends State<ChatIMPage>
}
Future<Null> _appendMessage(Message message) async {
// print('append:' + message!.mid);
// BytedeskUtils.printLog('append:' + message!.mid);
bool contains = false;
for (var i = 0; i < _messages.length; i++) {
Message? element = _messages[i].message;
@ -895,7 +897,7 @@ class _ChatIMPageState extends State<ChatIMPage>
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
// print("didChangeAppLifecycleState:" + state.toString());
// BytedeskUtils.printLog("didChangeAppLifecycleState:" + state.toString());
switch (state) {
case AppLifecycleState.inactive: //
break;
@ -913,7 +915,7 @@ class _ChatIMPageState extends State<ChatIMPage>
@override
void dispose() {
// print('chat_kf_page dispose');
// BytedeskUtils.printLog('chat_kf_page dispose');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, false);
WidgetsBinding.instance!.removeObserver(this);
_debounce?.cancel();

@ -100,14 +100,14 @@ class _ChatKFPageState extends State<ChatKFPage>
// preview
Timer? _debounce;
//
// Timer? _loadHistoryTimer;
Timer? _loadHistoryTimer;
//
// final _flutterVideoCompress = FlutterVideoCompress();
bool _isRequestingThread = true;
//
@override
void initState() {
// print('chat_kf_page init');
// BytedeskUtils.printLog('chat_kf_page init');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true);
//
if (widget.isThread! && widget.thread != null) {
@ -124,20 +124,22 @@ class _ChatKFPageState extends State<ChatKFPage>
WidgetsBinding.instance!.addObserver(this);
// buildhttps://blog.csdn.net/baoolong/article/details/85097318
// WidgetsBinding.instance.addPostFrameCallback((_) {
// print('addPostFrameCallback');
// BytedeskUtils.printLog('addPostFrameCallback');
// });
// Fluttertoast.showToast(msg: "请求中, 请稍后...");
_listener();
super.initState();
// 10s
// _loadHistoryTimer = Timer.periodic(Duration(seconds: 10), (timer) {
// // print('从服务器 load history');
// // TODO:
// // BlocProvider.of<MessageBloc>(context)
// // ..add(LoadHistoryMessageEvent(uid: _currentUid, page: 0, size: 10));
// // 1
// // timer.cancel();
// });
_loadHistoryTimer = Timer.periodic(Duration(seconds: 15), (timer) {
// BytedeskUtils.printLog('从服务器 load history');
// // TODO:
// BlocProvider.of<MessageBloc>(context)
// ..add(LoadHistoryMessageEvent(uid: _currentUid, page: 0, size: 10));
// // 1
// // timer.cancel();
});
BlocProvider.of<MessageBloc>(context)
..add(LoadUnreadVisitorMessagesEvent(page: 0, size: 10));
}
//
@ -197,7 +199,7 @@ class _ChatKFPageState extends State<ChatKFPage>
//
if (state.threadResult.statusCode == 200 ||
state.threadResult.statusCode == 201) {
print('创建新会话');
BytedeskUtils.printLog('创建新会话');
// TODO: pop
//
if (widget.custom != null &&
@ -212,7 +214,7 @@ class _ChatKFPageState extends State<ChatKFPage>
widget.postscript!, _currentThread!);
}
} else if (state.threadResult.statusCode == 202) {
print('提示排队中');
BytedeskUtils.printLog('提示排队中');
//
_messageProvider.insert(state.threadResult.msg!);
//
@ -230,7 +232,7 @@ class _ChatKFPageState extends State<ChatKFPage>
widget.postscript!, _currentThread!);
}
} else if (state.threadResult.statusCode == 203) {
print('当前非工作时间,请自助查询或留言');
BytedeskUtils.printLog('当前非工作时间,请自助查询或留言');
setState(() {
_currentThread = state.threadResult.msg!.thread;
});
@ -248,7 +250,7 @@ class _ChatKFPageState extends State<ChatKFPage>
tip: state.threadResult.msg!.content);
}));
} else if (state.threadResult.statusCode == 204) {
print('当前无客服在线,请自助查询或留言');
BytedeskUtils.printLog('当前无客服在线,请自助查询或留言');
setState(() {
_currentThread = state.threadResult.msg!.thread;
});
@ -267,7 +269,7 @@ class _ChatKFPageState extends State<ChatKFPage>
tip: state.threadResult.msg!.content);
}));
} else if (state.threadResult.statusCode == 205) {
print('咨询前问卷');
BytedeskUtils.printLog('咨询前问卷');
setState(() {
_currentThread = state.threadResult.msg!.thread;
});
@ -278,7 +280,7 @@ class _ChatKFPageState extends State<ChatKFPage>
_appendMessage(state.threadResult.msg!);
//
} else if (state.threadResult.statusCode == 206) {
// print('返回机器人初始欢迎语 + 欢迎问题列表');
// BytedeskUtils.printLog('返回机器人初始欢迎语 + 欢迎问题列表');
// TODO:
setState(() {
_isRobot = true;
@ -329,9 +331,9 @@ class _ChatKFPageState extends State<ChatKFPage>
),
BlocListener<MessageBloc, MessageState>(
listener: (context, state) {
// print('message state change');
// BytedeskUtils.printLog('message state change');
if (state is ReceiveMessageState) {
// print('receive message:' + state.message!.content!);
// BytedeskUtils.printLog('receive message:' + state.message!.content!);
} else if (state is MessageUpLoading) {
Fluttertoast.showToast(msg: '上传中...');
} else if (state is UploadImageSuccess) {
@ -375,7 +377,13 @@ class _ChatKFPageState extends State<ChatKFPage>
} else if (state is RateAnswerSuccess) {
// TODO:
} else if (state is LoadHistoryMessageSuccess) {
// print('LoadHistoryMessageSuccess');
// BytedeskUtils.printLog('LoadHistoryMessageSuccess');
//
for (var i = 0; i < state.messageList!.length; i++) {
Message message = state.messageList![i];
_appendMessage(message);
}
} else if (state is LoadUnreadVisitorMessageSuccess) {
//
for (var i = 0; i < state.messageList!.length; i++) {
Message message = state.messageList![i];
@ -406,7 +414,7 @@ class _ChatKFPageState extends State<ChatKFPage>
child: SmartRefresher(
enablePullDown: false,
onLoading: () async {
// print('TODO: 下拉刷新'); //
// BytedeskUtils.printLog('TODO: 下拉刷新'); //
// await Future.delayed(Duration(milliseconds: 1000));
_getMessages(_page, _size);
setState(() {});
@ -490,7 +498,7 @@ class _ChatKFPageState extends State<ChatKFPage>
if (_debounce?.isActive ?? false) _debounce!.cancel();
// 500
_debounce = Timer(const Duration(milliseconds: 500), () {
// print('send preview $value');
// BytedeskUtils.printLog('send preview $value');
//
if (value.trim().length > 0) {
_bdMqtt.sendPreviewMessage(value, _currentThread!);
@ -547,7 +555,7 @@ class _ChatKFPageState extends State<ChatKFPage>
//
_bdMqtt.sendTextMessage(text, _currentThread!);
} else {
// print('长连接断开的情况下调用rest接口');
// BytedeskUtils.printLog('长连接断开的情况下调用rest接口');
sendTextMessageRest(text);
}
}
@ -744,7 +752,7 @@ class _ChatKFPageState extends State<ChatKFPage>
_listener() {
//
bytedeskEventBus.on<ReceiveMessageReceiptEventBus>().listen((event) {
// print('更新状态:' + event.mid + '-' + event.status);
// BytedeskUtils.printLog('更新状态:' + event.mid + '-' + event.status);
if (this.mounted) {
//
for (var i = 0; i < _messages.length; i++) {
@ -752,7 +760,7 @@ class _ChatKFPageState extends State<ChatKFPage>
if (messageWidget.message!.mid == event.mid &&
_messages[i].message!.status !=
BytedeskConstants.MESSAGE_STATUS_READ) {
// print('do update status:' + messageWidget.message!.mid!);
// BytedeskUtils.printLog('do update status:' + messageWidget.message!.mid!);
// setState(() {
// _messages[i].message!.status = event.status; //
// });
@ -772,7 +780,7 @@ class _ChatKFPageState extends State<ChatKFPage>
}
});
bytedeskEventBus.on<ReceiveMessagePreviewEventBus>().listen((event) {
// print('消息预知');
// BytedeskUtils.printLog('消息预知');
if (this.mounted) {
setState(() {
// TODO:
@ -783,7 +791,7 @@ class _ChatKFPageState extends State<ChatKFPage>
Timer(
Duration(seconds: 3),
() {
// print('timer');
// BytedeskUtils.printLog('timer');
if (this.mounted) {
setState(() {
_title = widget.title;
@ -794,7 +802,7 @@ class _ChatKFPageState extends State<ChatKFPage>
});
//
bytedeskEventBus.on<ReceiveMessageEventBus>().listen((event) {
// print('receive message:' + event.message!.content);
// BytedeskUtils.printLog('receive message:' + event.message!.content);
if (_currentThread != null &&
(event.message.thread!.topic != _currentThread!.topic)) {
return;
@ -834,7 +842,7 @@ class _ChatKFPageState extends State<ChatKFPage>
//
bytedeskEventBus.on<QueryAnswerEventBus>().listen((event) {
if (this.mounted) {
// print('aid ${event.aid}, question ${event.question}, answer ${event.answer}');
// BytedeskUtils.printLog('aid ${event.aid}, question ${event.question}, answer ${event.answer}');
//
appendQueryMessage(event.question);
//
@ -849,7 +857,7 @@ class _ChatKFPageState extends State<ChatKFPage>
//
bytedeskEventBus.on<QueryCategoryEventBus>().listen((event) {
if (this.mounted) {
print('cid ${event.cid}, name ${event.name}');
BytedeskUtils.printLog('cid ${event.cid}, name ${event.name}');
//
appendQueryMessage(event.name);
//
@ -872,7 +880,7 @@ class _ChatKFPageState extends State<ChatKFPage>
//
// if (_scrollController.position.pixels ==
// _scrollController.position.maxScrollExtent) {
// print('已经到底了');
// BytedeskUtils.printLog('已经到底了');
// }
});
}
@ -885,7 +893,7 @@ class _ChatKFPageState extends State<ChatKFPage>
source: ImageSource.gallery, maxWidth: 800, imageQuality: 95);
//
if (pickedFile != null) {
print('pick image path: ${pickedFile.path}');
BytedeskUtils.printLog('pick image path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -894,7 +902,7 @@ class _ChatKFPageState extends State<ChatKFPage>
// "/" +
// BytedeskUtils.currentTimeMillis().toString() +
// ".jpg";
// print('targetPath: $targetPath');
// BytedeskUtils.printLog('targetPath: $targetPath');
// await BytedeskUtils.compressImage(File(pickedFile.path), targetPath);
// //
// BlocProvider.of<MessageBloc>(context)
@ -906,7 +914,7 @@ class _ChatKFPageState extends State<ChatKFPage>
Fluttertoast.showToast(msg: '未选取图片');
}
} catch (e) {
print('pick image error ${e.toString()}');
BytedeskUtils.printLog('pick image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -918,7 +926,7 @@ class _ChatKFPageState extends State<ChatKFPage>
source: ImageSource.camera, maxWidth: 800, imageQuality: 95);
//
if (pickedFile != null) {
print('take image path: ${pickedFile.path}');
BytedeskUtils.printLog('take image path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -927,7 +935,7 @@ class _ChatKFPageState extends State<ChatKFPage>
// "/" +
// BytedeskUtils.currentTimeMillis().toString() +
// ".jpg";
// print('targetPath: $targetPath');
// BytedeskUtils.printLog('targetPath: $targetPath');
// await BytedeskUtils.compressImage(File(pickedFile.path), targetPath);
// //
// BlocProvider.of<MessageBloc>(context)
@ -939,7 +947,7 @@ class _ChatKFPageState extends State<ChatKFPage>
Fluttertoast.showToast(msg: '未拍照');
}
} catch (e) {
print('take image error ${e.toString()}');
BytedeskUtils.printLog('take image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -951,7 +959,7 @@ class _ChatKFPageState extends State<ChatKFPage>
try {
// final PickedFile videoFile = await _picker.getVideo(
// source: ImageSource.gallery, maxDuration: const Duration(seconds: 10));
// print('pick video path: ${videoFile.path}');
// BytedeskUtils.printLog('pick video path: ${videoFile.path}');
// if (videoFile != null) {
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: videoFile.path));
@ -975,9 +983,9 @@ class _ChatKFPageState extends State<ChatKFPage>
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugPrint(info.toJson().toString());
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // print('video path: ${_paths[0].path}, compress path: $afterPath');
// // BytedeskUtils.printLog('video path: ${_paths[0].path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
@ -986,7 +994,7 @@ class _ChatKFPageState extends State<ChatKFPage>
..add(UploadVideoEvent(filePath: _paths[0].path));
}
} catch (e) {
print('pick video error ${e.toString()}');
BytedeskUtils.printLog('pick video error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取视频");
}
}
@ -998,7 +1006,7 @@ class _ChatKFPageState extends State<ChatKFPage>
source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
//
if (pickedFile != null) {
print('take video path: ${pickedFile.path}');
BytedeskUtils.printLog('take video path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -1008,9 +1016,9 @@ class _ChatKFPageState extends State<ChatKFPage>
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugPrint(info.toJson().toString());
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // print('video path: ${pickedFile.path}, compress path: $afterPath');
// // BytedeskUtils.printLog('video path: ${pickedFile.path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
@ -1021,14 +1029,14 @@ class _ChatKFPageState extends State<ChatKFPage>
Fluttertoast.showToast(msg: '未录制视频');
}
} catch (e) {
print('take video error ${e.toString()}');
BytedeskUtils.printLog('take video error ${e.toString()}');
Fluttertoast.showToast(msg: "未录制视频");
}
}
//
// Future<void> _loadMoreMessages() async {
// print('load more');
// BytedeskUtils.printLog('load more');
// // TODO:
// _getMessages(_page, _size);
// }
@ -1042,7 +1050,7 @@ class _ChatKFPageState extends State<ChatKFPage>
//
List<Message> messageList = await _messageProvider.getTopicMessages(
_currentThread!.topic, _currentUid, page, size);
// print(messageList.length);
// BytedeskUtils.printLog(messageList.length);
int length = messageList.length;
for (var i = 0; i < length; i++) {
Message message = messageList[i];
@ -1103,15 +1111,16 @@ class _ChatKFPageState extends State<ChatKFPage>
if (message.status != BytedeskConstants.MESSAGE_STATUS_READ) {
//
if (message.isSend == 0) {
print('message.mid ${message.mid}');
print('_currentThread ${_currentThread!.tid}');
// BytedeskUtils.printLog('message.mid ${message.mid}');
// BytedeskUtils.printLog('_currentThread ${_currentThread!.tid}');
_bdMqtt.sendReceiptReadMessage(message.mid!, _currentThread!);
}
}
}
Future<Null> _appendMessage(Message message) async {
print('append:' + message.mid! + 'content:' + message.content!);
BytedeskUtils.printLog(
'append:' + message.mid! + 'content:' + message.content!);
pushToMessageArray(message, true);
}
@ -1130,7 +1139,7 @@ class _ChatKFPageState extends State<ChatKFPage>
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
// print("didChangeAppLifecycleState:" + state.toString());
// BytedeskUtils.printLog("didChangeAppLifecycleState:" + state.toString());
switch (state) {
case AppLifecycleState.inactive: //
break;
@ -1148,11 +1157,12 @@ class _ChatKFPageState extends State<ChatKFPage>
@override
void dispose() {
// print('chat_kf_page dispose');
// BytedeskUtils.printLog('chat_kf_page dispose');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, false);
WidgetsBinding.instance!.removeObserver(this);
_debounce?.cancel();
// _loadHistoryTimer?.cancel();
_loadHistoryTimer?.cancel();
// bytedeskEventBus.destroy(); // FIXME: destroy
super.dispose();
}
}

@ -21,6 +21,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
// import 'package:path_provider/path_provider.dart' as path_provider;
// TODO: APP
@ -96,7 +97,7 @@ class _ChatLSPageState extends State<ChatLSPage>
//
@override
void initState() {
// print('chat_kf_page init');
// BytedeskUtils.printLog('chat_kf_page init');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true);
//
if (widget.isThread! && widget.thread != null) {
@ -113,7 +114,7 @@ class _ChatLSPageState extends State<ChatLSPage>
WidgetsBinding.instance!.addObserver(this);
// buildhttps://blog.csdn.net/baoolong/article/details/85097318
// WidgetsBinding.instance.addPostFrameCallback((_) {
// print('addPostFrameCallback');
// BytedeskUtils.printLog('addPostFrameCallback');
// });
_listener();
super.initState();
@ -172,7 +173,7 @@ class _ChatLSPageState extends State<ChatLSPage>
//
if (state.threadResult.statusCode == 200 ||
state.threadResult.statusCode == 201) {
print('创建新会话');
BytedeskUtils.printLog('创建新会话');
//
// _messageProvider.insert(state.threadResult.msg!);
// TODO: pop
@ -189,7 +190,7 @@ class _ChatLSPageState extends State<ChatLSPage>
widget.postscript!, _currentThread!);
}
} else if (state.threadResult.statusCode == 202) {
print('提示排队中');
BytedeskUtils.printLog('提示排队中');
//
_messageProvider.insert(state.threadResult.msg!);
//
@ -208,7 +209,7 @@ class _ChatLSPageState extends State<ChatLSPage>
widget.postscript!, _currentThread!);
}
} else if (state.threadResult.statusCode == 203) {
print('当前非工作时间,请自助查询或留言');
BytedeskUtils.printLog('当前非工作时间,请自助查询或留言');
// TODO:
setState(() {
_currentThread = state.threadResult.msg!.thread;
@ -219,7 +220,7 @@ class _ChatLSPageState extends State<ChatLSPage>
_getMessages(_page, _size);
_appendMessage(state.threadResult.msg!);
} else if (state.threadResult.statusCode == 204) {
print('当前无客服在线,请自助查询或留言');
BytedeskUtils.printLog('当前无客服在线,请自助查询或留言');
// TODO:
setState(() {
_currentThread = state.threadResult.msg!.thread;
@ -230,7 +231,7 @@ class _ChatLSPageState extends State<ChatLSPage>
_getMessages(_page, _size);
_appendMessage(state.threadResult.msg!);
} else if (state.threadResult.statusCode == 205) {
print('咨询前问卷');
BytedeskUtils.printLog('咨询前问卷');
setState(() {
_currentThread = state.threadResult.msg!.thread;
});
@ -241,7 +242,7 @@ class _ChatLSPageState extends State<ChatLSPage>
_appendMessage(state.threadResult.msg!);
//
} else if (state.threadResult.statusCode == 206) {
print('返回机器人初始欢迎语 + 欢迎问题列表');
BytedeskUtils.printLog('返回机器人初始欢迎语 + 欢迎问题列表');
// TODO:
setState(() {
_isRobot = true;
@ -276,9 +277,10 @@ class _ChatLSPageState extends State<ChatLSPage>
),
BlocListener<MessageBloc, MessageState>(
listener: (context, state) {
print('message state change');
BytedeskUtils.printLog('message state change');
if (state is ReceiveMessageState) {
print('receive message:' + state.message!.content!);
BytedeskUtils.printLog(
'receive message:' + state.message!.content!);
} else if (state is UploadImageSuccess) {
_bdMqtt.sendImageMessage(
state.uploadJsonResult.url!, _currentThread!);
@ -345,7 +347,7 @@ class _ChatLSPageState extends State<ChatLSPage>
child: SmartRefresher(
enablePullDown: false,
onLoading: () async {
print('TODO: 下拉刷新'); //
BytedeskUtils.printLog('TODO: 下拉刷新'); //
// await Future.delayed(Duration(milliseconds: 1000));
_getMessages(_page, _size);
setState(() {});
@ -427,7 +429,7 @@ class _ChatLSPageState extends State<ChatLSPage>
if (_debounce?.isActive ?? false) _debounce!.cancel();
// 500
_debounce = Timer(const Duration(milliseconds: 500), () {
print('send preview $value');
BytedeskUtils.printLog('send preview $value');
// value != null &&
if (value.trim().length > 0) {
_bdMqtt.sendPreviewMessage(value, _currentThread!);
@ -486,7 +488,7 @@ class _ChatLSPageState extends State<ChatLSPage>
_listener() {
//
bytedeskEventBus.on<ReceiveMessageReceiptEventBus>().listen((event) {
// print('更新状态:' + event.status);
// BytedeskUtils.printLog('更新状态:' + event.status);
if (!this.mounted) {
return;
}
@ -503,7 +505,7 @@ class _ChatLSPageState extends State<ChatLSPage>
}
});
bytedeskEventBus.on<ReceiveMessagePreviewEventBus>().listen((event) {
// print('消息预知');
// BytedeskUtils.printLog('消息预知');
if (this.mounted) {
setState(() {
// TODO:
@ -514,7 +516,7 @@ class _ChatLSPageState extends State<ChatLSPage>
Timer(
Duration(seconds: 3),
() {
// print('timer');
// BytedeskUtils.printLog('timer');
if (this.mounted) {
setState(() {
_title = widget.title;
@ -525,11 +527,11 @@ class _ChatLSPageState extends State<ChatLSPage>
});
// DeleteMessageEventBus
// bytedeskEventBus.on<ReceiveMessageRecallEventBus>().listen((event) {
// print('消息撤回');
// BytedeskUtils.printLog('消息撤回');
// });
//
bytedeskEventBus.on<ReceiveMessageEventBus>().listen((event) {
// print('receive message:' + event.message!.content);
// BytedeskUtils.printLog('receive message:' + event.message!.content);
if (_currentThread != null &&
(event.message.thread!.topic != _currentThread!.topic)) {
return;
@ -568,7 +570,7 @@ class _ChatLSPageState extends State<ChatLSPage>
bytedeskEventBus.on<QueryAnswerEventBus>().listen((event) {
//
if (this.mounted) {
print(
BytedeskUtils.printLog(
'aid ${event.aid}, question ${event.question}, answer ${event.answer}');
//
// BlocProvider.of<MessageBloc>(context)
@ -585,7 +587,7 @@ class _ChatLSPageState extends State<ChatLSPage>
//
// if (_scrollController.position.pixels ==
// _scrollController.position.maxScrollExtent) {
// print('已经到底了');
// BytedeskUtils.printLog('已经到底了');
// }
});
}
@ -597,7 +599,7 @@ class _ChatLSPageState extends State<ChatLSPage>
source: ImageSource.gallery, maxWidth: 800, imageQuality: 95);
//
if (pickedFile != null) {
print('pick image path: ${pickedFile.path}');
BytedeskUtils.printLog('pick image path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -606,7 +608,7 @@ class _ChatLSPageState extends State<ChatLSPage>
// "/" +
// BytedeskUtils.currentTimeMillis().toString() +
// ".jpg";
// print('targetPath: $targetPath');
// BytedeskUtils.printLog('targetPath: $targetPath');
// await BytedeskUtils.compressImage(File(pickedFile.path), targetPath);
// //
// BlocProvider.of<MessageBloc>(context)
@ -618,7 +620,7 @@ class _ChatLSPageState extends State<ChatLSPage>
Fluttertoast.showToast(msg: '未选取图片');
}
} catch (e) {
print('pick image error ${e.toString()}');
BytedeskUtils.printLog('pick image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -630,7 +632,7 @@ class _ChatLSPageState extends State<ChatLSPage>
source: ImageSource.camera, maxWidth: 800, imageQuality: 95);
//
if (pickedFile != null) {
print('take image path: ${pickedFile.path}');
BytedeskUtils.printLog('take image path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -639,7 +641,7 @@ class _ChatLSPageState extends State<ChatLSPage>
// "/" +
// BytedeskUtils.currentTimeMillis().toString() +
// ".jpg";
// print('targetPath: $targetPath');
// BytedeskUtils.printLog('targetPath: $targetPath');
// await BytedeskUtils.compressImage(File(pickedFile.path), targetPath);
// //
// BlocProvider.of<MessageBloc>(context)
@ -651,7 +653,7 @@ class _ChatLSPageState extends State<ChatLSPage>
Fluttertoast.showToast(msg: '未拍照');
}
} catch (e) {
print('take image error ${e.toString()}');
BytedeskUtils.printLog('take image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -663,7 +665,7 @@ class _ChatLSPageState extends State<ChatLSPage>
try {
// final PickedFile videoFile = await _picker.getVideo(
// source: ImageSource.gallery, maxDuration: const Duration(seconds: 10));
// print('pick video path: ${videoFile.path}');
// BytedeskUtils.printLog('pick video path: ${videoFile.path}');
// if (videoFile != null) {
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: videoFile.path));
@ -687,9 +689,9 @@ class _ChatLSPageState extends State<ChatLSPage>
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugPrint(info.toJson().toString());
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // print('video path: ${_paths[0].path}, compress path: $afterPath');
// // BytedeskUtils.printLog('video path: ${_paths[0].path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
@ -698,7 +700,7 @@ class _ChatLSPageState extends State<ChatLSPage>
..add(UploadVideoEvent(filePath: _paths[0].path));
}
} catch (e) {
print('pick video error ${e.toString()}');
BytedeskUtils.printLog('pick video error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取视频");
}
}
@ -710,7 +712,7 @@ class _ChatLSPageState extends State<ChatLSPage>
source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
//
if (pickedFile != null) {
print('take video path: ${pickedFile.path}');
BytedeskUtils.printLog('take video path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
@ -720,9 +722,9 @@ class _ChatLSPageState extends State<ChatLSPage>
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugPrint(info.toJson().toString());
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // print('video path: ${pickedFile.path}, compress path: $afterPath');
// // BytedeskUtils.printLog('video path: ${pickedFile.path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
@ -733,14 +735,14 @@ class _ChatLSPageState extends State<ChatLSPage>
Fluttertoast.showToast(msg: '未录制视频');
}
} catch (e) {
print('take video error ${e.toString()}');
BytedeskUtils.printLog('take video error ${e.toString()}');
Fluttertoast.showToast(msg: "未录制视频");
}
}
//
// Future<void> _loadMoreMessages() async {
// print('load more');
// BytedeskUtils.printLog('load more');
// // TODO:
// _getMessages(_page, _size);
// }
@ -769,7 +771,7 @@ class _ChatLSPageState extends State<ChatLSPage>
}
Future<Null> _appendMessage(Message message) async {
// print('append:' + message!.mid);
// BytedeskUtils.printLog('append:' + message!.mid);
_messageProvider.insert(message);
MessageWidget messageWidget = new MessageWidget(
message: message,
@ -798,7 +800,7 @@ class _ChatLSPageState extends State<ChatLSPage>
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
// print("didChangeAppLifecycleState:" + state.toString());
// BytedeskUtils.printLog("didChangeAppLifecycleState:" + state.toString());
switch (state) {
case AppLifecycleState.inactive: //
break;
@ -816,7 +818,7 @@ class _ChatLSPageState extends State<ChatLSPage>
@override
void dispose() {
// print('chat_kf_page dispose');
// BytedeskUtils.printLog('chat_kf_page dispose');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, false);
WidgetsBinding.instance!.removeObserver(this);
_debounce?.cancel();

@ -51,7 +51,7 @@ class _ChatWebViewPageState extends State<ChatWebViewPage> {
// padding: new EdgeInsets.only(right: 10),
// child: InkWell(
// onTap: () {
// print('share');
// BytedeskUtils.printLog('share');
// // showShareSheet(context);
// },
// child: Image.asset(
@ -120,7 +120,7 @@ class _ChatWebViewPageState extends State<ChatWebViewPage> {
// );
// }).then((value) {
// //
// print('share $value');
// BytedeskUtils.printLog('share $value');
// if (value == 'wechat') {
// // TODO:
// } else if (value == 'weibo') {

@ -13,6 +13,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
//
class MessageWidget extends StatelessWidget {
@ -124,7 +125,7 @@ class MessageWidget extends StatelessWidget {
];
},
onSelected: (value) {
print('send menu $value');
BytedeskUtils.printLog('send menu $value');
//
if (value == 'copy') {
///
@ -150,7 +151,7 @@ class MessageWidget extends StatelessWidget {
}
},
onCancelled: () {
// print('cancel');
// BytedeskUtils.printLog('cancel');
},
);
}
@ -212,11 +213,11 @@ class MessageWidget extends StatelessWidget {
String imageUrl = commodityJson['imageUrl'].toString();
return InkWell(
onTap: () {
// print('message!.type ${message!.type}, message!.content ${message!.content}');
// BytedeskUtils.printLog('message!.type ${message!.type}, message!.content ${message!.content}');
if (customCallback != null) {
customCallback!(message.content!);
} else {
print('customCallback is null');
BytedeskUtils.printLog('customCallback is null');
}
},
child: Row(
@ -271,7 +272,7 @@ class MessageWidget extends StatelessWidget {
} else if (message.type == BytedeskConstants.MESSAGE_TYPE_VIDEO) {
return InkWell(
onTap: () {
print('play video');
BytedeskUtils.printLog('play video');
Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
return new VideoPlayPage(videoUrl: message.videoUrl);
}));
@ -365,7 +366,7 @@ class MessageWidget extends StatelessWidget {
];
},
onSelected: (value) {
print('send menu $value');
BytedeskUtils.printLog('send menu $value');
//
if (value == 'copy') {
///
@ -389,7 +390,7 @@ class MessageWidget extends StatelessWidget {
}
},
onCancelled: () {
// print('cancel');
// BytedeskUtils.printLog('cancel');
},
);
}
@ -464,7 +465,7 @@ class MessageWidget extends StatelessWidget {
},
onImageTap: (src, _, __, ___) {
//
// print("open image $src");
// BytedeskUtils.printLog("open image $src");
Navigator.push(
context,
MaterialPageRoute(
@ -491,7 +492,7 @@ class MessageWidget extends StatelessWidget {
);
},
onImageError: (exception, stackTrace) {
print(exception);
BytedeskUtils.printLog(exception);
},
),
),
@ -526,7 +527,7 @@ class MessageWidget extends StatelessWidget {
style: TextStyle(color: Colors.blue),
),
onTap: () => {
// print('object:' + answer.question),
// BytedeskUtils.printLog('object:' + answer.question),
bytedeskEventBus.fire(QueryAnswerEventBus(
answer.aid!,
answer.question!,
@ -547,7 +548,7 @@ class MessageWidget extends StatelessWidget {
style: TextStyle(color: Theme.of(context).primaryColor),
),
onTap: () {
print('请求人工客服');
BytedeskUtils.printLog('请求人工客服');
bytedeskEventBus.fire(RequestAgentThreadEventBus());
},
)
@ -601,7 +602,7 @@ class MessageWidget extends StatelessWidget {
style: TextStyle(color: Colors.blue),
),
onTap: () => {
// print(category.name),
// BytedeskUtils.printLog(category.name),
bytedeskEventBus.fire(QueryCategoryEventBus(
category.cid!, category.name!))
}),
@ -620,7 +621,7 @@ class MessageWidget extends StatelessWidget {
style: TextStyle(color: Theme.of(context).primaryColor),
),
onTap: () {
print('请求人工客服');
BytedeskUtils.printLog('请求人工客服');
bytedeskEventBus.fire(RequestAgentThreadEventBus());
},
)
@ -648,11 +649,11 @@ class MessageWidget extends StatelessWidget {
String imageUrl = commodityJson['imageUrl'].toString();
return InkWell(
onTap: () {
// print('message!.type ${message!.type}, message!.content ${message!.content}');
// BytedeskUtils.printLog('message!.type ${message!.type}, message!.content ${message!.content}');
if (customCallback != null) {
customCallback!(message.content!);
} else {
print('customCallback is null');
BytedeskUtils.printLog('customCallback is null');
}
},
child: Row(
@ -707,7 +708,7 @@ class MessageWidget extends StatelessWidget {
} else if (message.type == BytedeskConstants.MESSAGE_TYPE_VIDEO) {
return InkWell(
onTap: () {
print('play video');
BytedeskUtils.printLog('play video');
Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
return new VideoPlayPage(videoUrl: message.videoUrl);
}));

@ -7,6 +7,7 @@ import 'package:bytedesk_kefu/ui/widget/loading_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
// import 'package:flutter_easyrefresh/phoenix_header.dart';
class HelpArticleListPage extends StatefulWidget {
@ -44,7 +45,7 @@ class _HelpArticleListPageState extends State<HelpArticleListPage>
body: BlocConsumer<HelpBloc, HelpState>(listener: (context, state) {
// do stuff here based on BlocA's state
if (state is HelpArticleState) {
print('help article load success length: ' +
BytedeskUtils.printLog('help article load success length: ' +
state.articleList.length.toString());
if (state.articleList.length == 0) {
// Toast.show('没有更多了哦');

@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
// import 'package:flutter_easyrefresh/phoenix_header.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
class HelpPage extends StatefulWidget {
final String? uid;
@ -43,7 +44,7 @@ class _HelpPageState extends State<HelpPage>
body: BlocConsumer<HelpBloc, HelpState>(listener: (context, state) {
// do stuff here based on BlocA's state
if (state is HelpCategoryState) {
print('help category load success length: ' +
BytedeskUtils.printLog('help category load success length: ' +
state.categoryList.length.toString());
if (state.categoryList.length == 0) {
// Toast.show('没有更多了哦');

@ -6,6 +6,7 @@ import 'package:bytedesk_kefu/ui/widget/loading_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
// import 'package:flutter_easyrefresh/phoenix_header.dart';
class FeedbackPage extends StatefulWidget {
@ -47,7 +48,7 @@ class _FeedbackPageState extends State<FeedbackPage>
BlocConsumer<FeedbackBloc, FeedbackState>(listener: (context, state) {
// do stuff here based on BlocA's state
if (state is FeedbackCategoryState) {
print('help category load success length: ' +
BytedeskUtils.printLog('help category load success length: ' +
state.categoryList.length.toString());
if (state.categoryList.length == 0) {
// Toast.show('没有更多了哦');

@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
class FeedbackSubmitPage extends StatefulWidget {
final HelpCategory? helpCategory;
@ -35,7 +36,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
//
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
// print('scroll to bottom');
// BytedeskUtils.printLog('scroll to bottom');
}
});
super.initState();
@ -44,7 +45,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
@override
Widget build(BuildContext context) {
//
print('fileList的内容: $_fileList');
BytedeskUtils.printLog('fileList的内容: $_fileList');
if (_selectedImageFile != null) {
_fileList.add(_selectedImageFile!);
}
@ -62,7 +63,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
margin: EdgeInsets.only(right: 10),
child: InkWell(
onTap: () {
print('submit');
BytedeskUtils.printLog('submit');
// TODO:
BlocProvider.of<FeedbackBloc>(context)
..add(SubmitFeedbackEvent(
@ -222,7 +223,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
try {
XFile? pickedFile = await picker.pickImage(
source: ImageSource.gallery, maxWidth: 800, imageQuality: 95);
print('pick image path: ${pickedFile!.path}');
BytedeskUtils.printLog('pick image path: ${pickedFile!.path}');
setState(() {
_selectedImageFile = File(pickedFile.path);
});
@ -230,7 +231,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
BlocProvider.of<FeedbackBloc>(context)
..add(UploadImageEvent(filePath: pickedFile.path));
} catch (e) {
print('pick image error ${e.toString()}');
BytedeskUtils.printLog('pick image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -244,7 +245,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
try {
XFile? pickedFile = await picker.pickImage(
source: ImageSource.camera, maxWidth: 800, imageQuality: 95);
print('take image path: ${pickedFile!.path}');
BytedeskUtils.printLog('take image path: ${pickedFile!.path}');
setState(() {
_selectedImageFile = File(pickedFile.path);
});
@ -252,7 +253,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
BlocProvider.of<FeedbackBloc>(context)
..add(UploadImageEvent(filePath: pickedFile.path));
} catch (e) {
print('take image error ${e.toString()}');
BytedeskUtils.printLog('take image error ${e.toString()}');
Fluttertoast.showToast(msg: "未选取图片");
}
}
@ -270,7 +271,7 @@ class _FeedbackSubmitPageState extends State<FeedbackSubmitPage> {
// ImagePicker.pickImage(source: source).then((result) {
// setState(() {
// _selectedImageFile = result;
// print("执行刷新:");
// BytedeskUtils.printLog("执行刷新:");
// });
// });
// },

@ -52,7 +52,7 @@ class _LeaveMsgPageState extends State<LeaveMsgPage> {
//
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
// print('scroll to bottom');
// BytedeskUtils.printLog('scroll to bottom');
}
});
super.initState();
@ -61,7 +61,7 @@ class _LeaveMsgPageState extends State<LeaveMsgPage> {
@override
Widget build(BuildContext context) {
//
// print('fileList的内容: $_fileList');
// BytedeskUtils.printLog('fileList的内容: $_fileList');
// if (_selectedImageFile != null) {
// _fileList.add(_selectedImageFile!);
// }
@ -282,7 +282,7 @@ class _LeaveMsgPageState extends State<LeaveMsgPage> {
// try {
// XFile? pickedFile = await picker.pickImage(
// source: ImageSource.gallery, maxWidth: 800, imageQuality: 95);
// print('pick image path: ${pickedFile!.path}');
// BytedeskUtils.printLog('pick image path: ${pickedFile!.path}');
// setState(() {
// _selectedImageFile = File(pickedFile.path);
// });
@ -290,7 +290,7 @@ class _LeaveMsgPageState extends State<LeaveMsgPage> {
// BlocProvider.of<LeaveMsgBloc>(context)
// ..add(UploadImageEvent(filePath: pickedFile.path));
// } catch (e) {
// print('pick image error ${e.toString()}');
// BytedeskUtils.printLog('pick image error ${e.toString()}');
// Fluttertoast.showToast(msg: "未选取图片");
// }
// }
@ -304,7 +304,7 @@ class _LeaveMsgPageState extends State<LeaveMsgPage> {
// try {
// XFile? pickedFile = await picker.pickImage(
// source: ImageSource.camera, maxWidth: 800, imageQuality: 95);
// print('take image path: ${pickedFile!.path}');
// BytedeskUtils.printLog('take image path: ${pickedFile!.path}');
// setState(() {
// _selectedImageFile = File(pickedFile.path);
// });
@ -312,7 +312,7 @@ class _LeaveMsgPageState extends State<LeaveMsgPage> {
// BlocProvider.of<LeaveMsgBloc>(context)
// ..add(UploadImageEvent(filePath: pickedFile.path));
// } catch (e) {
// print('take image error ${e.toString()}');
// BytedeskUtils.printLog('take image error ${e.toString()}');
// Fluttertoast.showToast(msg: "未选取图片");
// }
// }

@ -61,7 +61,7 @@ class PhotoViewWrapper extends StatelessWidget {
// color: Colors.pink,
child: InkWell(
onTap: () {
print('imageurl: $imageUrl');
BytedeskUtils.printLog('imageurl: $imageUrl');
BytedeskUtils.saveImage(imageUrl!);
},
child: Text(

@ -18,7 +18,7 @@ class BytedeskConstants {
// static const String httpUploadUrl = 'http://' + mqttHost + ':8000';
// static const String host = mqttHost + ':8000';
// static const int mqttPort = 3883; // not secure
// static const String mqttHost = '172.16.0.78';
// static const String mqttHost = '172.20.10.7';
//
// static const bool isDebug = true;
@ -30,8 +30,8 @@ class BytedeskConstants {
// static const String httpBaseUrlAndroid = 'http://' + mqttHost + ':8000';
// static const String httpBaseUrliOS = 'http://' + mqttHost + ':8000';
// static const String httpUploadUrl = 'http://' + mqttHost + ':8000';
// static const String mqttHost = '127.0.0.1';
// static const String host = mqttHost + ':8000';
// static const String mqttHost = '127.0.0.1';
// static const String mqttHost = '10.0.2.2'; //
//
@ -45,7 +45,7 @@ class BytedeskConstants {
// static const String httpBaseUrliOS = 'http://' + mqttHost + ':8000';
// static const String httpUploadUrl = 'http://' + mqttHost + ':8000';
// static const String host = mqttHost + ':8000';
// static const String mqttHost = '192.168.0.103';
// static const String mqttHost = '192.168.0.106';
// 线
static const bool isDebug = false; // false;

@ -39,6 +39,12 @@ class BytedeskUtils {
static bool get isFuchsia => Platform.isFuchsia;
static bool get isIOS => Platform.isIOS;
static void printLog(content) {
if (BytedeskConstants.isDebug) {
print(content);
}
}
static String client() {
if (isWeb) {
return 'flutter_web';
@ -235,7 +241,7 @@ class BytedeskUtils {
// https://pub.dev/packages/flutter_image_compress
// static Future<File> compressImage(File file, String targetPath) async {
// // print("compressImage");
// // BytedeskUtils.printLog("compressImage");
// final result = await FlutterImageCompress.compressAndGetFile(
// file.absolute.path,
// targetPath,
@ -307,7 +313,7 @@ class BytedeskUtils {
}
static Future<bool> requestPermission() async {
print('请求定位');
BytedeskUtils.printLog('请求定位');
return true;
// FIXME:
// if (await Permission.location.request().isGranted) {
@ -402,9 +408,9 @@ class BytedeskUtils {
if (result == null || result == '') throw '图片保存失败';
//
Fluttertoast.showToast(msg: "保存成功");
print("保存成功");
BytedeskUtils.printLog("保存成功");
} catch (e) {
print(e.toString());
BytedeskUtils.printLog(e.toString());
}
}

@ -1,6 +1,6 @@
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.
version: 1.3.1
version: 1.3.2
homepage: https://www.weikefu.net
environment:
@ -49,7 +49,6 @@ dependencies:
# https://pub.dev/packages/flutter_easyloading
flutter_easyloading: ^3.0.3
# H5-webchat https://pub.dev/packages/webview_flutter
# webview_flutter: ^3.0.2
webview_flutter: ^2.0.4
# https://pub.dev/packages/device_info
device_info: ^2.0.3

Loading…
Cancel
Save