增加查询未读消息接口

master
jack ning 3 years ago
parent ebdcc713cc
commit 01d8b06e7b

@ -18,6 +18,7 @@
- 消息撤回 - 消息撤回
- 输入状态(对方正在输入) - 输入状态(对方正在输入)
- 发送/播放视频 - 发送/播放视频
- 查询未读消息数
<!-- - 提交工单 --> <!-- - 提交工单 -->
<!-- - 意见反馈 --> <!-- - 意见反馈 -->

@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
// //
class ChatTypePage extends StatefulWidget { class ChatTypePage extends StatefulWidget {
ChatTypePage({Key? key}) : super(key: key); const ChatTypePage({Key? key}) : super(key: key);
@override @override
_ChatTypePageState createState() => _ChatTypePageState(); _ChatTypePageState createState() => _ChatTypePageState();
@ -15,39 +15,57 @@ class ChatTypePage extends StatefulWidget {
class _ChatTypePageState extends State<ChatTypePage> { class _ChatTypePageState extends State<ChatTypePage> {
// ->- IDwId, wid // ->- IDwId, wid
// 访 // 访
String _workGroupWid = "201807171659201"; // final String _workGroupWid = "201807171659201"; //
String _workGroupWidRobot = "201809061716221"; // , final String _workGroupWidRobot = "201809061716221"; // ,
// //
String _agentUid = "201808221551193"; final String _agentUid = "201808221551193";
//
String _unreadMessageCount = "0";
//
@override
void initState() {
//
_getUnreadCountVisitor();
//
super.initState();
}
// //
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('对话类型'), title: const Text('对话类型'),
elevation: 0, elevation: 0,
), ),
body: ListView( body: ListView(
children: ListTile.divideTiles(context: context, tiles: [ children: ListTile.divideTiles(context: context, tiles: [
ListTile( ListTile(
title: Text('技能组客服'), title: Text('未读消息数目:' + _unreadMessageCount),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () {
//
_getUnreadCountVisitor();
},
),
ListTile(
title: const Text('技能组客服'),
trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
BytedeskKefu.startWorkGroupChat( BytedeskKefu.startWorkGroupChat(
context, _workGroupWid, "技能组客服-默认人工"); context, _workGroupWid, "技能组客服-默认人工");
}, },
), ),
ListTile( ListTile(
title: Text('技能组客服-机器人'), title: const Text('技能组客服-机器人'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
BytedeskKefu.startWorkGroupChat( BytedeskKefu.startWorkGroupChat(
context, _workGroupWidRobot, "技能组客服-默认机器人"); context, _workGroupWidRobot, "技能组客服-默认机器人");
}, },
), ),
ListTile( ListTile(
title: Text('技能组客服-电商'), title: const Text('技能组客服-电商'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
// type/title/content/price/url/imageUrl/id/categoryCode // type/title/content/price/url/imageUrl/id/categoryCode
// 500 // 500
@ -69,8 +87,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
}, },
), ),
ListTile( ListTile(
title: Text('技能组客服-电商-回调'), title: const Text('技能组客服-电商-回调'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
// type/title/content/price/url/imageUrl/id/categoryCode // type/title/content/price/url/imageUrl/id/categoryCode
// 500 // 500
@ -99,8 +117,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
}, },
), ),
ListTile( ListTile(
title: Text('技能组客服-附言'), title: const Text('技能组客服-附言'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
BytedeskKefu.startWorkGroupChatPostscript( BytedeskKefu.startWorkGroupChatPostscript(
context, _workGroupWid, "技能组客服-附言", "随便说点什么吧,我会自动发送给客服"); context, _workGroupWid, "技能组客服-附言", "随便说点什么吧,我会自动发送给客服");
@ -110,15 +128,15 @@ class _ChatTypePageState extends State<ChatTypePage> {
height: 20, height: 20,
), ),
ListTile( ListTile(
title: Text('指定一对一客服'), title: const Text('指定一对一客服'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
BytedeskKefu.startAppointedChat(context, _agentUid, "指定一对一客服"); BytedeskKefu.startAppointedChat(context, _agentUid, "指定一对一客服");
}, },
), ),
ListTile( ListTile(
title: Text('指定一对一客服-电商'), title: const Text('指定一对一客服-电商'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
// type/title/content/price/url/imageUrl/id/categoryCode // type/title/content/price/url/imageUrl/id/categoryCode
// 500 // 500
@ -139,8 +157,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
}, },
), ),
ListTile( ListTile(
title: Text('指定一对一客服-电商-回调'), title: const Text('指定一对一客服-电商-回调'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
// type/title/content/price/url/imageUrl/id/categoryCode // type/title/content/price/url/imageUrl/id/categoryCode
// 500 // 500
@ -168,8 +186,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
}, },
), ),
ListTile( ListTile(
title: Text('指定一对一客服-附言'), title: const Text('指定一对一客服-附言'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
BytedeskKefu.startAppointedChatPostscript( BytedeskKefu.startAppointedChatPostscript(
context, _agentUid, "指定一对一客服-附言", "随便说点什么吧,我会自动发送给客服"); context, _agentUid, "指定一对一客服-附言", "随便说点什么吧,我会自动发送给客服");
@ -179,13 +197,13 @@ class _ChatTypePageState extends State<ChatTypePage> {
height: 20, height: 20,
), ),
ListTile( ListTile(
title: Text('H5网页会话'), title: const Text('H5网页会话'),
trailing: Icon(Icons.keyboard_arrow_right), trailing: const Icon(Icons.keyboard_arrow_right),
onTap: () { onTap: () {
print('h5 chat'); print('h5 chat');
// : ->->()-> URL // : ->->()-> URL
String url = String url =
"http://www.bytedesk.com/chat?sub=vip&uid=201808221551193&wid=201807171659201&type=workGroup&aid=&hidenav=1&ph=ph"; "https://h1.kefux.cn/chat/h5/index.html?sub=vip&uid=201808221551193&wid=201807171659201&type=workGroup&aid=&hidenav=1&ph=ph";
String title = 'H5在线客服演示'; String title = 'H5在线客服演示';
BytedeskKefu.startH5Chat(context, url, title); BytedeskKefu.startH5Chat(context, url, title);
}, },
@ -194,4 +212,14 @@ class _ChatTypePageState extends State<ChatTypePage> {
), ),
); );
} }
void _getUnreadCountVisitor() {
// 线
BytedeskKefu.getUnreadCountVisitor().then((count) => {
print('unreadcount:' + count),
setState(() {
_unreadMessageCount = count;
})
});
}
} }

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

Loading…
Cancel
Save