更新订单数据发送

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(
onTap: (){
custom = json.encode({
"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, width: 200,
height: 200, height: 200,
color: Colors.red, 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,7 +218,11 @@ class _ChatKFPageState extends State<ChatKFPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
// //
return Scaffold ( return GestureDetector(
onTap: (){
FocusScope.of(context).requestFocus(FocusNode());
},
child: 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,
@ -598,7 +604,7 @@ class _ChatKFPageState extends State<ChatKFPage>
SizedBox(width: 30,), SizedBox(width: 30,),
GestureDetector( GestureDetector(
onTap: (){ onTap: (){
showGood = false; //showGood = false;
setState(() { setState(() {
}); });
_goodsSubmitted(); _goodsSubmitted();
@ -633,7 +639,8 @@ class _ChatKFPageState extends State<ChatKFPage>
), ),
),):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