订单数据更新

master
章文轩 2 years ago
parent bd6a8b54c9
commit d7d600355d

@ -128,43 +128,77 @@ class _ChatTypePageState extends State<ChatTypePage> {
"other3": "", //
});
BytedeskKefu.startWorkGroupChatShopCallback(
context, _workGroupWid, "技能组客服-电商-回调", custom, (value) {
print('value为custom参数原样返回 $value');
BytedeskKefu.startWorkGroupChatOrderCallback(
context, _workGroupWid, "技能组客服-电商-回调",(value){ }, () {
//
showModalBottomSheet(
context: context,
builder: (context) {
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(() {
return Column(
children: [
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,
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(
width: 200,
height: 200,
color: Colors.red,
),
});
},
child: Container(
width: 200,
height: 100,
color: Colors.blue,
),
),
],
);
});
});

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

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

@ -14,7 +14,7 @@ class ChatKFProvider extends StatelessWidget {
final String? postscript;
final bool? isV2Robot;
final ValueSetter<String>? customCallback;
final Widget? widget;
final Function? btnBack;
//
const ChatKFProvider(
{Key? key,
@ -25,7 +25,7 @@ class ChatKFProvider extends StatelessWidget {
this.custom,
this.postscript,
this.isV2Robot,
this.customCallback, this.widget})
this.customCallback, this.btnBack})
: super(key: key);
//
@override
@ -51,7 +51,8 @@ class ChatKFProvider extends StatelessWidget {
isV2Robot: isV2Robot,
isThread: false,
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;
class BytedeskUtils {
//
static String goodsInfo = '';
static ValueNotifier<String> goodsInfo = ValueNotifier<String>('');
static bool get isDesktop => !isWeb && (isWindows || isLinux || isMacOS);
static bool get isMobile => isAndroid || isIOS;
static bool get isWeb => kIsWeb;

Loading…
Cancel
Save