fix: customer service message
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pilipala/models/msg/like.dart';
|
||||
import 'package:pilipala/models/msg/reply.dart';
|
||||
import 'package:pilipala/models/msg/system.dart';
|
||||
@ -63,7 +64,7 @@ class MsgHttp {
|
||||
.toList(),
|
||||
};
|
||||
} catch (err) {
|
||||
print('err🔟: $err');
|
||||
debugPrint('err: $err');
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
|
@ -45,7 +45,9 @@ class WhisperController extends GetxController {
|
||||
if (isLoading) return;
|
||||
var res = await MsgHttp.sessionList(
|
||||
endTs: type == 'onLoad' ? sessionList.last.sessionTs : null);
|
||||
if (res['data'].sessionList != null && res['data'].sessionList.isNotEmpty) {
|
||||
if (res['status'] &&
|
||||
res['data'].sessionList != null &&
|
||||
res['data'].sessionList.isNotEmpty) {
|
||||
await queryAccountList(res['data'].sessionList);
|
||||
// 将 accountList 转换为 Map 结构
|
||||
Map<int, dynamic> accountMap = {};
|
||||
@ -67,8 +69,6 @@ class WhisperController extends GetxController {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res['status'] && res['data'].sessionList != null) {
|
||||
if (type == 'onLoad') {
|
||||
sessionList.addAll(res['data'].sessionList);
|
||||
} else {
|
||||
@ -81,10 +81,33 @@ class WhisperController extends GetxController {
|
||||
|
||||
Future queryAccountList(sessionList) async {
|
||||
List midsList = sessionList.map((e) => e.talkerId!).toList();
|
||||
var index = midsList.indexOf(0);
|
||||
AccountListModel? accountInfo;
|
||||
if (index != -1) {
|
||||
accountInfo = AccountListModel(
|
||||
mid: 0,
|
||||
name: '客服消息',
|
||||
face:
|
||||
'https://i0.hdslb.com/bfs/activity-plat/static/20230809/f87fc7ea98282a4dd48ec7743044b0bf/OWdoP9ZXAX.png',
|
||||
);
|
||||
}
|
||||
if (midsList.length == 1 && index != -1) {
|
||||
accountList.add(accountInfo!);
|
||||
return;
|
||||
}
|
||||
|
||||
var res = await MsgHttp.accountList(midsList.join(','));
|
||||
if (res['status']) {
|
||||
accountList.value = res['data'];
|
||||
if (accountInfo != null) {
|
||||
if (accountList.isNotEmpty) {
|
||||
accountList.insert(index, accountInfo);
|
||||
} else {
|
||||
accountList.add(accountInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/skeleton/skeleton.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
@ -151,8 +152,15 @@ class _WhisperPageState extends State<WhisperPage> {
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return Center(
|
||||
child: Text(data?['msg'] ?? '请求异常'),
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_whisperController.querySessionList('init');
|
||||
});
|
||||
},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user