验证码倒计时重复点击bug

websocket地址更改
master
张萌 3 years ago
parent b99616a1ff
commit c5b447f38a

@ -10,6 +10,9 @@ class ClockTimerProvider extends ChangeNotifier{
void startTimer() {
timerStart = true;
if (timer != null) {
return;
}
timer = Timer.periodic(Duration(seconds: 1), (timer) {
if (second > 0) {
second--;

@ -27,7 +27,6 @@ class UserProvider extends ChangeNotifier {
await HiveStore.appBox!.put('login', true);
if (isLogin) {
await updateUserInfo();
WebSocketUtil().setUser(_userInfoModel!.id.toString());
WebSocketUtil().startWebSocket();
await SignFunc.checkNameAndAccount();
}

@ -1,11 +1,11 @@
import 'dart:async';
import 'package:aku_new_community_manager/tools/user_tool.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:power_logger/power_logger.dart';
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
const String baseUri = 'wss://shop.kaidalai.cn/websocket/butlerApp';
enum SOCKETSTATUS {
CONNECTED, //
BREAKOFF, //
@ -17,13 +17,18 @@ class WebSocketUtil {
//
WebSocketUtil._();
//
factory WebSocketUtil() => _socket;
IOWebSocketChannel? _webSocket;
///
String _user = 'admin';
static const String baseUri = 'wss://saas.kaidalai.cn/websocket/butlerApp';
String get urlAddress =>
'$baseUri/${UserTool.userProvider.userInfoModel?.communityName}/${UserTool.userProvider.userInfoModel?.nickName}';
///
SOCKETSTATUS _socketStatus = SOCKETSTATUS.CLOSED;
@ -79,26 +84,23 @@ class WebSocketUtil {
print('——————————webSocket init ——————————');
}
///
void setUser(String user) {
this._user = user;
}
///websocket
void startWebSocket() {
closeWebSocket();
try {
_webSocket = IOWebSocketChannel.connect(Uri.parse('$baseUri/$_user'));
print('webSocket已连接服务器$baseUri/$_user');
_webSocket = IOWebSocketChannel.connect(Uri.parse(urlAddress));
print('webSocket已连接服务器$urlAddress');
_socketStatus = SOCKETSTATUS.CONNECTED;
endReconnect();
onStart?.call();
_webSocket!.stream.listen(
(event) => webSocketReceiveMessage(event as String),
onError: webSocketOnError, );
onError: webSocketOnError,
);
initHeartBeat();
} catch (e) {
BotToast.showText(text: 'webSocket连接失败');
print('webSocket连接失败');
onError?.call(e);
LoggerData.addData(e);
}

Loading…
Cancel
Save