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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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