|
|
@ -114,8 +114,32 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
// final _flutterVideoCompress = FlutterVideoCompress();
|
|
|
|
// final _flutterVideoCompress = FlutterVideoCompress();
|
|
|
|
bool _isRequestingThread = true;
|
|
|
|
bool _isRequestingThread = true;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
String goodName = '';
|
|
|
|
|
|
|
|
String goodPrice = '';
|
|
|
|
|
|
|
|
String goodUrl = '';
|
|
|
|
|
|
|
|
bool showGood = false;
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
if (widget.custom != null &&
|
|
|
|
|
|
|
|
widget.custom!.trim().length > 0){
|
|
|
|
|
|
|
|
showGood = true;
|
|
|
|
|
|
|
|
Map<String, dynamic> json = jsonDecode(widget.custom??"");
|
|
|
|
|
|
|
|
json.forEach((key, value) {
|
|
|
|
|
|
|
|
//typeOne等所对应的数组数据
|
|
|
|
|
|
|
|
if(key=='title'){
|
|
|
|
|
|
|
|
goodName = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(key=='price'){
|
|
|
|
|
|
|
|
goodPrice = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(key=='imageUrl'){
|
|
|
|
|
|
|
|
goodUrl = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BytedeskUtils.printLog('chat_kf_page init');
|
|
|
|
// BytedeskUtils.printLog('chat_kf_page init');
|
|
|
|
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true);
|
|
|
|
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true);
|
|
|
|
// 从历史会话或者顶部通知栏进入
|
|
|
|
// 从历史会话或者顶部通知栏进入
|
|
|
@ -191,7 +215,7 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
super.build(context);
|
|
|
|
super.build(context);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold (
|
|
|
|
appBar: AppBar(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(_title ?? '请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333),fontSize: 16),),
|
|
|
|
title: Text(_title ?? '请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333),fontSize: 16),),
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
@ -260,11 +284,11 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
BytedeskUtils.printLog('创建新会话');
|
|
|
|
BytedeskUtils.printLog('创建新会话');
|
|
|
|
// TODO: 参考拼多多,在发送按钮上方显示pop商品信息,用户确认之后才会发送商品信息
|
|
|
|
// TODO: 参考拼多多,在发送按钮上方显示pop商品信息,用户确认之后才会发送商品信息
|
|
|
|
// 发送商品信息
|
|
|
|
// 发送商品信息
|
|
|
|
if (widget.custom != null &&
|
|
|
|
// if (widget.custom != null &&
|
|
|
|
widget.custom!.trim().length > 0) {
|
|
|
|
// widget.custom!.trim().length > 0) {
|
|
|
|
_bdMqtt.sendCommodityMessage(
|
|
|
|
// _bdMqtt.sendCommodityMessage(
|
|
|
|
widget.custom!, _currentThread!);
|
|
|
|
// widget.custom!, _currentThread!);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
// 发送附言消息
|
|
|
|
// 发送附言消息
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
@ -278,11 +302,11 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
// 加载本地历史消息
|
|
|
|
// 加载本地历史消息
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
_appendMessage(state.threadResult.msg!);
|
|
|
|
// 发送商品信息
|
|
|
|
// 发送商品信息
|
|
|
|
if (widget.custom != null &&
|
|
|
|
// if (widget.custom != null &&
|
|
|
|
widget.custom!.trim().length > 0) {
|
|
|
|
// widget.custom!.trim().length > 0) {
|
|
|
|
_bdMqtt.sendCommodityMessage(
|
|
|
|
// _bdMqtt.sendCommodityMessage(
|
|
|
|
widget.custom!, _currentThread!);
|
|
|
|
// widget.custom!, _currentThread!);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
// 发送附言消息
|
|
|
|
// 发送附言消息
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
if (widget.postscript != null &&
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
|
widget.postscript!.trim().length > 0) {
|
|
|
@ -482,63 +506,133 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text('会话请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333)),)
|
|
|
|
Text('会话请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333)),)
|
|
|
|
]))
|
|
|
|
]))
|
|
|
|
: Container(
|
|
|
|
: Stack(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
color: Color(0xFFDEEEEEE),
|
|
|
|
children: [
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
|
|
// 参考pull_to_refresh库中 QQChatList例子
|
|
|
|
Container(
|
|
|
|
Expanded(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
//
|
|
|
|
color: Color(0xFFDEEEEEE),
|
|
|
|
child: SmartRefresher(
|
|
|
|
child: Column(
|
|
|
|
enablePullDown: false,
|
|
|
|
children: <Widget>[
|
|
|
|
onLoading: () async {
|
|
|
|
// 参考pull_to_refresh库中 QQChatList例子
|
|
|
|
// BytedeskUtils.printLog('TODO: 下拉刷新'); // 注意:方向跟默认是反着的
|
|
|
|
Expanded(
|
|
|
|
// await Future.delayed(Duration(milliseconds: 1000));
|
|
|
|
//
|
|
|
|
_getMessages(_page, _size);
|
|
|
|
child: SmartRefresher(
|
|
|
|
setState(() {});
|
|
|
|
enablePullDown: false,
|
|
|
|
_refreshController.loadComplete();
|
|
|
|
onLoading: () async {
|
|
|
|
},
|
|
|
|
// BytedeskUtils.printLog('TODO: 下拉刷新'); // 注意:方向跟默认是反着的
|
|
|
|
footer: ClassicFooter(
|
|
|
|
// await Future.delayed(Duration(milliseconds: 1000));
|
|
|
|
loadStyle: LoadStyle.ShowWhenLoading,
|
|
|
|
_getMessages(_page, _size);
|
|
|
|
),
|
|
|
|
setState(() {});
|
|
|
|
enablePullUp: true,
|
|
|
|
_refreshController.loadComplete();
|
|
|
|
//
|
|
|
|
},
|
|
|
|
child: Scrollable(
|
|
|
|
footer: ClassicFooter(
|
|
|
|
controller: _scrollController,
|
|
|
|
loadStyle: LoadStyle.ShowWhenLoading,
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
),
|
|
|
|
viewportBuilder: (context, offset) {
|
|
|
|
enablePullUp: true,
|
|
|
|
return ExpandedViewport(
|
|
|
|
//
|
|
|
|
offset: offset,
|
|
|
|
child: Scrollable(
|
|
|
|
|
|
|
|
controller: _scrollController,
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
slivers: <Widget>[
|
|
|
|
viewportBuilder: (context, offset) {
|
|
|
|
SliverExpanded(),
|
|
|
|
return ExpandedViewport(
|
|
|
|
SliverList(
|
|
|
|
offset: offset,
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
axisDirection: AxisDirection.up,
|
|
|
|
(c, i) => _messages[i],
|
|
|
|
slivers: <Widget>[
|
|
|
|
childCount: _messages.length),
|
|
|
|
SliverExpanded(),
|
|
|
|
)
|
|
|
|
SliverList(
|
|
|
|
],
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
);
|
|
|
|
(c, i) => _messages[i],
|
|
|
|
},
|
|
|
|
childCount: _messages.length),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
controller: _refreshController,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Divider(
|
|
|
|
|
|
|
|
height: 1.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
//
|
|
|
|
Container(
|
|
|
|
controller: _refreshController,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
),
|
|
|
|
color: Colors.white
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
// child: _textComposerWidget(),
|
|
|
|
|
|
|
|
child: _chatInput(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Divider(
|
|
|
|
),
|
|
|
|
height: 1.0,
|
|
|
|
showGood? Positioned(
|
|
|
|
|
|
|
|
top: 0,
|
|
|
|
|
|
|
|
child:Container(
|
|
|
|
|
|
|
|
width: 300,
|
|
|
|
|
|
|
|
margin: EdgeInsets.all(10),
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10),
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Color(0xFFe5f9ff).withOpacity(0.8),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(5)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
child: Row(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
color: Colors.white
|
|
|
|
children: [
|
|
|
|
),
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
// child: _textComposerWidget(),
|
|
|
|
Image.network(goodUrl,width: 50,height: 50,),
|
|
|
|
child: _chatInput(),
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text(goodName,style: TextStyle(color: Color(0xFF333333),fontSize: 15),),
|
|
|
|
|
|
|
|
SizedBox(height: 8,),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text('¥ '+goodPrice,style: TextStyle(color: Colors.red,fontSize: 16),),
|
|
|
|
|
|
|
|
SizedBox(width: 30,),
|
|
|
|
|
|
|
|
GestureDetector(
|
|
|
|
|
|
|
|
onTap: (){
|
|
|
|
|
|
|
|
showGood = false;
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
_goodsSubmitted();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Color(0xFFefefef),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(4)),
|
|
|
|
|
|
|
|
border: Border.all(color:Color(0xFF999999) )
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),):SizedBox(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)));
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _chatInput() {
|
|
|
|
Widget _chatInput() {
|
|
|
@ -665,7 +759,8 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
icon: Icon(Icons.send),
|
|
|
|
icon: Icon(Icons.send),
|
|
|
|
onPressed: () => _handleSubmitted(_textController.text),
|
|
|
|
onPressed: () => _handleSubmitted(_textController.text),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -676,6 +771,33 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
bool get wantKeepAlive => true;
|
|
|
|
bool get wantKeepAlive => true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 发送商品消息
|
|
|
|
|
|
|
|
void _goodsSubmitted() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (widget.custom != null &&
|
|
|
|
|
|
|
|
widget.custom!.trim().length > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_bdMqtt.isConnected()) {
|
|
|
|
|
|
|
|
if (_currentThread == null) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: '请求客服中, 请稍后...');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 长连接正常情况下,调用长连接接口
|
|
|
|
|
|
|
|
_bdMqtt.sendCommodityMessage(
|
|
|
|
|
|
|
|
widget.custom!, _currentThread!);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 发送消息
|
|
|
|
// 发送消息
|
|
|
|
void _handleSubmitted(String? text) {
|
|
|
|
void _handleSubmitted(String? text) {
|
|
|
|
_textController.clear();
|
|
|
|
_textController.clear();
|
|
|
|