增加用户发送商品信息按钮,自动发送关闭

master
章文轩 2 years ago
parent d3cb995598
commit c8c684d471

@ -36,6 +36,108 @@
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/windows/flutter/ephemeral/.plugin_symlinks/shared_preferences_windows/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/windows/flutter/ephemeral/.plugin_symlinks/shared_preferences_windows/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/windows/flutter/ephemeral/.plugin_symlinks/shared_preferences_windows/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/fluttertoast/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/fluttertoast/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/fluttertoast/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/wakelock/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/wakelock/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/wakelock/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/fluttertoast/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/fluttertoast/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/fluttertoast/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/vibration/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/vibration/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/vibration/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/bytedesk_kefu/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/bytedesk_kefu/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/bytedesk_kefu/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/video_player_avfoundation/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/video_player_avfoundation/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/video_player_avfoundation/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/package_info/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/package_info/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/package_info/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/webview_flutter_wkwebview/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/webview_flutter_wkwebview/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/webview_flutter_wkwebview/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/url_launcher_ios/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/url_launcher_ios/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/url_launcher_ios/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/shared_preferences_ios/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/shared_preferences_ios/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/shared_preferences_ios/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/package_info/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/package_info/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/package_info/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/wakelock/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/wakelock/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/wakelock/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/audioplayers/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/audioplayers/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/audioplayers/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/devicelocale/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/devicelocale/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/devicelocale/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/device_info/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/device_info/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/device_info/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/webview_flutter_wkwebview/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/webview_flutter_wkwebview/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/webview_flutter_wkwebview/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/audioplayers/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/audioplayers/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/audioplayers/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/file_picker/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/file_picker/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/file_picker/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/path_provider_ios/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/path_provider_ios/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/path_provider_ios/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_picker_ios/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_picker_ios/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_picker_ios/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_picker_ios/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_picker_ios/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_picker_ios/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/device_info/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/device_info/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/device_info/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/devicelocale/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/devicelocale/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/devicelocale/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/vibration/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/vibration/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/vibration/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/shared_preferences_ios/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/shared_preferences_ios/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/shared_preferences_ios/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_gallery_saver/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_gallery_saver/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_gallery_saver/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/url_launcher_ios/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/url_launcher_ios/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/url_launcher_ios/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/file_picker/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/file_picker/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/file_picker/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/sqflite/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/sqflite/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/sqflite/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/video_player_avfoundation/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/video_player_avfoundation/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/video_player_avfoundation/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_gallery_saver/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_gallery_saver/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/image_gallery_saver/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/path_provider_ios/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/path_provider_ios/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/path_provider_ios/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/sqflite/example/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/sqflite/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/sqflite/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/bytedesk_kefu/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/bytedesk_kefu/build" />
<excludeFolder url="file://$MODULE_DIR$/bytedesk_demo/ios/.symlinks/plugins/bytedesk_kefu/.pub" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />

File diff suppressed because it is too large Load Diff

@ -44,7 +44,7 @@ dependencies:
# 振动 https://pub.dev/packages/vibration
# 针对报错fatal error: 'vibration/vibration-Swift.h' file not found #import <vibration/vibration-Swift.h>, ld: library not found for -lvibration
# 请在ios/Podfile中添加use_frameworks!
vibration: ^1.7.3
vibration: ^1.7.5
# 在线客服 https://pub.dev/packages/bytedesk_kefu
#bytedesk_kefu: ^1.4.1
bytedesk_kefu:

@ -114,8 +114,32 @@ class _ChatKFPageState extends State<ChatKFPage>
// final _flutterVideoCompress = FlutterVideoCompress();
bool _isRequestingThread = true;
//
String goodName = '';
String goodPrice = '';
String goodUrl = '';
bool showGood = false;
@override
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');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true);
//
@ -191,7 +215,7 @@ class _ChatKFPageState extends State<ChatKFPage>
Widget build(BuildContext context) {
super.build(context);
//
return Scaffold(
return Scaffold (
appBar: AppBar(
title: Text(_title ?? '请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333),fontSize: 16),),
backgroundColor: Colors.white,
@ -260,11 +284,11 @@ class _ChatKFPageState extends State<ChatKFPage>
BytedeskUtils.printLog('创建新会话');
// TODO: pop
//
if (widget.custom != null &&
widget.custom!.trim().length > 0) {
_bdMqtt.sendCommodityMessage(
widget.custom!, _currentThread!);
}
// if (widget.custom != null &&
// widget.custom!.trim().length > 0) {
// _bdMqtt.sendCommodityMessage(
// widget.custom!, _currentThread!);
// }
//
if (widget.postscript != null &&
widget.postscript!.trim().length > 0) {
@ -278,11 +302,11 @@ class _ChatKFPageState extends State<ChatKFPage>
//
_appendMessage(state.threadResult.msg!);
//
if (widget.custom != null &&
widget.custom!.trim().length > 0) {
_bdMqtt.sendCommodityMessage(
widget.custom!, _currentThread!);
}
// if (widget.custom != null &&
// widget.custom!.trim().length > 0) {
// _bdMqtt.sendCommodityMessage(
// widget.custom!, _currentThread!);
// }
//
if (widget.postscript != null &&
widget.postscript!.trim().length > 0) {
@ -482,7 +506,12 @@ class _ChatKFPageState extends State<ChatKFPage>
),
Text('会话请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333)),)
]))
: Container(
: Stack(
alignment: Alignment.center,
children: [
Container(
alignment: Alignment.bottomCenter,
color: Color(0xFFDEEEEEE),
child: Column(
@ -536,8 +565,73 @@ class _ChatKFPageState extends State<ChatKFPage>
// child: _textComposerWidget(),
child: _chatInput(),
),
],
),
),
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)),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(width: 10,),
Image.network(goodUrl,width: 50,height: 50,),
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(),
],
)));
}
@ -665,7 +759,8 @@ class _ChatKFPageState extends State<ChatKFPage>
icon: Icon(Icons.send),
onPressed: () => _handleSubmitted(_textController.text),
),
)
),
],
),
),
@ -676,6 +771,33 @@ class _ChatKFPageState extends State<ChatKFPage>
@override
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) {
_textController.clear();

@ -71,7 +71,7 @@ dependencies:
# 视频压缩 https://pub.dev/packages/flutter_video_compress/install
# flutter_video_compress: ^0.3.7+8
# 振动 https://pub.dev/packages/vibration
# vibration: ^1.7.3
# vibration: ^1.7.5
# 播放语音
# https://pub.dev/packages/audioplayers
# audioplayers: ^0.16.1

Loading…
Cancel
Save