|
|
|
@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
// 多种客服对话类型列表页面
|
|
|
|
|
class ChatTypePage extends StatefulWidget {
|
|
|
|
|
ChatTypePage({Key? key}) : super(key: key);
|
|
|
|
|
const ChatTypePage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ChatTypePageState createState() => _ChatTypePageState();
|
|
|
|
@ -15,39 +15,57 @@ class ChatTypePage extends StatefulWidget {
|
|
|
|
|
class _ChatTypePageState extends State<ChatTypePage> {
|
|
|
|
|
// 第二步:到 客服管理->技能组-有一列 ‘唯一ID(wId)’, 默认设置工作组wid
|
|
|
|
|
// 说明:一个技能组可以分配多个客服,访客会按照一定的规则分配给组内的各个客服账号
|
|
|
|
|
String _workGroupWid = "201807171659201"; // 默认人工
|
|
|
|
|
String _workGroupWidRobot = "201809061716221"; // 默认机器人, 在管理后台开启或关闭机器人
|
|
|
|
|
final String _workGroupWid = "201807171659201"; // 默认人工
|
|
|
|
|
final String _workGroupWidRobot = "201809061716221"; // 默认机器人, 在管理后台开启或关闭机器人
|
|
|
|
|
// 说明:直接发送给此一个客服账号,一对一会话
|
|
|
|
|
String _agentUid = "201808221551193";
|
|
|
|
|
final String _agentUid = "201808221551193";
|
|
|
|
|
// 未读消息数目
|
|
|
|
|
String _unreadMessageCount = "0";
|
|
|
|
|
//
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
// 加载未读消息数目
|
|
|
|
|
_getUnreadCountVisitor();
|
|
|
|
|
//
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
title: Text('对话类型'),
|
|
|
|
|
title: const Text('对话类型'),
|
|
|
|
|
elevation: 0,
|
|
|
|
|
),
|
|
|
|
|
body: ListView(
|
|
|
|
|
children: ListTile.divideTiles(context: context, tiles: [
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('技能组客服'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: Text('未读消息数目:' + _unreadMessageCount),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
// 加载未读消息数目
|
|
|
|
|
_getUnreadCountVisitor();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: const Text('技能组客服'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
BytedeskKefu.startWorkGroupChat(
|
|
|
|
|
context, _workGroupWid, "技能组客服-默认人工");
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('技能组客服-机器人'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('技能组客服-机器人'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
BytedeskKefu.startWorkGroupChat(
|
|
|
|
|
context, _workGroupWidRobot, "技能组客服-默认机器人");
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('技能组客服-电商'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('技能组客服-电商'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
// 商品信息,type/title/content/price/url/imageUrl/id/categoryCode
|
|
|
|
|
// 注意:长度不能大于500字符
|
|
|
|
@ -69,8 +87,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('技能组客服-电商-回调'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('技能组客服-电商-回调'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
// 商品信息,type/title/content/price/url/imageUrl/id/categoryCode
|
|
|
|
|
// 注意:长度不能大于500字符
|
|
|
|
@ -99,8 +117,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('技能组客服-附言'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('技能组客服-附言'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
BytedeskKefu.startWorkGroupChatPostscript(
|
|
|
|
|
context, _workGroupWid, "技能组客服-附言", "随便说点什么吧,我会自动发送给客服");
|
|
|
|
@ -110,15 +128,15 @@ class _ChatTypePageState extends State<ChatTypePage> {
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('指定一对一客服'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('指定一对一客服'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
BytedeskKefu.startAppointedChat(context, _agentUid, "指定一对一客服");
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('指定一对一客服-电商'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('指定一对一客服-电商'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
// 商品信息,type/title/content/price/url/imageUrl/id/categoryCode
|
|
|
|
|
// 注意:长度不能大于500字符
|
|
|
|
@ -139,8 +157,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('指定一对一客服-电商-回调'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('指定一对一客服-电商-回调'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
// 商品信息,type/title/content/price/url/imageUrl/id/categoryCode
|
|
|
|
|
// 注意:长度不能大于500字符
|
|
|
|
@ -168,8 +186,8 @@ class _ChatTypePageState extends State<ChatTypePage> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('指定一对一客服-附言'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('指定一对一客服-附言'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
BytedeskKefu.startAppointedChatPostscript(
|
|
|
|
|
context, _agentUid, "指定一对一客服-附言", "随便说点什么吧,我会自动发送给客服");
|
|
|
|
@ -179,13 +197,13 @@ class _ChatTypePageState extends State<ChatTypePage> {
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text('H5网页会话'),
|
|
|
|
|
trailing: Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
title: const Text('H5网页会话'),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
print('h5 chat');
|
|
|
|
|
// 注意: 登录后台->客服管理->技能组(或客服账号)->获取客服代码 获取相应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在线客服演示';
|
|
|
|
|
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;
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|