对接彩票列表接口

master
laiiihz 5 years ago
parent 634030ffd3
commit e0f2885cf7

@ -359,3 +359,12 @@ class SystemApi {
return _instance;
}
}
///API
class LotteryAPI {
///
static const String list = "/v1/ticket/list";
///
static const String redeem_history = "/v1/ticket/order/list";
}

@ -74,7 +74,6 @@ class _LotteryHistoryPageState extends State<LotteryHistoryPage> {
children: [
Expanded(
child: LotteryResultBoxes(
type: LotteryType.DOUBLE_LOTTERY,
redBalls: [1, 2, 3, 4, 5, 6],
blueBalls: [7],
),

@ -60,7 +60,6 @@ class _LotteryPickerPageState extends State<LotteryPickerPage> {
),
Expanded(
child: LotteryResultBoxes(
type: LotteryType.DOUBLE_LOTTERY,
small: true,
redBalls: [1, 2, 3, 4, 5, 6],
blueBalls: [1],

@ -1,4 +1,4 @@
class LotteryList {
class LotteryListModel {
int id;
String name;
String icon;
@ -6,10 +6,10 @@ class LotteryList {
Now now;
Now last;
LotteryList(
LotteryListModel(
{this.id, this.name, this.icon, this.number, this.now, this.last});
LotteryList.fromJson(Map<String, dynamic> json) {
LotteryListModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
icon = json['icon'];
@ -36,7 +36,7 @@ class LotteryList {
class Now {
int id;
String lotteryId;
int lotteryId;
String number;
String startTime;
String stopTime;

@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
import 'package:recook/constants/api.dart';
import 'package:recook/constants/header.dart';
import 'package:recook/manager/http_manager.dart';
import 'package:recook/pages/lottery/models/lottery_list_model.dart';
import 'package:recook/pages/lottery/widget/lottery_result_boxes.dart';
import 'package:recook/pages/lottery/widget/lottery_scaffold.dart';
import 'package:recook/widgets/custom_image_button.dart';
@ -17,6 +20,22 @@ class RedeemLotteryPage extends StatefulWidget {
}
class _RedeemLotteryPageState extends State<RedeemLotteryPage> {
List<LotteryListModel> _models = [];
@override
void initState() {
super.initState();
HttpManager.post(LotteryAPI.list, {}).then((resultData) {
setState(() {
_models = resultData.data['data'] == null
? []
: (resultData.data['data'] as List)
.map((e) => LotteryListModel.fromJson(e))
.toList();
});
});
}
@override
Widget build(BuildContext context) {
return LotteryScaffold(
@ -34,37 +53,51 @@ class _RedeemLotteryPageState extends State<RedeemLotteryPage> {
),
),
],
body: ListView(
children: [
_lotteryCard(
type: LotteryType.DOUBLE_LOTTERY,
redBalls: [2, 6, 11, 14, 18, 22],
blueBalls: [2],
),
_lotteryCard(
type: LotteryType.BIG_LOTTERY,
redBalls: [2, 6, 11, 14, 18],
blueBalls: [7, 12],
),
],
),
body: _models.isEmpty
? Center(
child: CircularProgressIndicator(),
)
: ListView(
children: _models
.map(
(e) => _lotteryCard(model: e),
)
.toList(),
),
);
}
_lotteryCard({
LotteryType type,
List<int> redBalls,
List<int> blueBalls,
}) {
String title = type == LotteryType.DOUBLE_LOTTERY ? "双色球" : "大乐透";
String asset = type == LotteryType.DOUBLE_LOTTERY
? R.ASSETS_LOTTERY_REDEEM_DOUBLE_LOTTERY_PNG
: R.ASSETS_LOTTERY_REDEEM_BIG_LOTTERY_PNG;
Widget _lotteryCard({@required LotteryListModel model}) {
String asset;
switch (model.id) {
case 1:
asset = R.ASSETS_LOTTERY_REDEEM_DOUBLE_LOTTERY_PNG;
break;
case 2:
asset = R.ASSETS_LOTTERY_REDEEM_BIG_LOTTERY_PNG;
break;
default:
asset = R.ASSETS_LOTTERY_REDEEM_DOUBLE_LOTTERY_PNG;
}
List<int> redBalls, blueBalls;
if (TextUtils.isNotEmpty(model.last.bonusCode)) {
redBalls = model.last.bonusCode
.split('#')[0]
.split(',')
.map((e) => int.parse(e))
.toList();
blueBalls = model.last.bonusCode
.split('#')[1]
.split(',')
.map((e) => int.parse(e))
.toList();
}
return CustomImageButton(
onPressed: () {
AppRouter.push(context, RouteName.LOTTERY_PICKER_PAGE,
arguments: {'type': type == LotteryType.DOUBLE_LOTTERY});
arguments: {'type': model.id == 1});
},
child: Container(
padding: EdgeInsets.all(rSize(16)),
@ -92,14 +125,14 @@ class _RedeemLotteryPageState extends State<RedeemLotteryPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
model.name,
style: TextStyle(
color: Color(0xFF333333),
fontSize: rSP(16),
),
),
Text(
'20200820',
'${model.last.number}\',
style: TextStyle(
color: Color(0xFF666666),
fontSize: rSP(12),
@ -116,18 +149,19 @@ class _RedeemLotteryPageState extends State<RedeemLotteryPage> {
],
),
SizedBox(height: rSize(20)),
Row(
children: [
Expanded(
child: LotteryResultBoxes(
type: type,
redBalls: redBalls,
blueBalls: blueBalls,
redBalls == null
? SizedBox()
: Row(
children: [
Expanded(
child: LotteryResultBoxes(
redBalls: redBalls ?? [],
blueBalls: blueBalls ?? [],
),
),
SizedBox(width: rSize(34)),
],
),
),
SizedBox(width: rSize(34)),
],
),
],
),
),

@ -1,26 +1,16 @@
import 'package:flutter/material.dart';
import 'package:recook/pages/lottery/redeem_lottery_page.dart';
import 'package:recook/pages/lottery/widget/lottery_ball.dart';
class LotteryResultBoxes extends StatelessWidget {
final LotteryType type;
final List<int> redBalls;
final List<int> blueBalls;
final bool small;
const LotteryResultBoxes({
Key key,
this.type,
this.redBalls,
this.blueBalls,
this.small = false,
})
//
: assert(redBalls.length == (type == LotteryType.DOUBLE_LOTTERY ? 6 : 5),
"红球数量错误"),
//
assert(
blueBalls.length == (type == LotteryType.DOUBLE_LOTTERY ? 1 : 2)),
super(key: key);
}) : super(key: key);
@override
Widget build(BuildContext context) {

Loading…
Cancel
Save