Browse Source

safety

master
fmk 3 years ago
parent
commit
044677b931
  1. 2
      lib/home/points_mall_page.dart
  2. 72
      lib/integral/integral_page.dart
  3. 170
      lib/mine/vip_card_page.dart
  4. 27
      lib/mine/vip_detail_page.dart
  5. 3
      lib/utils/location.dart
  6. 2
      lib/utils/painter_bg.dart
  7. 2
      lib/view_widget/custom_image.dart

2
lib/home/points_mall_page.dart

@ -245,7 +245,7 @@ class _PointsMallPage extends State<PointsMallPage>
onTap: (index) { onTap: (index) {
categoryId = gooodsCategorys[index].id; categoryId = gooodsCategorys[index].id;
pageNum = 1; pageNum = 1;
creditGoods(); setState(() {});;
}, },
), ),
), ),

72
lib/integral/integral_page.dart

@ -132,12 +132,13 @@ class _IntegralPage extends State<IntegralPage> {
Widget integralTask() { Widget integralTask() {
return Container( return Container(
width: double.infinity, width: MediaQuery.of(context).size.width - 32,
height: 300.h,
margin: EdgeInsets.all(16), margin: EdgeInsets.all(16),
padding: EdgeInsets.fromLTRB(10.w, 20.h, 10.w, 20.h), padding: EdgeInsets.fromLTRB(10.w, 20.h, 10.w, 20.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(8)), borderRadius: BorderRadius.circular(8),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withAlpha(12), color: Colors.black.withAlpha(12),
@ -162,9 +163,8 @@ class _IntegralPage extends State<IntegralPage> {
), ),
), ),
), ),
Container( Expanded(
child: AspectRatio( child: Container(
aspectRatio: 1.5,
child: Swiper( child: Swiper(
loop: false, loop: false,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
@ -190,7 +190,8 @@ class _IntegralPage extends State<IntegralPage> {
(signInfo.taskList.length % 3 > 0 ? 1 : 0))) (signInfo.taskList.length % 3 > 0 ? 1 : 0)))
: 1), : 1),
), ),
), flex: 1,
)
], ],
), ),
); );
@ -293,10 +294,10 @@ class _IntegralPage extends State<IntegralPage> {
backgroup: task.limitDay == (task.complateNum ?? task.conplateNum) backgroup: task.limitDay == (task.complateNum ?? task.conplateNum)
? Color(0xFFA0A0A0) ? Color(0xFFA0A0A0)
: Color(0xFF32A060), : Color(0xFF32A060),
radius: 12, radius: 12.w,
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
padding: EdgeInsets.fromLTRB(12.w, 4.h, 12.w, 4.h), padding: EdgeInsets.symmetric(vertical: 4.h, horizontal: 12.w),
), ),
], ],
), ),
@ -306,7 +307,7 @@ class _IntegralPage extends State<IntegralPage> {
Widget signInItem(position) { Widget signInItem(position) {
if (position == 6) { if (position == 6) {
return Container( return Container(
padding: EdgeInsets.all(6), padding: EdgeInsets.all(4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFF0F0F2), color: Color(0xFFF0F0F2),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
@ -317,7 +318,7 @@ class _IntegralPage extends State<IntegralPage> {
children: [ children: [
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
@ -328,11 +329,9 @@ class _IntegralPage extends State<IntegralPage> {
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
), ),
), ),
SizedBox(
height: 10.h,
),
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
height: 30.h,
child: Text( child: Text(
S.of(context).shenmijifendali, S.of(context).shenmijifendali,
style: TextStyle( style: TextStyle(
@ -342,6 +341,14 @@ class _IntegralPage extends State<IntegralPage> {
), ),
), ),
), ),
Text(
"",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
], ],
), ),
flex: 1, flex: 1,
@ -350,8 +357,8 @@ class _IntegralPage extends State<IntegralPage> {
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
"assets/image/icon_gold_blessing.png", "assets/image/icon_gold_blessing.png",
width: 59, width: 59.w,
height: 59, height: 59.h,
), ),
), ),
], ],
@ -388,8 +395,8 @@ class _IntegralPage extends State<IntegralPage> {
alignment: Alignment.center, alignment: Alignment.center,
child: Image.asset( child: Image.asset(
"assets/image/icon_gold_coin.png", "assets/image/icon_gold_coin.png",
width: 30, width: 30.w,
height: 30, height: 30.h,
), ),
), ),
Container( Container(
@ -404,13 +411,14 @@ class _IntegralPage extends State<IntegralPage> {
? "+${signInfo.rewardList[position]}" ? "+${signInfo.rewardList[position]}"
: "+10", : "+10",
style: TextStyle( style: TextStyle(
color: (signInfo != null && color: (signInfo != null &&
signInfo.signInList != null && signInfo.signInList != null &&
signInfo.signInList.length > position) signInfo.signInList.length > position)
? Colors.white ? Colors.white
: Color(0xFF727272), : Color(0xFF727272),
fontSize: 12.sp, fontSize: 12.sp,
fontWeight: MyFontWeight.regular), fontWeight: MyFontWeight.regular,
),
), ),
), ),
], ],
@ -424,7 +432,7 @@ class _IntegralPage extends State<IntegralPage> {
return Container( return Container(
width: double.infinity, width: double.infinity,
margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h), margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h),
padding: EdgeInsets.fromLTRB(20.w, 20.h, 20.w, 20.h), padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
@ -467,9 +475,9 @@ class _IntegralPage extends State<IntegralPage> {
crossAxisCount: 4, crossAxisCount: 4,
shrinkWrap: true, shrinkWrap: true,
itemCount: 7, itemCount: 7,
mainAxisSpacing: 8.h, mainAxisSpacing: 8,
crossAxisSpacing: 18.w, crossAxisSpacing: 18,
padding: EdgeInsets.only(bottom: 32.h), padding: EdgeInsets.only(bottom: 32),
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return signInItem(position); return signInItem(position);
@ -483,8 +491,8 @@ class _IntegralPage extends State<IntegralPage> {
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
child: RoundButton( child: RoundButton(
width: 106, width: 106.w,
height: 34, height: 34.h,
text: (signInfo != null && signInfo.todayHasSignin) text: (signInfo != null && signInfo.todayHasSignin)
? S.of(context).yiqiandao ? S.of(context).yiqiandao
: S.of(context).lijiqiandao, : S.of(context).lijiqiandao,
@ -494,8 +502,8 @@ class _IntegralPage extends State<IntegralPage> {
: Color(0xFF32A060), : Color(0xFF32A060),
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
padding: EdgeInsets.fromLTRB(16.w, 6.h, 16.w, 6.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h),
radius: 4, radius: 4.w,
), ),
), ),
), ),

170
lib/mine/vip_card_page.dart

@ -32,7 +32,8 @@ class _VipCardPage extends State<VipCardPage> {
_refreshController = RefreshController(); _refreshController = RefreshController();
SharedPreferences.getInstance().then((value) { SharedPreferences.getInstance().then((value) {
apiService = ApiService(Dio(), context: context, token: value.getString("token")); apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
queryVipCard(); queryVipCard();
}); });
} }
@ -40,7 +41,8 @@ class _VipCardPage extends State<VipCardPage> {
List<VipCard> coupons = []; List<VipCard> coupons = [];
queryVipCard() async { queryVipCard() async {
BaseData<List<VipCard>> baseData = await apiService.vipList({}).catchError((error) { BaseData<List<VipCard>> baseData =
await apiService.vipList({}).catchError((error) {
_refreshController.refreshFailed(); _refreshController.refreshFailed();
}); });
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
@ -70,24 +72,27 @@ class _VipCardPage extends State<VipCardPage> {
controller: _refreshController, controller: _refreshController,
onRefresh: queryVipCard, onRefresh: queryVipCard,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: (coupons != null && coupons.length > 0) ? ListView.builder( child: (coupons != null && coupons.length > 0)
padding: EdgeInsets.symmetric(vertical: 8.h), ? ListView.builder(
itemBuilder: (context, position) { padding: EdgeInsets.symmetric(vertical: 8.h),
return GestureDetector( itemBuilder: (context, position) {
onTap: () { return GestureDetector(
Navigator.of(context).pushNamed('/router/vip_details_page', onTap: () {
arguments: {"id": coupons[position].id}); Navigator.of(context).pushNamed(
}, '/router/vip_details_page',
child: vipCardItem(coupons[position]), arguments: {"id": coupons[position].id});
); },
}, child: vipCardItem(coupons[position]),
itemCount: coupons != null ? coupons.length : 0, );
) : NoDataView( },
isShowBtn: false, itemCount: coupons != null ? coupons.length : 0,
text: "还没有会员卡~", )
fontSize: 16.sp, : NoDataView(
margin: EdgeInsets.only(top: 120.h), isShowBtn: false,
), text: "还没有会员卡~",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h),
),
), ),
), ),
); );
@ -107,18 +112,19 @@ class _VipCardPage extends State<VipCardPage> {
Widget vipCardItem(VipCard vipCard) { Widget vipCardItem(VipCard vipCard) {
return Container( return Container(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 8.h), margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
color: Colors.white, color: Colors.white,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withAlpha(12), color: Colors.black.withAlpha(12),
offset: Offset(0, 3), offset: Offset(0, 3),
blurRadius: 14, blurRadius: 14,
spreadRadius: 0, spreadRadius: 0,
) )
],), ],
),
child: Stack( child: Stack(
children: [ children: [
Positioned( Positioned(
@ -144,7 +150,9 @@ class _VipCardPage extends State<VipCardPage> {
Row( Row(
children: [ children: [
MImage( MImage(
(vipCard?.storeList?.length ?? 0) > 0 ? vipCard.storeList[0].logo : "", (vipCard?.storeList?.length ?? 0) > 0
? vipCard.storeList[0].logo
: "",
width: 54, width: 54,
height: 54, height: 54,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -185,16 +193,18 @@ class _VipCardPage extends State<VipCardPage> {
], ],
), ),
Text.rich( Text.rich(
TextSpan(children: [ TextSpan(
TextSpan( children: [
text:S.of(context).huiyuanka, TextSpan(
style: TextStyle( text: S.of(context).huiyuanka,
fontSize: 12.sp, style: TextStyle(
fontWeight: MyFontWeight.medium, fontSize: 12.sp,
color: Colors.black, fontWeight: MyFontWeight.medium,
color: Colors.black,
),
), ),
), ],
],), ),
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
), ),
], ],
@ -214,16 +224,18 @@ class _VipCardPage extends State<VipCardPage> {
size: 24, size: 24,
), ),
Text.rich( Text.rich(
TextSpan(children: [ TextSpan(
TextSpan( children: [
text:S.of(context).chakanxiangqing, TextSpan(
style: TextStyle( text: S.of(context).chakanxiangqing,
fontSize: 12.sp, style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 12.sp,
color: Colors.black, fontWeight: FontWeight.bold,
color: Colors.black,
),
), ),
), ],
],), ),
), ),
], ],
), ),
@ -237,41 +249,47 @@ class _VipCardPage extends State<VipCardPage> {
Expanded( Expanded(
flex: 1, flex: 1,
child: Text.rich( child: Text.rich(
TextSpan(children: [ TextSpan(
children: [
TextSpan(
text: "No.${vipCard.id}",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
],
),
),
),
Text.rich(
TextSpan(
children: [
TextSpan( TextSpan(
text: "No.${vipCard.id}", text: S.of(context).youxiaoqixian,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 12.sp,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
color: Colors.black, color: Color(0Xff353535),
), ),
), ),
],), ],
), ),
), ),
Text.rich( Text.rich(
TextSpan(children: [ TextSpan(
TextSpan( children: [
text: S.of(context).youxiaoqixian, TextSpan(
style: TextStyle( text: S.of(context).changqiyouxiao,
fontSize: 12.sp, style: TextStyle(
fontWeight: MyFontWeight.regular, fontSize: 12.sp,
color: Color(0Xff353535), fontWeight: MyFontWeight.regular,
), color: Color(0Xff353535),
), ),
],),
),
Text.rich(
TextSpan(children: [
TextSpan(
text: S.of(context).changqiyouxiao,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0Xff353535),
), ),
), ],
],), ),
), ),
], ],
), ),

27
lib/mine/vip_detail_page.dart

@ -1,6 +1,7 @@
import 'package:barcode_widget/barcode_widget.dart'; import 'package:barcode_widget/barcode_widget.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/data/order_info.dart';
@ -43,6 +44,11 @@ class _VipDetailPage extends State<VipDetailPage> {
vipDetail("", ""); vipDetail("", "");
startLocation();
}
startLocation() async {
EasyLoading.show(status: S.current.zhengzaijiazai);
Location.getInstance() Location.getInstance()
.aMapFlutterLocation .aMapFlutterLocation
.onResultCallback() .onResultCallback()
@ -50,15 +56,18 @@ class _VipDetailPage extends State<VipDetailPage> {
if (event != null && if (event != null &&
event["latitude"] != null && event["latitude"] != null &&
event["longitude"] != null) { event["longitude"] != null) {
SharedPreferences.getInstance().then((value) { vipDetail(event["latitude"], event["longitude"]);
apiService = ApiService(Dio(), } else {
context: context, token: value.getString("token")); EasyLoading.dismiss();
vipDetail(event["latitude"], event["longitude"]);
});
} }
}); });
Location.getInstance().prepareLoc(); Location.getInstance().prepareLoc();
Location.getInstance().startLocation(context); Location.getInstance().startLocation(context).then((value) {
if (!value) {
EasyLoading.dismiss();
refreshController.refreshFailed();
}
});
} }
VipCard vipCard; VipCard vipCard;
@ -66,6 +75,9 @@ class _VipDetailPage extends State<VipDetailPage> {
int current = 1; int current = 1;
vipDetail(latitude, longitude) async { vipDetail(latitude, longitude) async {
final SharedPreferences value = await SharedPreferences.getInstance();
if(apiService == null)
apiService = ApiService(Dio(), context: context, token: value.getString("token"));
BaseData<VipCard> baseData = await apiService.vipDetail({ BaseData<VipCard> baseData = await apiService.vipDetail({
"id": widget.arguments["id"], "id": widget.arguments["id"],
"latitude": "$latitude", "latitude": "$latitude",
@ -74,10 +86,11 @@ class _VipDetailPage extends State<VipDetailPage> {
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
vipCard = baseData.data; vipCard = baseData.data;
refreshController.loadComplete(); refreshController.loadComplete();
setState(() {});
} else { } else {
refreshController.loadFailed(); refreshController.loadFailed();
} }
print("object:object");
setState(() {});
} }
@override @override

3
lib/utils/location.dart

@ -74,7 +74,8 @@ class Location {
} }
void stopLocation() { void stopLocation() {
aMapFlutterLocation.stopLocation(); if (aMapFlutterLocation != null)
aMapFlutterLocation.stopLocation();
} }
enableLocation(context) { enableLocation(context) {

2
lib/utils/painter_bg.dart

@ -15,6 +15,7 @@ class BgPainter extends CustomPainter {
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
Path path = Path(); Path path = Path();
// P0点 线 // P0点 线
path.lineTo(0, 0); path.lineTo(0, 0);
path.lineTo(size.width, 0); path.lineTo(size.width, 0);
@ -23,6 +24,7 @@ class BgPainter extends CustomPainter {
path.close(); path.close();
Paint paint = Paint() Paint paint = Paint()
..isAntiAlias = true
..color = bgColor ..color = bgColor
..style = PaintingStyle.fill; ..style = PaintingStyle.fill;

2
lib/view_widget/custom_image.dart

@ -13,7 +13,7 @@ class MImage extends StatelessWidget {
final BoxFit fit; final BoxFit fit;
final bool isCircle; final bool isCircle;
double scaleIndex = 2.5; double scaleIndex = 3.5;
MImage( MImage(
this.src, { this.src, {

Loading…
Cancel
Save