会员刷新

master
戴余标 2 years ago
parent ee4f61aa4a
commit da09a3eb68

@ -3,6 +3,7 @@ import 'dart:ffi';
import 'package:bot_toast/bot_toast.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/tab_navigator.dart';
import 'package:project_telephony/ui/user/user_page.dart';
@ -22,7 +23,6 @@ import '../../model/pay/wx_pay_model.dart';
import '../../utils/pay_util.dart';
import '../../utils/toast/cloud_toast.dart';
class MembersPage extends StatefulWidget {
const MembersPage({Key? key}) : super(key: key);
@ -30,7 +30,6 @@ class MembersPage extends StatefulWidget {
_MembersPageState createState() => _MembersPageState();
}
List<dynamic>? data;
final List<ChooseItems> _piceList = [
ChooseItems(
@ -54,10 +53,28 @@ List payWay = [
class _MembersPageState extends State<MembersPage> {
int nowPrice = 1;
final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override
void dispose() {
_easyRefreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
body: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
footer: MaterialFooter(),
controller: _easyRefreshController,
onRefresh: () async {
await UserTool.userProvider.updateUserInfo();
setState(() {});
},
child: Stack(
children: [
Align(
child: SizedBox(
@ -92,7 +109,8 @@ class _MembersPageState extends State<MembersPage> {
if (_selectIndex == 0) {
_wxPayFunc();
} else {
var result = await isAliPayInstalled(); //
var result =
await isAliPayInstalled(); //
if (!result) {
Get.snackbar('提示', "请先安装支付宝");
} else {
@ -111,8 +129,9 @@ class _MembersPageState extends State<MembersPage> {
}
},
textColor: const Color(0xFF333333),
text: UserTool.userProvider.userInfo.isVip!=1?"立即开通":"立即续费",
text: UserTool.userProvider.userInfo.isVip != 1
? "立即开通"
: "立即续费",
color1: const Color(0xFFFFF6D8),
color2: const Color(0xFFFFEAB0),
)
@ -131,6 +150,7 @@ class _MembersPageState extends State<MembersPage> {
)),
],
),
),
);
}
@ -173,7 +193,9 @@ class _MembersPageState extends State<MembersPage> {
),
16.hb,
Text(
UserTool.userProvider.userInfo.isVip!=1?"暂未开通会员":"${DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d)}到期",
UserTool.userProvider.userInfo.isVip != 1
? "暂未开通会员"
: "${DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d)}到期",
style: TextStyle(color: Colors.white, fontSize: BaseStyle.fontSize24),
),
],
@ -212,7 +234,6 @@ class _MembersPageState extends State<MembersPage> {
);
}
Future _wxPayFunc() async {
bool isInstalled = await fluwx.isWeChatInstalled;
if (!isInstalled) {
@ -233,6 +254,7 @@ class _MembersPageState extends State<MembersPage> {
// payModel: wxPayModel,
// );
}
// base ={
// "content": {
// "prepayId": "wx121434071826969924754d7d3309520000",
@ -261,11 +283,12 @@ class _MembersPageState extends State<MembersPage> {
});
if (base.code == 0) {
await PayUtil().callAliPay(base.data);
Get.offAll(const TabNavigator(index: 1,));
_easyRefreshController.callRefresh();
} else {
CloudToast.show(base.msg);
}
}
Future _wxPay() async {
var base = await apiClient.request(API.pay.wxpay, data: {
// 'amount': nowPrice,//
@ -276,7 +299,7 @@ class _MembersPageState extends State<MembersPage> {
await PayUtil().callWxPay(
payModel: wxPayModel,
);
Get.offAll(const TabNavigator(index: 1,));
_easyRefreshController.callRefresh();
} else {
CloudToast.show(base.msg);
}

@ -3,6 +3,7 @@ import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/login/login_page.dart';
@ -47,19 +48,31 @@ class _UserPageState extends State<UserPage> {
final service = FlutterBackgroundService();
late bool vle = false;
// bool vle=service.isRunning() as bool;
_load() async {
vle = await service.isRunning();
}
final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override
void dispose() {
_easyRefreshController.dispose();
super.dispose();
}
@override
void initState() {
super.initState();
UserTool.userProvider.updateUserInfo();
Future.delayed(const Duration(milliseconds: 0), ()=>setState(() {
Future.delayed(
const Duration(milliseconds: 0),
() => setState(() {
if (UserTool.userProvider.isLogin) {
print(UserTool.userProvider.userInfo.end * 1000);
print(DateTime.now().millisecondsSinceEpoch);
if (UserTool.userProvider.userInfo.end*1000>DateTime.now().microsecondsSinceEpoch) {
if (UserTool.userProvider.userInfo.end * 1000 >
DateTime.now().microsecondsSinceEpoch) {
isVip = false;
vle = false;
} else {
@ -67,15 +80,13 @@ class _UserPageState extends State<UserPage> {
_load();
}
//service.isRunning() as bool;
endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);
endDate = DateUtil.formatDateMs(
UserTool.userProvider.userInfo.end * 1000,
format: DateFormats.y_mo_d);
} else {
vle = false;
}
}));
// Future.delayed(const Duration(milliseconds: 0), () async {
//
// });
}
@override
@ -88,8 +99,8 @@ class _UserPageState extends State<UserPage> {
path: Assets.images.bg.path,
bodyColor: Colors.white,
extendBody: true,
body: Column(children: [
body: Column(
children: [
_getUser(),
72.hb,
_getBanner(),
@ -104,7 +115,6 @@ class _UserPageState extends State<UserPage> {
? PloneBottom(
border: false,
onTap: () async {
var cancel = CloudToast.loading;
var base = await apiClient.request(API.app.logout,
showMessage: true);
@ -120,7 +130,8 @@ class _UserPageState extends State<UserPage> {
text: "退出登录",
)
: const SizedBox()
]),
],
),
);
}
@ -140,7 +151,9 @@ class _UserPageState extends State<UserPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
UserTool.userProvider.isLogin ?UserTool.userProvider.userInfo.name : "登录/注册",
UserTool.userProvider.isLogin
? UserTool.userProvider.userInfo.name
: "登录/注册",
// UserTool.userProvider.userInfo.name ,
style: TextStyle(
fontSize: BaseStyle.fontSize48,
@ -168,7 +181,9 @@ class _UserPageState extends State<UserPage> {
},
child: ClipOval(
child: Image.asset(
UserTool.userProvider.isLogin?Assets.images.portraitDeep.path:Assets.images.portrait.path,
UserTool.userProvider.isLogin
? Assets.images.portraitDeep.path
: Assets.images.portrait.path,
height: 128.w,
width: 128.w,
fit: BoxFit.cover,
@ -185,7 +200,8 @@ class _UserPageState extends State<UserPage> {
return SizedBox(
// margin: EdgeInsets.symmetric(horizontal: 32.w),
height: 144.w,
child: Stack(children: [
child: Stack(
children: [
Align(
child: SizedBox(
width: 622.w,
@ -202,17 +218,30 @@ class _UserPageState extends State<UserPage> {
child: Row(
children: [_getText(), const Spacer(), _getBotton()],
),
))
]),
),
),
],
),
);
}
_getRequests() async {
endDate = DateUtil.formatDateMs(
UserTool.userProvider.userInfo.end * 1000,
format: DateFormats.y_mo_d);
setState(() {});
}
//banner botton
_getBotton() {
return GestureDetector(
onTap: () {
if (userProvider.isLogin) {
Get.to(() => const MembersPage());
Navigator.of(context)
.push(
MaterialPageRoute(builder: (_) => const MembersPage()),
)
.then((val) => _getRequests());
} else {
BotToast.showText(text: '您还未登录,请先登录!');
}
@ -302,7 +331,6 @@ class _UserPageState extends State<UserPage> {
trailing: Switch(
value: vle,
onChanged: (value) async {
final SharedPreferences prefs = await _prefs;
// if(!value){
//
@ -330,7 +358,9 @@ class _UserPageState extends State<UserPage> {
} else {
prefs.remove("kg");
prefs.setBool("kg", vle);
service.invoke("stopService");///
service.invoke("stopService");
///
// exit(0);
// UserTool.userProvider.setKg(vle);
// prefs.setBool("kg", false);
@ -342,11 +372,11 @@ class _UserPageState extends State<UserPage> {
} else {
BotToast.showText(text: "还没有开通会员,不可使用改功能");
}
});
}),
));
}
_getSwitch(String url, String name, bool pd) {
return GestureDetector(
onTap: () async {
@ -354,8 +384,9 @@ class _UserPageState extends State<UserPage> {
switch (name) {
case "短信标签":
Get.to(() => ContentDetailsPage(
content:
UserTool.userProvider.isLogin ? UserTool.userProvider.userInfo.tag : "",
content: UserTool.userProvider.isLogin
? UserTool.userProvider.userInfo.tag
: "",
ploneBack: (String textContent) {
// print("这是数据" + textContent);
// textList.setAll(index, {textContent});

@ -18,7 +18,7 @@ class CloudBackButton extends StatelessWidget {
? Padding(
padding: isSpecial ? EdgeInsets.only(left: 8.w) : EdgeInsets.zero,
child: IconButton(
onPressed: () => Get.back(),
onPressed: () => Navigator.pop(context,true),
icon: Icon(
CupertinoIcons.chevron_back,
color: color,

Loading…
Cancel
Save