You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
7.0 KiB

4 years ago
import 'dart:convert';
4 years ago
import 'package:dio/dio.dart';
4 years ago
import 'package:flutter/material.dart';
3 years ago
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
4 years ago
import 'package:huixiang/generated/l10n.dart';
3 years ago
import 'package:huixiang/integral/intergra_view/in_for_points.dart';
import 'package:huixiang/integral/intergra_view/integral_vip.dart';
4 years ago
import 'package:huixiang/retrofit/data/base_data.dart';
4 years ago
import 'package:huixiang/retrofit/data/rank.dart';
4 years ago
import 'package:huixiang/retrofit/data/sign_info.dart';
4 years ago
import 'package:huixiang/retrofit/data/user_info.dart';
4 years ago
import 'package:huixiang/retrofit/retrofit_api.dart';
3 years ago
import 'package:huixiang/utils/font_weight.dart';
3 years ago
import 'package:huixiang/view_widget/classic_header.dart';
4 years ago
import 'package:huixiang/view_widget/my_appbar.dart';
3 years ago
import 'package:huixiang/view_widget/my_footer.dart';
4 years ago
import 'package:huixiang/view_widget/sign_in_widget.dart';
3 years ago
import 'package:pull_to_refresh/pull_to_refresh.dart';
4 years ago
import 'package:shared_preferences/shared_preferences.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
3 years ago
import 'intergra_view/integral_task.dart';
4 years ago
class IntegralPage extends StatefulWidget {
3 years ago
4 years ago
@override
State<StatefulWidget> createState() {
return _IntegralPage();
}
}
class _IntegralPage extends State<IntegralPage> {
4 years ago
ApiService apiService;
SignInfo signInfo;
3 years ago
UserInfo userInfo;
4 years ago
List<Rank> ranks = [];
int rankLevel = 1;
3 years ago
final ScrollController scrollController = ScrollController();
final RefreshController refreshController = RefreshController();
4 years ago
4 years ago
querySignInfo() async {
3 years ago
// EasyLoading.show(status: S.of(context).zhengzaijiazai);
3 years ago
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
showLoading: false,
);
userInfo = UserInfo.fromJson(jsonDecode(value.getString("user")));
4 years ago
3 years ago
BaseData<List<Rank>> rankData = await apiService.rankList()
.catchError((onError) {});
4 years ago
if (rankData != null && rankData.isSuccess) {
ranks.clear();
3 years ago
ranks.addAll(rankData.data);
3 years ago
refreshController.refreshCompleted();
}else {
refreshController.refreshFailed();
4 years ago
}
3 years ago
if (userInfo != null &&
userInfo.memberRankVo != null &&
4 years ago
ranks != null &&
ranks.length > 0) {
rankLevel = (ranks
3 years ago
.indexWhere((element) => element.id == userInfo.memberRankVo.id) +
4 years ago
1);
}
3 years ago
BaseData<SignInfo> baseData =
await apiService.signInInfo().catchError((onError) {});
4 years ago
if (baseData != null && baseData.isSuccess) {
3 years ago
signInfo = baseData.data;
3 years ago
refreshController.refreshCompleted();
4 years ago
}
3 years ago
EasyLoading.dismiss();
4 years ago
}
4 years ago
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Stack(
children: [
// Positioned(
// child: Container(
// height: 122.h + kToolbarHeight + MediaQuery.of(context).padding.top,
// decoration: BoxDecoration(
// image: DecorationImage(
// fit: BoxFit.fill,
// image: AssetImage("assets/image/jifen.webp"),
// ),
// ),
// ),
// top: 0,
// left: 0,
// right: 0,
// ),
Container(
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage("assets/image/jifen.webp"),
),
4 years ago
),
width: double.infinity,
height: 215.h,
4 years ago
),
Scaffold(
backgroundColor: Colors.transparent,
appBar: MyAppBar(
exit: (){Navigator.of(context).pop(signInfo.todayHasSignin ?? false);},
background: Colors.transparent,
leadingColor: Colors.white,
title: "",
titleColor: Colors.white,
titleSize: 16.sp,
brightness: Brightness.dark,
action: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(right: 16.w),
child: GestureDetector(
onTap: () {
1.动态详情,评论-已显示全部—修改; 2.新增加集换卡详情页面; 3.语言-增加部分文本语言并更改; 4.回乡VIP板块更改;原本的VIP卡逻辑暂时不用,换成用户充值200即成为会员,该页面ui调整;(原来逻辑未删减,暂保留不使用) 5.16进制渐变色值的方法,改变亮度暂定统一为95; 6.首页ui调整;邀请好友图片处,原单一图片现更改为轮播效果,新增集换卡引导也放在此处; 7.积分明细页面更改;共用一个页面根据积分跟集换卡的入口,传对应的值,查看对应的数据; 8.积分明细跳转路径更改,新增一个类型带入路径中跳转传入; 9.更改测试版本服务地址; 10.我的页面跟首页更改一致,单一图片改轮播效果; 11.会员中心,会员卡部分更改;将原有写法去掉,重写了会员卡的使用显示,并优化了该页面数据的显示; 12.我的页面,vip等级显示更改; 13.会员卡列表等级接口,实体类新增部分字段;(原定位分数已不用,更改为originScore,后期若用的原字段,需要修改) 14.订单结算页,支付类型更换时queryOrderInfo()接口中。优惠类型做了调整更改;(改修改需要多测试下,尝试多种情况看下,是否有问题;有可能部分情况没有预判到) 15.点单页结算跳转,vipLevelName,vipLevelName字段做了非空判断; 16.UserInfo实体类新增isVip字段;(主要用于查看用户数据是查询该用户是否已是vip卡状态) 17.福利兑换中心页面,我的信息部分ui做调整,新增集换卡数量的显示;
2 years ago
Navigator.of(context).pushNamed('/router/integral_detailed_page',arguments:{"titleType":2});
},
child: Text(
S.of(context).mingxi,
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: MyFontWeight.bold,
),
3 years ago
),
),
4 years ago
),
4 years ago
),
body:SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh:(){
setState(() {
querySignInfo();
});
3 years ago
},
physics: BouncingScrollPhysics(),
scrollController: scrollController,
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: FutureBuilder(
future: querySignInfo(),
builder: (context, snap) {
return Column(
children: [
/// 上面的积分和VIP等级显示
IntegralVip(rankLevel, signInfo, userInfo,"${ (signInfo?.signInList?.length ) ?? "0"}",
((signInfo?.rewardList != null && signInfo.rewardList.length > (signInfo?.signInList?.length ?? 0)) ?
signInfo.rewardList[signInfo?.signInList?.length ?? 0]:0).toString()),
4 years ago
///立即签到
InForPoints(signInfo, _signIn),
4 years ago
///积分任务
IntegralTask(signInfo),
],
);
},
),
3 years ago
),
4 years ago
),
),
3 years ago
),
],
),
4 years ago
);
}
4 years ago
///立即签到
3 years ago
_signIn() async {
4 years ago
if ((signInfo != null && signInfo.todayHasSignin)) {
4 years ago
SmartDialog.showToast("今日已签到了", alignment: Alignment.center);
4 years ago
return;
}
EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black);
3 years ago
BaseData baseData = await apiService.signIn().catchError((onError) {});
4 years ago
if (baseData != null && baseData.isSuccess) {
3 years ago
setState(() {});
3 years ago
SmartDialog.show(
widget: SignInWidget("${signInfo.signInList.length + 1}",
"${signInfo.rewardList[signInfo.signInList.length]}"));
3 years ago
} else {
3 years ago
EasyLoading.dismiss();
4 years ago
}
}
4 years ago
}