You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2 KiB

4 years ago
import 'package:bytedesk_kefu/bytedesk_kefu.dart';
import 'package:flutter/material.dart';
// 查询技能组和指定客服账号的在线状态
class OnlineStatusPage extends StatefulWidget {
3 years ago
const OnlineStatusPage({Key? key}) : super(key: key);
4 years ago
@override
_OnlineStatusPageState createState() => _OnlineStatusPageState();
}
class _OnlineStatusPageState extends State<OnlineStatusPage> {
// 到 客服管理->技能组-有一列 唯一IDwId
String _workGroupWid = "201807171659201";
// 到 客服管理->客服账号-有一列 唯一IDuId
String _agentUid = "201808221551193";
//
4 years ago
String _workGroupStatus = ''; // 注online 代表在线offline 代表离线
String _agentStatus = ''; // 注online 代表在线offline 代表离线
4 years ago
//
@override
void initState() {
4 years ago
// 获取技能组在线状态
4 years ago
_getWorkGroupStatus();
4 years ago
// 获取指定客服在线状态
4 years ago
_getAgentStatus();
super.initState();
}
//
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
3 years ago
title: const Text('在线状态'),
4 years ago
elevation: 0,
),
body: ListView(
children: ListTile.divideTiles(
context: context,
tiles: [
ListTile(
3 years ago
title: const Text('技能组在线状态'),
4 years ago
subtitle: Text(_workGroupStatus),
onTap: () {
_getWorkGroupStatus();
},
),
ListTile(
3 years ago
title: const Text('客服在线状态'),
4 years ago
subtitle: Text(_agentStatus),
onTap: () {
_getAgentStatus();
},
),
],
).toList()),
);
}
void _getWorkGroupStatus() {
4 years ago
// 获取技能组在线状态:当技能组中至少有一个客服在线时,显示在线
4 years ago
BytedeskKefu.getWorkGroupStatus(_workGroupWid).then((status) => {
print(status),
setState(() {
_workGroupStatus = status;
})
});
}
void _getAgentStatus() {
4 years ago
// 获取指定客服在线状态
4 years ago
BytedeskKefu.getAgentStatus(_agentUid).then((status) => {
print(status),
setState(() {
_agentStatus = status;
})
});
}
}