验证码重复点击bug

pull/1/head
张萌 3 years ago
parent adc538516f
commit f2e41b2e87

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

@ -30,9 +30,6 @@ class UserProvider extends ChangeNotifier {
Future init() async { Future init() async {
if (isLogin) { if (isLogin) {
await updateUserInfo(); await updateUserInfo();
WebSocketUtil().setUser(userInfoModel!.id.toString());
WebSocketUtil().setCommunityCode(userInfoModel!.communityCode);
WebSocketUtil().setNickName(userInfoModel!.nickName!);
WebSocketUtil().startWebSocket(); WebSocketUtil().startWebSocket();
await updateMyHouseInfo(); await updateMyHouseInfo();

@ -7,9 +7,6 @@ import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:aku_new_community/widget/others/user_tool.dart';
// const String baseUri = 'wss://shop.kaidalai.cn/websocket/app';
const String baseUri = 'wss://saas.kaidalai.cn/websocket/app';
enum SOCKETSTATUS { enum SOCKETSTATUS {
CONNECTED, // CONNECTED, //
BREAKOFF, // BREAKOFF, //
@ -28,9 +25,10 @@ class WebSocketUtil {
IOWebSocketChannel? _webSocket; IOWebSocketChannel? _webSocket;
/// ///
String _user = 'admin'; static const String baseUri = 'wss://saas.kaidalai.cn/websocket/app';
String _communityCode = 'communityCode';
String _nickName = 'nickName'; String get urlAddress =>
'$baseUri/${UserTool.userProvider.userInfoModel?.communityCode}/${UserTool.userProvider.userInfoModel?.nickName}';
/// ///
SOCKETSTATUS _socketStatus = SOCKETSTATUS.CLOSED; SOCKETSTATUS _socketStatus = SOCKETSTATUS.CLOSED;
@ -86,32 +84,19 @@ class WebSocketUtil {
print('——————————webSocket init ——————————'); print('——————————webSocket init ——————————');
} }
///
void setUser(String user) {
this._user = user;
}
void setCommunityCode(String communityCode) {
this._communityCode = communityCode;
}
void setNickName(String nickName) {
this._nickName = nickName;
}
///websocket ///websocket
void startWebSocket() { void startWebSocket() {
closeWebSocket(); closeWebSocket();
try { try {
_webSocket = IOWebSocketChannel.connect( _webSocket = IOWebSocketChannel.connect(Uri.parse(urlAddress));
Uri.parse('$baseUri/$_communityCode/$_nickName')); print('webSocket已连接服务器$urlAddress');
print('webSocket已连接服务器$baseUri/$_user');
_socketStatus = SOCKETSTATUS.CONNECTED; _socketStatus = SOCKETSTATUS.CONNECTED;
endReconnect(); endReconnect();
onStart?.call(); onStart?.call();
_webSocket!.stream.listen( _webSocket!.stream.listen(
(event) => webSocketReceiveMessage(event as String), (event) => webSocketReceiveMessage(event as String),
onError: webSocketOnError,); onError: webSocketOnError,
);
initHeartBeat(); initHeartBeat();
} catch (e) { } catch (e) {
BotToast.showText(text: 'webSocket连接失败'); BotToast.showText(text: 'webSocket连接失败');

Loading…
Cancel
Save