订单数据更新

master
章文轩 2 years ago
parent bd6a8b54c9
commit d7d600355d

@ -128,43 +128,77 @@ class _ChatTypePageState extends State<ChatTypePage> {
"other3": "", // "other3": "", //
}); });
BytedeskKefu.startWorkGroupChatShopCallback( BytedeskKefu.startWorkGroupChatOrderCallback(
context, _workGroupWid, "技能组客服-电商-回调", custom, (value) { context, _workGroupWid, "技能组客服-电商-回调",(value){ }, () {
print('value为custom参数原样返回 $value');
// //
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (context) { builder: (context) {
return GestureDetector( return Column(
onTap: (){ children: [
custom = json.encode({ GestureDetector(
"type": BytedeskConstants.MESSAGE_TYPE_COMMODITY, // onTap: (){
"title": "11111", // , custom = json.encode({
"content": "11111", // , "type": BytedeskConstants.MESSAGE_TYPE_COMMODITY, //
"price": "11111", // , "title": "11111", // ,
"url": "content": "11111", // ,
"https://item.m.jd.com/product/12172344.html", // url, "price": "11111", // ,
"imageUrl": "url":
"https://bytedesk.oss-cn-shenzhen.aliyuncs.com/images/123.webp", //, "https://item.m.jd.com/product/12172344.html", // url,
"id": 123, // "imageUrl":
"categoryCode": "100010003", // , "https://bytedesk.oss-cn-shenzhen.aliyuncs.com/images/123.webp", //,
"client": "flutter", // , "id": 123, //
// key:value, "categoryCode": "100010003", // ,
"other1": "", // "client": "flutter", // ,
"other2": "", // // key:value,
"other3": "", // "other1": "", //
}); "other2": "", //
print('11111'); "other3": "", //
BytedeskKefu.updateGoods(custom); });
setState(() { print('11111');
BytedeskKefu.updateGoods(custom);
setState(() {
});
},
child: Container(
width: 200,
height: 100,
color: Colors.red,
),
),
GestureDetector(
onTap: (){
custom = json.encode({
"type": BytedeskConstants.MESSAGE_TYPE_COMMODITY, //
"title": "222", // ,
"content": "222", // ,
"price": "222", // ,
"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( child: Container(
width: 200, width: 200,
height: 200, height: 100,
color: Colors.red, color: Colors.blue,
), ),
),
],
); );
}); });
}); });

@ -195,7 +195,7 @@ class BytedeskKefu {
static void startWorkGroupChatPostscript( static void startWorkGroupChatPostscript(
BuildContext context, String wid, String title, String postScript) { BuildContext context, String wid, String title, String postScript) {
startChat(context, wid, BytedeskConstants.CHAT_TYPE_WORKGROUP, title, '', startChat(context, wid, BytedeskConstants.CHAT_TYPE_WORKGROUP, title, '',
postScript, false, null); postScript, false, null, null);
} }
// //
@ -207,16 +207,23 @@ class BytedeskKefu {
} }
///
static void startWorkGroupChatOrderCallback(BuildContext context, String wid,
String title, ValueSetter<String> customCallback,Function btnCallBack) {
startChatShop(context, wid, BytedeskConstants.CHAT_TYPE_WORKGROUP, title,
'', customCallback,btnCallBack: btnCallBack);
}
/// ///
static void updateGoods(String info) { static void updateGoods(String info) {
BytedeskUtils.goodsInfo = info; BytedeskUtils.goodsInfo.value = 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) {
startChatShop(context, wid, BytedeskConstants.CHAT_TYPE_WORKGROUP, title, startChatShop(context, wid, BytedeskConstants.CHAT_TYPE_WORKGROUP, title,
commodity, customCallback,widget: widget); commodity, customCallback);
} }
// //
@ -230,7 +237,7 @@ class BytedeskKefu {
static void startAppointedChatPostscript( static void startAppointedChatPostscript(
BuildContext context, String uid, String title, String postScript) { BuildContext context, String uid, String title, String postScript) {
startChat(context, uid, BytedeskConstants.CHAT_TYPE_APPOINTED, title, '', startChat(context, uid, BytedeskConstants.CHAT_TYPE_APPOINTED, title, '',
postScript, false, null); postScript, false, null, null);
} }
// //
@ -249,20 +256,19 @@ class BytedeskKefu {
// //
static void startChatDefault(BuildContext context, String uuid, String type, static void startChatDefault(BuildContext context, String uuid, String type,
String title, bool isV2Robot) { String title, bool isV2Robot) {
startChat(context, uuid, type, title, '', '', isV2Robot, null); startChat(context, uuid, type, title, '', '', isV2Robot, null, null);
} }
// -() // -()
static void startChatShop(BuildContext context, String uuid, String type, static void startChatShop(BuildContext context, String uuid, String type,
String title, String commodity, ValueSetter<String>? customCallback, String title, String commodity, ValueSetter<String>? customCallback,{Function? btnCallBack}) {
{Widget? widget}) { startChat(context, uuid, type, title, commodity, '', false, customCallback, btnCallBack);
startChat(context, uuid, type, title, commodity, '', false, customCallback,widget:widget);
} }
// -() // -()
static void startChatPostscript(BuildContext context, String uuid, static void startChatPostscript(BuildContext context, String uuid,
String type, String title, String postScript) { String type, String title, String postScript) {
startChat(context, uuid, type, title, '', postScript, false, null); startChat(context, uuid, type, title, '', postScript, false, null, null);
} }
// -() // -()
@ -275,7 +281,7 @@ class BytedeskKefu {
String postScript, String postScript,
bool isV2Robot, bool isV2Robot,
ValueSetter<String>? customCallback, ValueSetter<String>? customCallback,
{Widget? widget} Function? btnBack,
) { ) {
Navigator.of(context).push(new MaterialPageRoute(builder: (context) { Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
return new ChatKFProvider( return new ChatKFProvider(
@ -287,6 +293,7 @@ class BytedeskKefu {
postscript: postScript, postscript: postScript,
isV2Robot: isV2Robot, isV2Robot: isV2Robot,
customCallback: customCallback, customCallback: customCallback,
btnBack: btnBack,
); );
})); }));
} }

@ -51,7 +51,7 @@ class ChatKFPage extends StatefulWidget {
final bool? isThread; final bool? isThread;
final Thread? thread; final Thread? thread;
final ValueSetter<String>? customCallback; final ValueSetter<String>? customCallback;
final Widget? widget; final Function? btnBack;
// //
ChatKFPage( ChatKFPage(
{Key? key, {Key? key,
@ -64,7 +64,7 @@ class ChatKFPage extends StatefulWidget {
this.isV2Robot, this.isV2Robot,
this.isThread, this.isThread,
this.thread, this.thread,
this.customCallback, this.widget}) this.customCallback, this.btnBack,})
: super(key: key); : super(key: key);
// //
@override @override
@ -120,29 +120,45 @@ class _ChatKFPageState extends State<ChatKFPage>
String goodUrl = ''; String goodUrl = '';
bool showGood = false; bool showGood = false;
String customGoods = ''; String customGoods = '';
// String lastGoods = '';
@override @override
void initState() { void initState() {
customGoods = widget.custom??'';
if ( BytedeskUtils.goodsInfo.addListener(() {
customGoods.trim().length > 0){ print('发生改变!!!!!!!!!!');
showGood = true; customGoods = BytedeskUtils.goodsInfo.value;
Map<String, dynamic> json = jsonDecode(customGoods); _goodsSubmitted();
json.forEach((key, value) { });
//typeOne
if(key=='title'){
goodName = value; if(widget.btnBack==null){
} customGoods = widget.custom??'';
if(key=='price'){
goodPrice = value; if (customGoods.trim().length > 0){
} showGood = true;
if(key=='imageUrl'){ Map<String, dynamic> json = jsonDecode(customGoods);
goodUrl = value; json.forEach((key, value) {
} //typeOne
}); if(key=='title'){
goodName = value;
}
if(key=='price'){
goodPrice = value;
}
if(key=='imageUrl'){
goodUrl = value;
}
});
}
}else{
} }
// BytedeskUtils.printLog('chat_kf_page init'); // BytedeskUtils.printLog('chat_kf_page init');
SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true); SpUtil.putBool(BytedeskConstants.isCurrentChatKfPage, true);
// //
@ -604,7 +620,7 @@ class _ChatKFPageState extends State<ChatKFPage>
SizedBox(width: 30,), SizedBox(width: 30,),
GestureDetector( GestureDetector(
onTap: (){ onTap: (){
//showGood = false; showGood = false;
setState(() { setState(() {
}); });
_goodsSubmitted(); _goodsSubmitted();
@ -695,10 +711,9 @@ class _ChatKFPageState extends State<ChatKFPage>
void _handleShowOrders() async { void _handleShowOrders() async {
print('_handleShowOrders'); print('_handleShowOrders');
if(widget.customCallback!=null){ if(widget.btnBack!=null){
widget.customCallback!('点击订单'); widget.btnBack!();
customGoods = BytedeskUtils.goodsInfo;
_goodsSubmitted();
} }
} }
@ -794,8 +809,7 @@ class _ChatKFPageState extends State<ChatKFPage>
// //
void _goodsSubmitted() { void _goodsSubmitted() {
print(customGoods); print(customGoods);
if ( if (customGoods.trim().length > 0) {
customGoods.trim().length > 0) {
if (_bdMqtt.isConnected()) { if (_bdMqtt.isConnected()) {
if (_currentThread == null) { if (_currentThread == null) {

@ -14,7 +14,7 @@ class ChatKFProvider extends StatelessWidget {
final String? postscript; final String? postscript;
final bool? isV2Robot; final bool? isV2Robot;
final ValueSetter<String>? customCallback; final ValueSetter<String>? customCallback;
final Widget? widget; final Function? btnBack;
// //
const ChatKFProvider( const ChatKFProvider(
{Key? key, {Key? key,
@ -25,7 +25,7 @@ class ChatKFProvider extends StatelessWidget {
this.custom, this.custom,
this.postscript, this.postscript,
this.isV2Robot, this.isV2Robot,
this.customCallback, this.widget}) this.customCallback, this.btnBack})
: super(key: key); : super(key: key);
// //
@override @override
@ -51,7 +51,8 @@ class ChatKFProvider extends StatelessWidget {
isV2Robot: isV2Robot, isV2Robot: isV2Robot,
isThread: false, isThread: false,
customCallback: customCallback, customCallback: customCallback,
widget: widget,), btnBack: btnBack,
),
); );
} }
} }

@ -28,8 +28,10 @@ import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:flutter/services.dart' show rootBundle; import 'package:flutter/services.dart' show rootBundle;
class BytedeskUtils { class BytedeskUtils {
//
static String goodsInfo = '';
static ValueNotifier<String> goodsInfo = ValueNotifier<String>('');
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