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.
349 lines
11 KiB
349 lines
11 KiB
4 years ago
|
import 'dart:io';
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:huixiang/generated/l10n.dart';
|
||
|
import 'package:huixiang/retrofit/retrofit_api.dart';
|
||
|
import 'package:huixiang/view_widget/item_title.dart';
|
||
|
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
|
||
|
|
||
|
import 'package:dio/dio.dart';
|
||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
|
||
|
class PointsMallPage extends StatefulWidget {
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _PointsMallPage();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class _PointsMallPage extends State<PointsMallPage> {
|
||
|
var _itemText = S.current.morenpaixu;
|
||
|
|
||
|
ApiService client;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
|
||
|
|
||
|
SharedPreferences.getInstance().then((value) => {
|
||
|
client = ApiService(Dio(), token: value.getString('token')),
|
||
|
creditGoods()
|
||
|
});
|
||
|
}
|
||
|
|
||
|
creditGoods() async {
|
||
|
var paramt = {
|
||
|
"categoryId": 1,
|
||
|
"isHot": true,
|
||
|
"orderDesc": true,
|
||
|
"orderType": 0,
|
||
|
"pageNum": 1,
|
||
|
"pageSize": 10,
|
||
|
"searchKey": "",
|
||
|
"state": 0
|
||
|
};
|
||
|
client.creditGoods(paramt);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
List<DropdownMenuItem<String>> sortItems = [];
|
||
|
sortItems.add(DropdownMenuItem(
|
||
|
value: S.of(context).morenpaixu,
|
||
|
child: Text(S.of(context).morenpaixu)));
|
||
|
sortItems.add(DropdownMenuItem(
|
||
|
value: S.of(context).duihuanlianggaodaodi,
|
||
|
child: Text(S.of(context).duihuanlianggaodaodi)));
|
||
|
sortItems.add(DropdownMenuItem(
|
||
|
value: S.of(context).duihuanliangdidaogao,
|
||
|
child: Text(S.of(context).duihuanliangdidaogao)));
|
||
|
sortItems.add(DropdownMenuItem(
|
||
|
value: S.of(context).jifengaodaodi,
|
||
|
child: Text(S.of(context).jifengaodaodi)));
|
||
|
sortItems.add(DropdownMenuItem(
|
||
|
value: S.of(context).jifendidaogao,
|
||
|
child: Text(S.of(context).jifendidaogao)));
|
||
|
return SingleChildScrollView(
|
||
|
physics: BouncingScrollPhysics(),
|
||
|
child: Container(
|
||
|
color: Color(0xFFFAFAFA),
|
||
|
child: Column(
|
||
|
children: [
|
||
|
banner(),
|
||
|
userItem(),
|
||
|
ItemTitle(
|
||
|
text: S.of(context).jifenshangcheng,
|
||
|
imgPath: "assets/image/icon_points_mall.png",
|
||
|
moreText: _itemText,
|
||
|
moreType: 1,
|
||
|
items: sortItems,
|
||
|
onChanged: (item) {
|
||
|
setState(() {
|
||
|
_itemText = item;
|
||
|
});
|
||
|
},
|
||
|
),
|
||
|
GridView.builder(
|
||
|
itemCount: 8,
|
||
|
padding: EdgeInsets.only(left: 16, right: 16, top: 16),
|
||
|
shrinkWrap: true,
|
||
|
physics: NeverScrollableScrollPhysics(),
|
||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||
|
//一行的Widget数量
|
||
|
crossAxisCount: 2,
|
||
|
//水平子Widget之间间距
|
||
|
crossAxisSpacing: 11.0,
|
||
|
//垂直子Widget之间间距
|
||
|
mainAxisSpacing: 16,
|
||
|
//子Widget宽高比例
|
||
|
childAspectRatio: Platform.isAndroid ? 0.57 : 0.60,
|
||
|
),
|
||
|
itemBuilder: (contetx, index) {
|
||
|
return GestureDetector(
|
||
|
onTap: () {
|
||
|
Navigator.of(context)
|
||
|
.pushNamed('/router/integral_store_page');
|
||
|
},
|
||
|
child: buildItem(),
|
||
|
);
|
||
|
})
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget buildItem() {
|
||
|
return Container(
|
||
|
alignment: Alignment.center,
|
||
|
decoration: BoxDecoration(
|
||
|
borderRadius: BorderRadius.all(
|
||
|
Radius.circular(4),
|
||
|
),
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Colors.black.withAlpha(12),
|
||
|
offset: Offset(0, 3),
|
||
|
blurRadius: 14,
|
||
|
spreadRadius: 0)
|
||
|
],
|
||
|
color: Colors.white),
|
||
|
child: Stack(
|
||
|
alignment: AlignmentDirectional.topEnd,
|
||
|
fit: StackFit.loose,
|
||
|
children: [
|
||
|
Column(
|
||
|
children: [
|
||
|
Container(
|
||
|
child: AspectRatio(
|
||
|
aspectRatio: 1,
|
||
|
child: ClipRRect(
|
||
|
borderRadius: BorderRadius.only(
|
||
|
topLeft: Radius.circular(4),
|
||
|
topRight: Radius.circular(4)),
|
||
|
child: Image.network(
|
||
|
"https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF",
|
||
|
fit: BoxFit.cover,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
margin:
|
||
|
EdgeInsets.only(left: 12, right: 12, bottom: 16, top: 10),
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||
|
children: [
|
||
|
Text(
|
||
|
"牙刷杯",
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
fontSize: 16),
|
||
|
),
|
||
|
Text(
|
||
|
S.of(context).yiduihuanjian("2.5万"),
|
||
|
style:
|
||
|
TextStyle(color: Color(0xFFA29E9E), fontSize: 10),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
SizedBox(
|
||
|
height: 8,
|
||
|
),
|
||
|
Container(
|
||
|
height: 34,
|
||
|
child: Text(
|
||
|
"海峡姐妹联名马克杯只需少量积分",
|
||
|
maxLines: 2,
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF727272),
|
||
|
fontSize: 12,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
SizedBox(
|
||
|
height: 12,
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||
|
children: [
|
||
|
Text(
|
||
|
S.of(context).yuan(55),
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF585858),
|
||
|
decoration: TextDecoration.lineThrough,
|
||
|
decorationColor: Color(0xFF585858),
|
||
|
fontSize: 12),
|
||
|
),
|
||
|
Text(
|
||
|
S.of(context).jifen_(99),
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF32A060),
|
||
|
fontSize: 14,
|
||
|
fontWeight: FontWeight.bold),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
ClipRRect(
|
||
|
borderRadius: BorderRadius.only(topRight: Radius.circular(4)),
|
||
|
child: Image.asset(
|
||
|
"assets/image/icon_hot_right_top.png",
|
||
|
width: 36,
|
||
|
height: 36,
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget userItem() {
|
||
|
return Container(
|
||
|
margin: EdgeInsets.all(16),
|
||
|
child: Row(
|
||
|
children: [
|
||
|
ClipRRect(
|
||
|
borderRadius: BorderRadius.all(Radius.circular(2)),
|
||
|
child: Image.network(
|
||
|
"https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF",
|
||
|
fit: BoxFit.cover,
|
||
|
width: 50,
|
||
|
height: 50,
|
||
|
),
|
||
|
),
|
||
|
Expanded(
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(left: 15),
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Text(
|
||
|
S.of(context).yonghuming,
|
||
|
style: TextStyle(
|
||
|
fontSize: 14,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
color: Color(0xFF353535)),
|
||
|
),
|
||
|
Row(
|
||
|
children: [
|
||
|
Image.asset(
|
||
|
"assets/image/icon_an_crown.png",
|
||
|
width: 13,
|
||
|
height: 13,
|
||
|
),
|
||
|
Text(
|
||
|
"白金会员",
|
||
|
style:
|
||
|
TextStyle(fontSize: 12, color: Color(0xFF353535)),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
flex: 1,
|
||
|
),
|
||
|
Container(
|
||
|
margin: EdgeInsets.only(left: 15),
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||
|
children: [
|
||
|
Text(
|
||
|
S.of(context).yiyoujifen,
|
||
|
style: TextStyle(
|
||
|
fontSize: 12,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
color: Color(0xFF4C4C4C)),
|
||
|
),
|
||
|
Text(
|
||
|
"6623",
|
||
|
style: TextStyle(
|
||
|
fontSize: 16,
|
||
|
color: Color(0xFFF8BA61),
|
||
|
fontWeight: FontWeight.bold),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
banner() {
|
||
|
var images = [
|
||
|
"https://t7.baidu.com/it/u=963301259,1982396977&fm=193&f=GIF",
|
||
|
"https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF",
|
||
|
"https://t7.baidu.com/it/u=1297102096,3476971300&fm=193&f=GIF",
|
||
|
"https://t7.baidu.com/it/u=91673060,7145840&fm=193&f=GIF",
|
||
|
"https://t7.baidu.com/it/u=3655946603,4193416998&fm=193&f=GIF",
|
||
|
];
|
||
|
return Container(
|
||
|
margin: EdgeInsets.only(top: 16, bottom: 16),
|
||
|
child: AspectRatio(
|
||
|
aspectRatio: 2.0,
|
||
|
child: Swiper(
|
||
|
pagination: SwiperPagination(
|
||
|
alignment: Alignment.bottomCenter,
|
||
|
builder: DotSwiperPaginationBuilder(
|
||
|
size: 8,
|
||
|
activeSize: 8,
|
||
|
space: 5,
|
||
|
activeColor: Colors.black,
|
||
|
color: Colors.black.withAlpha(76))),
|
||
|
viewportFraction: 0.7,
|
||
|
scale: 0.7,
|
||
|
loop: true,
|
||
|
itemBuilder: (context, position) {
|
||
|
return Container(
|
||
|
margin: EdgeInsets.only(bottom: 40),
|
||
|
decoration: BoxDecoration(
|
||
|
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||
|
child: ClipRRect(
|
||
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||
|
child: Image(
|
||
|
fit: BoxFit.cover,
|
||
|
image: NetworkImage(images.elementAt(position))),
|
||
|
));
|
||
|
},
|
||
|
itemCount: images.length),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|