|
|
@ -119,12 +119,14 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
String goodPrice = '';
|
|
|
|
String goodPrice = '';
|
|
|
|
String goodUrl = '';
|
|
|
|
String goodUrl = '';
|
|
|
|
bool showGood = false;
|
|
|
|
bool showGood = false;
|
|
|
|
|
|
|
|
String customGoods = '';
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
if (widget.custom != null &&
|
|
|
|
customGoods = widget.custom??'';
|
|
|
|
widget.custom!.trim().length > 0){
|
|
|
|
if (
|
|
|
|
|
|
|
|
customGoods.trim().length > 0){
|
|
|
|
showGood = true;
|
|
|
|
showGood = true;
|
|
|
|
Map<String, dynamic> json = jsonDecode(widget.custom??"");
|
|
|
|
Map<String, dynamic> json = jsonDecode(customGoods);
|
|
|
|
json.forEach((key, value) {
|
|
|
|
json.forEach((key, value) {
|
|
|
|
//typeOne等所对应的数组数据
|
|
|
|
//typeOne等所对应的数组数据
|
|
|
|
if(key=='title'){
|
|
|
|
if(key=='title'){
|
|
|
@ -216,424 +218,429 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
super.build(context);
|
|
|
|
super.build(context);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
return Scaffold (
|
|
|
|
return GestureDetector(
|
|
|
|
appBar: AppBar(
|
|
|
|
onTap: (){
|
|
|
|
title: Text(_title ?? '请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333),fontSize: 16),),
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
},
|
|
|
|
centerTitle: true,
|
|
|
|
child: Scaffold (
|
|
|
|
elevation: 0,
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: IconButton(
|
|
|
|
title: Text(_title ?? '请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333),fontSize: 16),),
|
|
|
|
icon: Icon(
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
Icons.arrow_back_ios,
|
|
|
|
centerTitle: true,
|
|
|
|
size: 17,
|
|
|
|
elevation: 0,
|
|
|
|
color: Color(0xFF333333),
|
|
|
|
leading: IconButton(
|
|
|
|
|
|
|
|
icon: Icon(
|
|
|
|
|
|
|
|
Icons.arrow_back_ios,
|
|
|
|
|
|
|
|
size: 17,
|
|
|
|
|
|
|
|
color: Color(0xFF333333),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
onPressed:
|
|
|
|
|
|
|
|
() {
|
|
|
|
|
|
|
|
Navigator.maybePop(context);
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
actions: [
|
|
|
|
|
|
|
|
// TODO: 评价
|
|
|
|
|
|
|
|
// TODO: 常见问题
|
|
|
|
|
|
|
|
Visibility(
|
|
|
|
|
|
|
|
visible: _isRobot,
|
|
|
|
|
|
|
|
child: Align(
|
|
|
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
padding: new EdgeInsets.only(right: 10),
|
|
|
|
|
|
|
|
width: 60,
|
|
|
|
|
|
|
|
child: InkWell(
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
BlocProvider.of<ThreadBloc>(context)
|
|
|
|
|
|
|
|
..add(RequestAgentEvent(
|
|
|
|
|
|
|
|
wid: widget.wid,
|
|
|
|
|
|
|
|
aid: widget.aid,
|
|
|
|
|
|
|
|
type: widget.type));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
'转人工',
|
|
|
|
|
|
|
|
// style: TextStyle(color: Colors.black),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
))),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed:
|
|
|
|
],
|
|
|
|
() {
|
|
|
|
),
|
|
|
|
Navigator.maybePop(context);
|
|
|
|
body: MultiBlocListener(
|
|
|
|
}),
|
|
|
|
listeners: [
|
|
|
|
actions: [
|
|
|
|
BlocListener<ThreadBloc, ThreadState>(
|
|
|
|
// TODO: 评价
|
|
|
|
listener: (context, state) {
|
|
|
|
// TODO: 常见问题
|
|
|
|
// 隐藏toast
|
|
|
|
Visibility(
|
|
|
|
// Fluttertoast.cancel();
|
|
|
|
visible: _isRobot,
|
|
|
|
if (state is RequestThreading) {
|
|
|
|
child: Align(
|
|
|
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
padding: new EdgeInsets.only(right: 10),
|
|
|
|
|
|
|
|
width: 60,
|
|
|
|
|
|
|
|
child: InkWell(
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
BlocProvider.of<ThreadBloc>(context)
|
|
|
|
|
|
|
|
..add(RequestAgentEvent(
|
|
|
|
|
|
|
|
wid: widget.wid,
|
|
|
|
|
|
|
|
aid: widget.aid,
|
|
|
|
|
|
|
|
type: widget.type));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
'转人工',
|
|
|
|
|
|
|
|
// style: TextStyle(color: Colors.black),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
))),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
body: MultiBlocListener(
|
|
|
|
|
|
|
|
listeners: [
|
|
|
|
|
|
|
|
BlocListener<ThreadBloc, ThreadState>(
|
|
|
|
|
|
|
|
listener: (context, state) {
|
|
|
|
|
|
|
|
// 隐藏toast
|
|
|
|
|
|
|
|
// Fluttertoast.cancel();
|
|
|
|
|
|
|
|
if (state is RequestThreading) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_isRequestingThread = true;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (state is RequestThreadSuccess) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_isRobot = false; // 需要,勿删
|
|
|
|
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
|
|
|
|
_isRequestingThread = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
|
|
|
|
_getMessages(_page, _size);
|
|
|
|
|
|
|
|
// 加载未读消息
|
|
|
|
|
|
|
|
BlocProvider.of<MessageBloc>(context)
|
|
|
|
|
|
|
|
..add(LoadUnreadVisitorMessagesEvent(page: 0, size: 10));
|
|
|
|
|
|
|
|
// 结果解析
|
|
|
|
|
|
|
|
if (state.threadResult.statusCode == 200 ||
|
|
|
|
|
|
|
|
state.threadResult.statusCode == 201) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('创建新会话');
|
|
|
|
|
|
|
|
// TODO: 参考拼多多,在发送按钮上方显示pop商品信息,用户确认之后才会发送商品信息
|
|
|
|
|
|
|
|
// 发送商品信息
|
|
|
|
|
|
|
|
// if (widget.custom != null &&
|
|
|
|
|
|
|
|
// widget.custom!.trim().length > 0) {
|
|
|
|
|
|
|
|
// _bdMqtt.sendCommodityMessage(
|
|
|
|
|
|
|
|
// widget.custom!, _currentThread!);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 发送附言消息
|
|
|
|
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
|
|
|
|
|
_bdMqtt.sendTextMessage(
|
|
|
|
|
|
|
|
widget.postscript!, _currentThread!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 202) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('提示排队中');
|
|
|
|
|
|
|
|
// 插入本地
|
|
|
|
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// 加载本地历史消息
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// 发送商品信息
|
|
|
|
|
|
|
|
// if (widget.custom != null &&
|
|
|
|
|
|
|
|
// widget.custom!.trim().length > 0) {
|
|
|
|
|
|
|
|
// _bdMqtt.sendCommodityMessage(
|
|
|
|
|
|
|
|
// widget.custom!, _currentThread!);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 发送附言消息
|
|
|
|
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
|
|
|
|
|
_bdMqtt.sendTextMessage(
|
|
|
|
|
|
|
|
widget.postscript!, _currentThread!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 203) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('当前非工作时间,请自助查询或留言');
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
_isRequestingThread = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// 插入本地
|
|
|
|
} else if (state is RequestThreadSuccess) {
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// 跳转留言页面,TODO: 关闭当前页面?
|
|
|
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
|
|
|
.push(new MaterialPageRoute(builder: (context) {
|
|
|
|
|
|
|
|
return new LeaveMsgProvider(
|
|
|
|
|
|
|
|
wid: this.widget.wid,
|
|
|
|
|
|
|
|
aid: this.widget.aid,
|
|
|
|
|
|
|
|
type: this.widget.type,
|
|
|
|
|
|
|
|
tip: state.threadResult.msg!.content);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 204) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('当前无客服在线,请自助查询或留言');
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_isRobot = false; // 需要,勿删
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
|
|
|
|
_isRequestingThread = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// 插入本地
|
|
|
|
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
// _getMessages(_page, _size);
|
|
|
|
_getMessages(_page, _size);
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
// 加载未读消息
|
|
|
|
// 跳转留言页面, TODO: 关闭当前页面?
|
|
|
|
BlocProvider.of<MessageBloc>(context)
|
|
|
|
Navigator.of(context)
|
|
|
|
..add(LoadUnreadVisitorMessagesEvent(page: 0, size: 10));
|
|
|
|
.push(new MaterialPageRoute(builder: (context) {
|
|
|
|
// 结果解析
|
|
|
|
return new LeaveMsgProvider(
|
|
|
|
if (state.threadResult.statusCode == 200 ||
|
|
|
|
wid: this.widget.wid,
|
|
|
|
state.threadResult.statusCode == 201) {
|
|
|
|
aid: this.widget.aid,
|
|
|
|
BytedeskUtils.printLog('创建新会话');
|
|
|
|
type: this.widget.type,
|
|
|
|
// TODO: 参考拼多多,在发送按钮上方显示pop商品信息,用户确认之后才会发送商品信息
|
|
|
|
tip: state.threadResult.msg!.content);
|
|
|
|
// 发送商品信息
|
|
|
|
}));
|
|
|
|
// if (widget.custom != null &&
|
|
|
|
} else if (state.threadResult.statusCode == 205) {
|
|
|
|
// widget.custom!.trim().length > 0) {
|
|
|
|
BytedeskUtils.printLog('咨询前问卷');
|
|
|
|
// _bdMqtt.sendCommodityMessage(
|
|
|
|
|
|
|
|
// widget.custom!, _currentThread!);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 发送附言消息
|
|
|
|
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
|
|
|
|
|
_bdMqtt.sendTextMessage(
|
|
|
|
|
|
|
|
widget.postscript!, _currentThread!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 202) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('提示排队中');
|
|
|
|
|
|
|
|
// 插入本地
|
|
|
|
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// 加载本地历史消息
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// 发送商品信息
|
|
|
|
|
|
|
|
// if (widget.custom != null &&
|
|
|
|
|
|
|
|
// widget.custom!.trim().length > 0) {
|
|
|
|
|
|
|
|
// _bdMqtt.sendCommodityMessage(
|
|
|
|
|
|
|
|
// widget.custom!, _currentThread!);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 发送附言消息
|
|
|
|
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
|
|
|
|
|
_bdMqtt.sendTextMessage(
|
|
|
|
|
|
|
|
widget.postscript!, _currentThread!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 203) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('当前非工作时间,请自助查询或留言');
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 插入本地
|
|
|
|
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// 跳转留言页面,TODO: 关闭当前页面?
|
|
|
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
|
|
|
.push(new MaterialPageRoute(builder: (context) {
|
|
|
|
|
|
|
|
return new LeaveMsgProvider(
|
|
|
|
|
|
|
|
wid: this.widget.wid,
|
|
|
|
|
|
|
|
aid: this.widget.aid,
|
|
|
|
|
|
|
|
type: this.widget.type,
|
|
|
|
|
|
|
|
tip: state.threadResult.msg!.content);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 204) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('当前无客服在线,请自助查询或留言');
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 插入本地
|
|
|
|
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
|
|
|
|
// _getMessages(_page, _size);
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// 跳转留言页面, TODO: 关闭当前页面?
|
|
|
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
|
|
|
.push(new MaterialPageRoute(builder: (context) {
|
|
|
|
|
|
|
|
return new LeaveMsgProvider(
|
|
|
|
|
|
|
|
wid: this.widget.wid,
|
|
|
|
|
|
|
|
aid: this.widget.aid,
|
|
|
|
|
|
|
|
type: this.widget.type,
|
|
|
|
|
|
|
|
tip: state.threadResult.msg!.content);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 205) {
|
|
|
|
|
|
|
|
BytedeskUtils.printLog('咨询前问卷');
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 插入本地
|
|
|
|
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
|
|
|
|
// _getMessages(_page, _size);
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 206) {
|
|
|
|
|
|
|
|
// BytedeskUtils.printLog('返回机器人初始欢迎语 + 欢迎问题列表');
|
|
|
|
|
|
|
|
// TODO: 显示问题列表
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_isRobot = true;
|
|
|
|
|
|
|
|
_robotUser = state.threadResult.msg!.user;
|
|
|
|
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 插入本地
|
|
|
|
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
|
|
|
|
// _getMessages(_page, _size);
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == -1) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == -2) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "siteId或者工作组id错误");
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == -3) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "您已经被禁言");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state is RequestThreadError) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
_isRequestingThread = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// 插入本地
|
|
|
|
} else if (state is RequestAgentThreading) {
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
|
|
|
|
// _getMessages(_page, _size);
|
|
|
|
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == 206) {
|
|
|
|
|
|
|
|
// BytedeskUtils.printLog('返回机器人初始欢迎语 + 欢迎问题列表');
|
|
|
|
|
|
|
|
// TODO: 显示问题列表
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
_isRobot = true;
|
|
|
|
_isRequestingThread = true;
|
|
|
|
_robotUser = state.threadResult.msg!.user;
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (state is RequestAgentSuccess) {
|
|
|
|
|
|
|
|
// 请求人工客服,不管此工作组是否设置为默认机器人,只要有人工客服在线,则可以直接对接人工
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_isRobot = false; // 需要,勿删
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
|
|
|
|
_isRequestingThread = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// 插入本地
|
|
|
|
// 插入本地
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
// TODO: 加载本地历史消息
|
|
|
|
// _appendMessage(state.threadResult.msg!);
|
|
|
|
// _getMessages(_page, _size);
|
|
|
|
} else if (state is RequestAgentThreadError) {
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == -1) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == -2) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "siteId或者工作组id错误");
|
|
|
|
|
|
|
|
} else if (state.threadResult.statusCode == -3) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "您已经被禁言");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_isRequestingThread = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (state is RequestThreadError) {
|
|
|
|
},
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
),
|
|
|
|
setState(() {
|
|
|
|
BlocListener<MessageBloc, MessageState>(
|
|
|
|
_isRequestingThread = false;
|
|
|
|
listener: (context, state) {
|
|
|
|
});
|
|
|
|
// BytedeskUtils.printLog('message state change');
|
|
|
|
} else if (state is RequestAgentThreading) {
|
|
|
|
if (state is ReceiveMessageState) {
|
|
|
|
setState(() {
|
|
|
|
// BytedeskUtils.printLog('receive message:' + state.message!.content!);
|
|
|
|
_isRequestingThread = true;
|
|
|
|
} else if (state is MessageUpLoading) {
|
|
|
|
});
|
|
|
|
Fluttertoast.showToast(msg: '上传中...');
|
|
|
|
} else if (state is RequestAgentSuccess) {
|
|
|
|
} else if (state is UploadImageSuccess) {
|
|
|
|
// 请求人工客服,不管此工作组是否设置为默认机器人,只要有人工客服在线,则可以直接对接人工
|
|
|
|
if (_bdMqtt.isConnected()) {
|
|
|
|
setState(() {
|
|
|
|
_bdMqtt.sendImageMessage(
|
|
|
|
_isRobot = false; // 需要,勿删
|
|
|
|
state.uploadJsonResult.url!, _currentThread!);
|
|
|
|
_currentThread = state.threadResult.msg!.thread;
|
|
|
|
} else {
|
|
|
|
_isRequestingThread = false;
|
|
|
|
sendImageMessageRest(state.uploadJsonResult.url!);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// 插入本地
|
|
|
|
} else if (state is UploadVideoSuccess) {
|
|
|
|
_messageProvider.insert(state.threadResult.msg!);
|
|
|
|
_bdMqtt.sendVideoMessage(
|
|
|
|
// _appendMessage(state.threadResult.msg!);
|
|
|
|
|
|
|
|
} else if (state is RequestAgentThreadError) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "请求会话失败");
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_isRequestingThread = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
BlocListener<MessageBloc, MessageState>(
|
|
|
|
|
|
|
|
listener: (context, state) {
|
|
|
|
|
|
|
|
// BytedeskUtils.printLog('message state change');
|
|
|
|
|
|
|
|
if (state is ReceiveMessageState) {
|
|
|
|
|
|
|
|
// BytedeskUtils.printLog('receive message:' + state.message!.content!);
|
|
|
|
|
|
|
|
} else if (state is MessageUpLoading) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: '上传中...');
|
|
|
|
|
|
|
|
} else if (state is UploadImageSuccess) {
|
|
|
|
|
|
|
|
if (_bdMqtt.isConnected()) {
|
|
|
|
|
|
|
|
_bdMqtt.sendImageMessage(
|
|
|
|
|
|
|
|
state.uploadJsonResult.url!, _currentThread!);
|
|
|
|
state.uploadJsonResult.url!, _currentThread!);
|
|
|
|
} else {
|
|
|
|
} else if (state is QueryAnswerSuccess) {
|
|
|
|
sendImageMessageRest(state.uploadJsonResult.url!);
|
|
|
|
// 已经修改为直接插入本地
|
|
|
|
}
|
|
|
|
// Message queryMessage = state.query!;
|
|
|
|
} else if (state is UploadVideoSuccess) {
|
|
|
|
// queryMessage.isSend = 1;
|
|
|
|
_bdMqtt.sendVideoMessage(
|
|
|
|
// _messageProvider.insert(queryMessage);
|
|
|
|
state.uploadJsonResult.url!, _currentThread!);
|
|
|
|
// _appendMessage(queryMessage);
|
|
|
|
} else if (state is QueryAnswerSuccess) {
|
|
|
|
// //
|
|
|
|
// 已经修改为直接插入本地
|
|
|
|
// _messageProvider.insert(state.answer!);
|
|
|
|
// Message queryMessage = state.query!;
|
|
|
|
// _appendMessage(state.answer!);
|
|
|
|
// queryMessage.isSend = 1;
|
|
|
|
} else if (state is QueryCategorySuccess) {
|
|
|
|
// _messageProvider.insert(queryMessage);
|
|
|
|
|
|
|
|
// _appendMessage(queryMessage);
|
|
|
|
|
|
|
|
// //
|
|
|
|
|
|
|
|
// _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;
|
|
|
|
|
|
|
|
// _messageProvider.insert(queryMessage);
|
|
|
|
|
|
|
|
// _appendMessage(queryMessage);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
if (state.query!.content!.contains('人工')) {
|
|
|
|
|
|
|
|
BlocProvider.of<ThreadBloc>(context)
|
|
|
|
|
|
|
|
..add(RequestAgentEvent(
|
|
|
|
|
|
|
|
wid: widget.wid,
|
|
|
|
|
|
|
|
aid: widget.aid,
|
|
|
|
|
|
|
|
type: widget.type));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
_messageProvider.insert(state.answer!);
|
|
|
|
_messageProvider.insert(state.answer!);
|
|
|
|
_appendMessage(state.answer!);
|
|
|
|
_appendMessage(state.answer!);
|
|
|
|
}
|
|
|
|
} else if (state is MessageAnswerSuccess) {
|
|
|
|
} else if (state is RateAnswerSuccess) {
|
|
|
|
// Message queryMessage = state.query!;
|
|
|
|
// TODO:
|
|
|
|
// queryMessage.isSend = 1;
|
|
|
|
} else if (state is LoadHistoryMessageSuccess) {
|
|
|
|
// _messageProvider.insert(queryMessage);
|
|
|
|
// BytedeskUtils.printLog('LoadHistoryMessageSuccess');
|
|
|
|
// _appendMessage(queryMessage);
|
|
|
|
// 插入历史聊天记录
|
|
|
|
//
|
|
|
|
for (var i = 0; i < state.messageList!.length; i++) {
|
|
|
|
if (state.query!.content!.contains('人工')) {
|
|
|
|
Message message = state.messageList![i];
|
|
|
|
BlocProvider.of<ThreadBloc>(context)
|
|
|
|
_appendMessage(message);
|
|
|
|
..add(RequestAgentEvent(
|
|
|
|
}
|
|
|
|
wid: widget.wid,
|
|
|
|
} else if (state is LoadUnreadVisitorMessageSuccess) {
|
|
|
|
aid: widget.aid,
|
|
|
|
// 插入历史聊天记录
|
|
|
|
type: widget.type));
|
|
|
|
if (state.messageList!.length > 0) {
|
|
|
|
} else {
|
|
|
|
// for (var i = 0; i < state.messageList!.length; i++) {
|
|
|
|
_messageProvider.insert(state.answer!);
|
|
|
|
for (var i = state.messageList!.length - 1; i >= 0; i--) {
|
|
|
|
_appendMessage(state.answer!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state is RateAnswerSuccess) {
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
|
|
|
} else if (state is LoadHistoryMessageSuccess) {
|
|
|
|
|
|
|
|
// BytedeskUtils.printLog('LoadHistoryMessageSuccess');
|
|
|
|
|
|
|
|
// 插入历史聊天记录
|
|
|
|
|
|
|
|
for (var i = 0; i < state.messageList!.length; i++) {
|
|
|
|
Message message = state.messageList![i];
|
|
|
|
Message message = state.messageList![i];
|
|
|
|
// 本地持久化
|
|
|
|
|
|
|
|
_messageProvider.insert(message);
|
|
|
|
|
|
|
|
// 界面显示
|
|
|
|
|
|
|
|
_appendMessage(message);
|
|
|
|
_appendMessage(message);
|
|
|
|
// 发送已读回执
|
|
|
|
|
|
|
|
_bdMqtt.sendReceiptReadMessage(
|
|
|
|
|
|
|
|
message.mid!, _currentThread!);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state is LoadUnreadVisitorMessageSuccess) {
|
|
|
|
|
|
|
|
// 插入历史聊天记录
|
|
|
|
|
|
|
|
if (state.messageList!.length > 0) {
|
|
|
|
|
|
|
|
// for (var i = 0; i < state.messageList!.length; i++) {
|
|
|
|
|
|
|
|
for (var i = state.messageList!.length - 1; i >= 0; i--) {
|
|
|
|
|
|
|
|
Message message = state.messageList![i];
|
|
|
|
|
|
|
|
// 本地持久化
|
|
|
|
|
|
|
|
_messageProvider.insert(message);
|
|
|
|
|
|
|
|
// 界面显示
|
|
|
|
|
|
|
|
_appendMessage(message);
|
|
|
|
|
|
|
|
// 发送已读回执
|
|
|
|
|
|
|
|
_bdMqtt.sendReceiptReadMessage(
|
|
|
|
|
|
|
|
message.mid!, _currentThread!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (state is SendMessageRestSuccess) {
|
|
|
|
|
|
|
|
// http rest 发送消息成功
|
|
|
|
|
|
|
|
String jsonMessage = state.jsonResult.data!;
|
|
|
|
|
|
|
|
String mid = json.decode(jsonMessage);
|
|
|
|
|
|
|
|
_messageProvider.update(
|
|
|
|
|
|
|
|
mid, BytedeskConstants.MESSAGE_STATUS_STORED);
|
|
|
|
|
|
|
|
} else if (state is SendMessageRestError) {
|
|
|
|
|
|
|
|
// http rest 发送消息失败
|
|
|
|
|
|
|
|
String jsonMessage = state.json;
|
|
|
|
|
|
|
|
String mid = json.decode(jsonMessage);
|
|
|
|
|
|
|
|
_messageProvider.update(
|
|
|
|
|
|
|
|
mid, BytedeskConstants.MESSAGE_STATUS_STORED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (state is SendMessageRestSuccess) {
|
|
|
|
},
|
|
|
|
// http rest 发送消息成功
|
|
|
|
),
|
|
|
|
String jsonMessage = state.jsonResult.data!;
|
|
|
|
],
|
|
|
|
String mid = json.decode(jsonMessage);
|
|
|
|
child: _isRequestingThread
|
|
|
|
_messageProvider.update(
|
|
|
|
? Container(
|
|
|
|
mid, BytedeskConstants.MESSAGE_STATUS_STORED);
|
|
|
|
margin: EdgeInsets.only(top: 50),
|
|
|
|
} else if (state is SendMessageRestError) {
|
|
|
|
alignment: Alignment.center,
|
|
|
|
// http rest 发送消息失败
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
String jsonMessage = state.json;
|
|
|
|
CircularProgressIndicator(
|
|
|
|
String mid = json.decode(jsonMessage);
|
|
|
|
strokeWidth: 2,
|
|
|
|
_messageProvider.update(
|
|
|
|
),
|
|
|
|
mid, BytedeskConstants.MESSAGE_STATUS_STORED);
|
|
|
|
Text('会话请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333)),)
|
|
|
|
}
|
|
|
|
]))
|
|
|
|
},
|
|
|
|
: Stack(
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
child: _isRequestingThread
|
|
|
|
|
|
|
|
? Container(
|
|
|
|
|
|
|
|
margin: EdgeInsets.only(top: 50),
|
|
|
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
children: [
|
|
|
|
CircularProgressIndicator(
|
|
|
|
|
|
|
|
strokeWidth: 2,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Text('会话请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333)),)
|
|
|
|
|
|
|
|
]))
|
|
|
|
|
|
|
|
: Stack(
|
|
|
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
color: Color(0xFFDEEEEEE),
|
|
|
|
color: Color(0xFFDEEEEEE),
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
children: <Widget>[
|
|
|
|
// 参考pull_to_refresh库中 QQChatList例子
|
|
|
|
// 参考pull_to_refresh库中 QQChatList例子
|
|
|
|
Expanded(
|
|
|
|
Expanded(
|
|
|
|
//
|
|
|
|
|
|
|
|
child: SmartRefresher(
|
|
|
|
|
|
|
|
enablePullDown: false,
|
|
|
|
|
|
|
|
onLoading: () async {
|
|
|
|
|
|
|
|
// BytedeskUtils.printLog('TODO: 下拉刷新'); // 注意:方向跟默认是反着的
|
|
|
|
|
|
|
|
// await Future.delayed(Duration(milliseconds: 1000));
|
|
|
|
|
|
|
|
_getMessages(_page, _size);
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
_refreshController.loadComplete();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
footer: ClassicFooter(
|
|
|
|
|
|
|
|
loadStyle: LoadStyle.ShowWhenLoading,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
enablePullUp: true,
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
child: Scrollable(
|
|
|
|
child: SmartRefresher(
|
|
|
|
controller: _scrollController,
|
|
|
|
enablePullDown: false,
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
onLoading: () async {
|
|
|
|
viewportBuilder: (context, offset) {
|
|
|
|
// BytedeskUtils.printLog('TODO: 下拉刷新'); // 注意:方向跟默认是反着的
|
|
|
|
return ExpandedViewport(
|
|
|
|
// await Future.delayed(Duration(milliseconds: 1000));
|
|
|
|
offset: offset,
|
|
|
|
_getMessages(_page, _size);
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
setState(() {});
|
|
|
|
slivers: <Widget>[
|
|
|
|
_refreshController.loadComplete();
|
|
|
|
SliverExpanded(),
|
|
|
|
|
|
|
|
SliverList(
|
|
|
|
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
|
|
|
|
(c, i) => _messages[i],
|
|
|
|
|
|
|
|
childCount: _messages.length),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
footer: ClassicFooter(
|
|
|
|
|
|
|
|
loadStyle: LoadStyle.ShowWhenLoading,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
enablePullUp: true,
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
child: Scrollable(
|
|
|
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
|
|
|
|
viewportBuilder: (context, offset) {
|
|
|
|
|
|
|
|
return ExpandedViewport(
|
|
|
|
|
|
|
|
offset: offset,
|
|
|
|
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
|
|
|
|
slivers: <Widget>[
|
|
|
|
|
|
|
|
SliverExpanded(),
|
|
|
|
|
|
|
|
SliverList(
|
|
|
|
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
|
|
|
|
(c, i) => _messages[i],
|
|
|
|
|
|
|
|
childCount: _messages.length),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
controller: _refreshController,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
//
|
|
|
|
|
|
|
|
controller: _refreshController,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Divider(
|
|
|
|
Divider(
|
|
|
|
height: 1.0,
|
|
|
|
height: 1.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white
|
|
|
|
color: Colors.white
|
|
|
|
),
|
|
|
|
|
|
|
|
// child: _textComposerWidget(),
|
|
|
|
|
|
|
|
child: _chatInput(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// child: _textComposerWidget(),
|
|
|
|
|
|
|
|
child: _chatInput(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
showGood? Positioned(
|
|
|
|
showGood? Positioned(
|
|
|
|
top: 0,
|
|
|
|
top: 0,
|
|
|
|
child:Container(
|
|
|
|
child:Container(
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Color(0xFFe5f9ff),
|
|
|
|
color: Color(0xFFe5f9ff),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(5)),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(5)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
Image.network(goodUrl,width: 50,height: 50,),
|
|
|
|
Image.network(goodUrl,width: 50,height: 50,),
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Text(goodName,style: TextStyle(color: Color(0xFF333333),fontSize: 15),),
|
|
|
|
Text(goodName,style: TextStyle(color: Color(0xFF333333),fontSize: 15),),
|
|
|
|
SizedBox(height: 8,),
|
|
|
|
SizedBox(height: 8,),
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Text('¥ '+goodPrice,style: TextStyle(color: Colors.red,fontSize: 16),),
|
|
|
|
Text('¥ '+goodPrice,style: TextStyle(color: Colors.red,fontSize: 16),),
|
|
|
|
SizedBox(width: 30,),
|
|
|
|
SizedBox(width: 30,),
|
|
|
|
GestureDetector(
|
|
|
|
GestureDetector(
|
|
|
|
onTap: (){
|
|
|
|
onTap: (){
|
|
|
|
showGood = false;
|
|
|
|
//showGood = false;
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
_goodsSubmitted();
|
|
|
|
_goodsSubmitted();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Color(0xFFefefef),
|
|
|
|
color: Color(0xFFefefef),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(4)),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(4)),
|
|
|
|
border: Border.all(color:Color(0xFF999999) )
|
|
|
|
border: Border.all(color:Color(0xFF999999) )
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 5),
|
|
|
|
|
|
|
|
child: Text('发送链接',style: TextStyle(color: Color(0xFF333333)),),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 5),
|
|
|
|
|
|
|
|
child: Text('发送链接',style: TextStyle(color: Color(0xFF333333)),),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Spacer(),
|
|
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 30),
|
|
|
|
|
|
|
|
icon: Icon(
|
|
|
|
|
|
|
|
Icons.close,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
onPressed: () {
|
|
|
|
),
|
|
|
|
showGood = false;
|
|
|
|
Spacer(),
|
|
|
|
setState(() {
|
|
|
|
IconButton(
|
|
|
|
});
|
|
|
|
padding: const EdgeInsets.only(bottom: 30),
|
|
|
|
},
|
|
|
|
icon: Icon(
|
|
|
|
|
|
|
|
Icons.close,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
],
|
|
|
|
showGood = false;
|
|
|
|
),
|
|
|
|
setState(() {
|
|
|
|
),):SizedBox(),
|
|
|
|
});
|
|
|
|
],
|
|
|
|
},
|
|
|
|
))),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),):SizedBox(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
)));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _chatInput() {
|
|
|
|
Widget _chatInput() {
|
|
|
@ -690,6 +697,8 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
print('_handleShowOrders');
|
|
|
|
print('_handleShowOrders');
|
|
|
|
if(widget.customCallback!=null){
|
|
|
|
if(widget.customCallback!=null){
|
|
|
|
widget.customCallback!('点击订单');
|
|
|
|
widget.customCallback!('点击订单');
|
|
|
|
|
|
|
|
customGoods = BytedeskUtils.goodsInfo;
|
|
|
|
|
|
|
|
_goodsSubmitted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -784,9 +793,9 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
|
|
|
|
|
|
|
|
// 发送商品消息
|
|
|
|
// 发送商品消息
|
|
|
|
void _goodsSubmitted() {
|
|
|
|
void _goodsSubmitted() {
|
|
|
|
|
|
|
|
print(customGoods);
|
|
|
|
if (widget.custom != null &&
|
|
|
|
if (
|
|
|
|
widget.custom!.trim().length > 0) {
|
|
|
|
customGoods.trim().length > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
if (_bdMqtt.isConnected()) {
|
|
|
|
if (_bdMqtt.isConnected()) {
|
|
|
|
if (_currentThread == null) {
|
|
|
|
if (_currentThread == null) {
|
|
|
@ -795,7 +804,7 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 长连接正常情况下,调用长连接接口
|
|
|
|
// 长连接正常情况下,调用长连接接口
|
|
|
|
_bdMqtt.sendCommodityMessage(
|
|
|
|
_bdMqtt.sendCommodityMessage(
|
|
|
|
widget.custom!, _currentThread!);
|
|
|
|
customGoods, _currentThread!);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|