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.
 
 
 
 
 
 

517 lines
22 KiB

import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/store.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/min.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:huixiang/view_widget/separator.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class UnionDetailsPage extends StatefulWidget {
final Map<String, dynamic> arguments;
UnionDetailsPage({this.arguments});
@override
State<StatefulWidget> createState() {
return _UnionDetailsPage();
}
}
class _UnionDetailsPage extends State<UnionDetailsPage> {
ApiService apiService;
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), token: value.getString('token')),
queryStoreInfo(),
});
}
StoreInfo storeInfo;
queryStoreInfo() async {
BaseData baseData = await apiService.queryStoreInfo(widget.arguments["id"]);
if (baseData.isSuccess) {
storeInfo = StoreInfo.fromJson(baseData.data);
} else {}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFFF7F7F7),
elevation: 0,
leading: GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Container(
alignment: Alignment.centerRight,
margin: EdgeInsets.only(left: 10.w),
padding: EdgeInsets.all(6.w),
child: Icon(
Icons.arrow_back_ios,
color: Colors.black,
size: 24.w,
),
),
),
titleSpacing: 2,
leadingWidth: 56.w,
),
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
children: [
AspectRatio(
aspectRatio: 1,
child: GestureDetector(
onTap: () {
Navigator.of(context)
.pushNamed('/router/store_detail_page');
},
child: Container(
margin: EdgeInsets.fromLTRB(16, 20, 16, 8),
padding: EdgeInsets.fromLTRB(10, 20, 10, 14),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(8)),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0,
)
]),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: 1.8,
child: buildSwiper(),
),
Expanded(
child: Container(
margin: EdgeInsets.only(
left: 10.w,
right: 10.w,
top: 16.h,
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
storeInfo != null
? storeInfo.storeName
: "",
style: TextStyle(
fontSize: 16.sp,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.black,
),
Expanded(
child: Container(
alignment: Alignment.centerRight,
child: Text(
S.of(context).ren(
storeInfo != null
? storeInfo
.perCapitaConsumption
: "",
),
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
)
],
),
Text(
storeInfo != null
? storeInfo.address
: "",
maxLines: 2,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp),
),
Row(
children: [
RoundButton(
text: S.of(context).kongtiao,
backgroup: Color(0xFFFF7A1A),
padding: EdgeInsets.only(
left: 2.w, right: 2.w),
fontSize: 10.sp,
),
SizedBox(
width: 8.w,
),
RoundButton(
text: "WiFi",
backgroup: Color(0xFFFF7A1A),
padding: EdgeInsets.only(
left: 2.w, right: 2.w),
fontSize: 10.sp,
),
SizedBox(
width: 8.w,
),
RoundButton(
text: S.of(context).tingchewei,
backgroup: Color(0xFFFF7A1A),
padding: EdgeInsets.only(
left: 2.w, right: 2.w),
fontSize: 10.sp,
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Expanded(
child: Text(
S.of(context).yingyeshijian(storeInfo ==
null
? ""
: (storeInfo.openStartTime ==
null &&
storeInfo.openEndTime ==
null)
? "全天"
: "${storeInfo.openStartTime} - ${storeInfo.openEndTime}"),
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
),
)),
SizedBox(
width: 16.w,
),
Image.asset(
"assets/image/icon_union_location.png",
width: 24.w,
height: 24.h,
),
SizedBox(
width: 16.w,
),
Image.asset(
"assets/image/icon_union_call.png",
width: 24.w,
height: 24.h,
)
],
),
],
),
),
flex: 1,
)
],
),
),
),
),
Container(
margin: EdgeInsets.only(top: 20.h, bottom: 20.h),
child: ItemTitle(
text: S.of(context).youhuiquan,
imgPath: "assets/image/icon_union_coupons.png",
),
),
Container(
height: 109,
child: ListView.builder(
itemCount: 5,
physics: BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemBuilder: (context, position) {
return Container(
width: MediaQuery.of(context).size.width * 0.784,
margin: EdgeInsets.only(left: 6.w),
child: AspectRatio(
aspectRatio: 2.86,
child: Stack(
children: [
Image.asset(
"assets/image/icon_union_coupons_bg.png",
fit: BoxFit.fill,
width: double.infinity,
height: double.infinity,
),
Container(
padding: EdgeInsets.only(
left: 24.w,
right: 24.w,
bottom: 17.h,
top: 11.h,
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Container(
child: Image.network(
"https://t7.baidu.com/it/u=136439029,1848397702&fm=193&f=GIF",
width: 40.w,
height: 40.h,
fit: BoxFit.contain,
),
alignment: Alignment.center,
),
Container(
margin: EdgeInsets.only(
top: 12.h,
bottom: 12.h,
left: 24.w,
right: 24.w),
child: MySeparator(
width: 1.w,
height: 5.h,
color: Color(0xFF979797),
),
),
Expanded(
child: Container(
margin: EdgeInsets.only(
bottom: 12.h, top: 12.h),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"百年川椒",
style: TextStyle(
fontSize: 10.sp,
fontWeight: FontWeight.bold,
color: Color(0xFF727272),
),
),
Text(
S
.of(context)
.manlijiandaijinquan(30, 5),
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Color(0xFFFF7A1A),
),
),
Text(
S
.of(context)
.youxiaoqizhi("2021.01.03"),
style: TextStyle(
fontSize: 8.sp,
color: Color(0xFFA29E9E),
),
),
],
),
)),
Container(
margin: EdgeInsets.only(bottom: 12.h),
height: 25.h,
child: RoundButton(
text: S.of(context).lingqu,
textColor: Colors.white,
backgroup: Color(0xFF32A060),
padding:
EdgeInsets.fromLTRB(8, 4, 8, 4),
fontSize: 12.sp,
),
),
],
),
)
],
),
),
);
}),
),
Container(
margin: EdgeInsets.only(top: 20.h, bottom: 20.h),
child: ItemTitle(
text: S.of(context).xindianhuodong,
imgPath: "assets/image/icon_union_start_store.png",
),
),
Container(
padding: EdgeInsets.only(left: 10.w, right: 10.w),
margin: EdgeInsets.only(bottom: 30.h),
child: AspectRatio(
aspectRatio: 2.0,
child: buildSwiper2Bottom(),
),
)
],
),
),
flex: 1,
),
InkWell(
onTap: _startMin,
child: Container(
padding: EdgeInsets.only(top: 16.h, bottom: 16.h),
decoration: BoxDecoration(
color: Color(0xFFD8D8D8),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(4),
topRight: Radius.circular(4),
),
),
alignment: Alignment.center,
child: Text(
S.of(context).diancan,
style: TextStyle(
fontSize: 16.sp,
color: Color(0xFFA0A0A0),
fontWeight: FontWeight.bold),
),
),
),
],
),
);
}
_startMin() async {
if (!(await Min.isInitialize())) {
await Min.initialize();
}
Min.clickListener();
if (!(await Min.isExistsApp("__UNI__ACD00DA"))) {
await Min.reloadWgt("__UNI__ACD00DA",
"/storage/emulated/0/Android/data/com.zsw.huixiang/files/__UNI__ACD00DA.wgt");
}
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
String token = sharedPreferences.getString("token");
String userId = sharedPreferences.getString("userId");
String nickname = sharedPreferences.getString("nick");
String mobile = sharedPreferences.getString("mobile");
String user = sharedPreferences.getString('user');
UserInfo userInfo = UserInfo.fromJson(jsonDecode(user));
Min.startMin("__UNI__ACD00DA", {
"token": "Bearer $token",
"shopId": widget.arguments["id"],
"tenantCode": storeInfo.tenantCode,
"uid": userId,
"userInfo": {
"nickname": nickname,
"headimg": userInfo.headimg,
"balance": userInfo.balance,
"money": userInfo.money,
"phone": mobile,
"isBind": userInfo.isBind,
},
});
}
Widget buildSwiper2Bottom() {
return Container(
child: Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8.w,
activeSize: 8.w,
space: 5.w,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
),
),
itemBuilder: (context, position) {
return Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
"https://t7.baidu.com/it/u=1492471725,655950677&fm=193&f=GIF",
fit: BoxFit.cover,
),
),
);
},
itemCount: 3,
),
);
}
Widget buildSwiper() {
return Container(
child: Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8.w,
activeSize: 8.w,
space: 5.w,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
),
),
itemBuilder: (context, position) {
return Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w),
child: MImage(
(storeInfo != null &&
storeInfo.bannerList != null &&
position < storeInfo.bannerList.length)
? storeInfo.bannerList[position].imgUrl
: "",
fit: BoxFit.cover,
radius: BorderRadius.circular(4),
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
);
},
itemCount: (storeInfo != null && storeInfo.bannerList != null)
? storeInfo.bannerList.length
: 1),
);
}
}