更新订单数据发送

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/util/bytedesk_constants.dart';
import 'package:bytedesk_kefu/util/bytedesk_utils.dart';
import 'package:flutter/material.dart';
//
@ -126,6 +127,7 @@ class _ChatTypePageState extends State<ChatTypePage> {
"other2": "", //
"other3": "", //
});
BytedeskKefu.startWorkGroupChatShopCallback(
context, _workGroupWid, "技能组客服-电商-回调", custom, (value) {
print('value为custom参数原样返回 $value');
@ -133,10 +135,36 @@ class _ChatTypePageState extends State<ChatTypePage> {
showModalBottomSheet(
context: 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,
height: 200,
color: Colors.red,
),
);
});
});

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

@ -119,12 +119,14 @@ class _ChatKFPageState extends State<ChatKFPage>
String goodPrice = '';
String goodUrl = '';
bool showGood = false;
String customGoods = '';
@override
void initState() {
if (widget.custom != null &&
widget.custom!.trim().length > 0){
customGoods = widget.custom??'';
if (
customGoods.trim().length > 0){
showGood = true;
Map<String, dynamic> json = jsonDecode(widget.custom??"");
Map<String, dynamic> json = jsonDecode(customGoods);
json.forEach((key, value) {
//typeOne
if(key=='title'){
@ -216,7 +218,11 @@ class _ChatKFPageState extends State<ChatKFPage>
Widget build(BuildContext context) {
super.build(context);
//
return Scaffold (
return GestureDetector(
onTap: (){
FocusScope.of(context).requestFocus(FocusNode());
},
child: Scaffold (
appBar: AppBar(
title: Text(_title ?? '请求中, 请稍后...',style: TextStyle(color: Color(0xFF333333),fontSize: 16),),
backgroundColor: Colors.white,
@ -598,7 +604,7 @@ class _ChatKFPageState extends State<ChatKFPage>
SizedBox(width: 30,),
GestureDetector(
onTap: (){
showGood = false;
//showGood = false;
setState(() {
});
_goodsSubmitted();
@ -633,7 +639,8 @@ class _ChatKFPageState extends State<ChatKFPage>
),
),):SizedBox(),
],
)));
))),
);
}
Widget _chatInput() {
@ -690,6 +697,8 @@ class _ChatKFPageState extends State<ChatKFPage>
print('_handleShowOrders');
if(widget.customCallback!=null){
widget.customCallback!('点击订单');
customGoods = BytedeskUtils.goodsInfo;
_goodsSubmitted();
}
}
@ -784,9 +793,9 @@ class _ChatKFPageState extends State<ChatKFPage>
//
void _goodsSubmitted() {
if (widget.custom != null &&
widget.custom!.trim().length > 0) {
print(customGoods);
if (
customGoods.trim().length > 0) {
if (_bdMqtt.isConnected()) {
if (_currentThread == null) {
@ -795,7 +804,7 @@ class _ChatKFPageState extends State<ChatKFPage>
}
//
_bdMqtt.sendCommodityMessage(
widget.custom!, _currentThread!);
customGoods, _currentThread!);
} else {
}

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

Loading…
Cancel
Save