更新订单数据发送

master
章文轩 2 years ago
parent ad5dbd5379
commit bd6a8b54c9

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:bytedesk_kefu/bytedesk_kefu.dart'; import 'package:bytedesk_kefu/bytedesk_kefu.dart';
import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; import 'package:bytedesk_kefu/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// //
@ -126,6 +127,7 @@ class _ChatTypePageState extends State<ChatTypePage> {
"other2": "", // "other2": "", //
"other3": "", // "other3": "", //
}); });
BytedeskKefu.startWorkGroupChatShopCallback( BytedeskKefu.startWorkGroupChatShopCallback(
context, _workGroupWid, "技能组客服-电商-回调", custom, (value) { context, _workGroupWid, "技能组客服-电商-回调", custom, (value) {
print('value为custom参数原样返回 $value'); print('value为custom参数原样返回 $value');
@ -133,10 +135,36 @@ class _ChatTypePageState extends State<ChatTypePage> {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (context) { builder: (context) {
return Container( return GestureDetector(
width: 200, onTap: (){
height: 200, custom = json.encode({
color: Colors.red, "type": BytedeskConstants.MESSAGE_TYPE_COMMODITY, //
"title": "11111", // ,
"content": "11111", // ,
"price": "11111", // ,
"url":
"https://item.m.jd.com/product/12172344.html", // url,
"imageUrl":
"https://bytedesk.oss-cn-shenzhen.aliyuncs.com/images/123.webp", //,
"id": 123, //
"categoryCode": "100010003", // ,
"client": "flutter", // ,
// key:value,
"other1": "", //
"other2": "", //
"other3": "", //
});
print('11111');
BytedeskKefu.updateGoods(custom);
setState(() {
});
},
child: Container(
width: 200,
height: 200,
color: Colors.red,
),
); );
}); });
}); });

@ -1,5 +1,4 @@
import 'dart:async'; import 'dart:async';
// import 'dart:io';
import 'package:bytedesk_kefu/http/bytedesk_device_api.dart'; import 'package:bytedesk_kefu/http/bytedesk_device_api.dart';
import 'package:bytedesk_kefu/http/bytedesk_thread_api.dart'; import 'package:bytedesk_kefu/http/bytedesk_thread_api.dart';
@ -161,6 +160,7 @@ class BytedeskKefu {
// //
static bool connect() { static bool connect() {
return BytedeskUtils.mqttConnect(); return BytedeskUtils.mqttConnect();
} }
// //
@ -206,6 +206,13 @@ class BytedeskKefu {
commodity, null); commodity, null);
} }
///
static void updateGoods(String info) {
BytedeskUtils.goodsInfo = info;
}
static void startWorkGroupChatShopCallback(BuildContext context, String wid, static void startWorkGroupChatShopCallback(BuildContext context, String wid,
String title, String commodity, ValueSetter<String> customCallback,{Widget? widget}) { String title, String commodity, ValueSetter<String> customCallback,{Widget? widget}) {
startChatShop(context, wid, BytedeskConstants.CHAT_TYPE_WORKGROUP, title, startChatShop(context, wid, BytedeskConstants.CHAT_TYPE_WORKGROUP, title,

@ -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 {
} }

@ -29,6 +29,7 @@ import 'package:flutter/services.dart' show rootBundle;
class BytedeskUtils { class BytedeskUtils {
// //
static String goodsInfo = '';
static bool get isDesktop => !isWeb && (isWindows || isLinux || isMacOS); static bool get isDesktop => !isWeb && (isWindows || isLinux || isMacOS);
static bool get isMobile => isAndroid || isIOS; static bool get isMobile => isAndroid || isIOS;
static bool get isWeb => kIsWeb; static bool get isWeb => kIsWeb;

Loading…
Cancel
Save