|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|
|
|
|
import 'dart:convert'; |
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
@ -27,7 +28,9 @@ class _VipPayCode extends State<VipPayCode> {
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
|
super.dispose(); |
|
|
|
|
refreshController.dispose(); |
|
|
|
|
refreshController?.dispose(); |
|
|
|
|
_timer?.cancel(); |
|
|
|
|
isDispose = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -44,40 +47,47 @@ class _VipPayCode extends State<VipPayCode> {
|
|
|
|
|
|
|
|
|
|
///查询用户信息 |
|
|
|
|
queryUser() async { |
|
|
|
|
try{ |
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
SharedPreferences prefs; |
|
|
|
|
try { |
|
|
|
|
prefs = await SharedPreferences.getInstance(); |
|
|
|
|
if (prefs.getString("bannerData") != null) { |
|
|
|
|
userInfo = UserInfo.fromJson(jsonDecode(prefs.getString('userInfo'))); |
|
|
|
|
setState(() {}); |
|
|
|
|
} |
|
|
|
|
if (apiService == null) |
|
|
|
|
apiService = ApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: value.getString("token"), |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: prefs.getString("token"), |
|
|
|
|
showLoading: true |
|
|
|
|
); |
|
|
|
|
BaseData<UserInfo> baseData = |
|
|
|
|
await apiService.queryInfo().catchError((onError) { |
|
|
|
|
refreshController.refreshFailed();}); |
|
|
|
|
BaseData<UserInfo> baseData = await apiService.queryInfo().catchError((onError) { |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
userInfo = baseData.data; |
|
|
|
|
SharedPreferences.getInstance().then((value) => { |
|
|
|
|
value.setString('user', jsonEncode(baseData.data)), |
|
|
|
|
}); |
|
|
|
|
prefs.setString('userInfo', jsonEncode(baseData.data)); |
|
|
|
|
setState(() {}); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
} |
|
|
|
|
}finally{ |
|
|
|
|
} finally { |
|
|
|
|
refreshCode(); |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshCode(){ |
|
|
|
|
if (_timer != null) return; |
|
|
|
|
const oneSec = const Duration(minutes: 2); |
|
|
|
|
var callback = ((timer) { |
|
|
|
|
if (isDispose) return; |
|
|
|
|
_timer = Timer.periodic(oneSec, (timer) { |
|
|
|
|
if (isDispose) { |
|
|
|
|
timer.cancel(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryUser(); |
|
|
|
|
}); |
|
|
|
|
_timer = Timer.periodic(oneSec, callback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -132,9 +142,7 @@ class _VipPayCode extends State<VipPayCode> {
|
|
|
|
|
), |
|
|
|
|
SizedBox(height: 30.h,), |
|
|
|
|
QrImage( |
|
|
|
|
data: userInfo != null |
|
|
|
|
? (userInfo?.vipScanNo ?? "") |
|
|
|
|
: "", |
|
|
|
|
data:userInfo?.vipScanNo ?? "622868c3c2c5a02508ed7064c7c27387a1c2c0cb2052ba344d82266a64feb1cfc75014532616b2fb179024c83a6066757cf2639efca8f2731c54a24859e200ca", |
|
|
|
|
version: QrVersions.auto, |
|
|
|
|
size: 200.w, |
|
|
|
|
gapless: true, |
|
|
|
|