master
jack ning 3 years ago
parent 8c7df6205d
commit dcd34c17ed

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save