|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/store_info.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/user_entity.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/classic_header.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:path_provider/path_provider.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.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(),
|
|
|
|
context: context, token: value.getString('token')),
|
|
|
|
queryStoreInfo(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
StoreInfo storeInfo;
|
|
|
|
|
|
|
|
queryStoreInfo() async {
|
|
|
|
BaseData baseData = await apiService
|
|
|
|
.queryStoreInfo(widget.arguments["id"])
|
|
|
|
.catchError((error) {
|
|
|
|
refreshController.refreshFailed();
|
|
|
|
});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
refreshController.refreshCompleted();
|
|
|
|
storeInfo = StoreInfo.fromJson(baseData.data);
|
|
|
|
if (mounted) setState(() {});
|
|
|
|
} else {
|
|
|
|
refreshController.refreshFailed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RefreshController refreshController = RefreshController();
|
|
|
|
|
|
|
|
@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: SmartRefresher(
|
|
|
|
controller: refreshController,
|
|
|
|
enablePullDown: true,
|
|
|
|
enablePullUp: false,
|
|
|
|
header: MyHeader(),
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
onRefresh: queryStoreInfo,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
AspectRatio(
|
|
|
|
aspectRatio: 1,
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
// Navigator.of(context).pushNamed('/router/store_detail_page',
|
|
|
|
// arguments: {"html": storeInfo.});
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
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: itemServer(storeInfo != null
|
|
|
|
? storeInfo.businessService
|
|
|
|
: ""),
|
|
|
|
),
|
|
|
|
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,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
buildVip(),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(top: 10.h, bottom: 10.h),
|
|
|
|
child: ItemTitle(
|
|
|
|
text: S.of(context).youhuiquan,
|
|
|
|
imgPath: "assets/image/icon_union_coupons.png",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
buildCoupon(),
|
|
|
|
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(
|
|
|
|
margin: EdgeInsets.only(bottom: 30.h),
|
|
|
|
child: AspectRatio(
|
|
|
|
aspectRatio: 1.55,
|
|
|
|
child: buildSwiper2Bottom(),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: _loginMin,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(top: 16.h, bottom: 16.h),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: isEnable() ? Color(0xFF32A060) : Color(0xFFD8D8D8),
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(4),
|
|
|
|
topRight: Radius.circular(4),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
isEnable()
|
|
|
|
? S.of(context).diancan
|
|
|
|
: S.of(context).zanbuzhichixianshangdiancan,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.sp,
|
|
|
|
color: isEnable() ? Colors.white : Color(0xFFA0A0A0),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isEnable() {
|
|
|
|
if (storeInfo == null) return false;
|
|
|
|
if (storeInfo.mini == null) return false;
|
|
|
|
String miniAppId = storeInfo.mini.miniAppId;
|
|
|
|
if (miniAppId == null ||
|
|
|
|
miniAppId == "" ||
|
|
|
|
storeInfo.mini.miniVersion == null ||
|
|
|
|
storeInfo.mini.miniVersion == "" ||
|
|
|
|
storeInfo.mini.miniDownloadUrl == null ||
|
|
|
|
storeInfo.mini.miniDownloadUrl == "") {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildVip() {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20.h, horizontal: 16.w),
|
|
|
|
padding: EdgeInsets.all(16),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
image: AssetImage("assets/image/icon_vip_bg.png"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
"assets/image/icon_vip.png",
|
|
|
|
width: 36.w,
|
|
|
|
height: 20.h,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 2.h,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"成为店铺专属会员,享专属权益",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10.sp,
|
|
|
|
color: Color(0xCFFFFFFF),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
RoundButton(
|
|
|
|
text: "点我领取",
|
|
|
|
textColor: Color(0xFF484D66),
|
|
|
|
backgroup: Colors.white,
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 5.h, horizontal: 16.w),
|
|
|
|
radius: 14,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildCoupon() {
|
|
|
|
return Container(
|
|
|
|
height: 109,
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: (storeInfo != null && storeInfo.couponVOList != null)
|
|
|
|
? storeInfo.couponVOList.length
|
|
|
|
: 0,
|
|
|
|
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.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(left: 5),
|
|
|
|
child: Text.rich(TextSpan(children: [
|
|
|
|
TextSpan(
|
|
|
|
text: "¥",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 22.sp,
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
text: "5",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 36.sp,
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
])),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: 12.h,
|
|
|
|
bottom: 12.h,
|
|
|
|
left: 15.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(
|
|
|
|
(storeInfo != null &&
|
|
|
|
storeInfo.couponVOList != null)
|
|
|
|
? storeInfo
|
|
|
|
.couponVOList[position].couponName
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xFF727272),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
(storeInfo != null &&
|
|
|
|
storeInfo.couponVOList != null)
|
|
|
|
? (storeInfo.couponVOList[position]
|
|
|
|
.bizType ==
|
|
|
|
1
|
|
|
|
? S.of(context).manlijiandaijinquan(
|
|
|
|
double.tryParse(storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.fullAmount)
|
|
|
|
.toInt(),
|
|
|
|
double.tryParse(storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.discountAmount)
|
|
|
|
.toInt())
|
|
|
|
: S.of(context).quanchangzhe(storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.discountPercent))
|
|
|
|
: "",
|
|
|
|
// (storeInfo != null && storeInfo.couponVOList != null) ? storeInfo.couponVOList[position].couponImg : "",
|
|
|
|
// S.of(context).manlijiandaijinquan(30, 5),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
S.of(context).youxiaoqizhi(
|
|
|
|
(storeInfo != null &&
|
|
|
|
storeInfo.couponVOList !=
|
|
|
|
null &&
|
|
|
|
storeInfo.couponVOList[position]
|
|
|
|
.useStartTime !=
|
|
|
|
null &&
|
|
|
|
storeInfo.couponVOList[position]
|
|
|
|
.useEndTime !=
|
|
|
|
null)
|
|
|
|
? "${storeInfo.couponVOList[position].useStartTime.replaceAll("-", ".").split(" ")[0]}-${storeInfo.couponVOList[position].useEndTime.replaceAll("-", ".").split(" ")[0]}"
|
|
|
|
: "",
|
|
|
|
),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 8.sp,
|
|
|
|
color: Color(0xFFA29E9E),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Container(
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildSwiper2Bottom() {
|
|
|
|
return Container(
|
|
|
|
child: Swiper(
|
|
|
|
viewportFraction: 0.95,
|
|
|
|
loop: false,
|
|
|
|
itemBuilder: (context, position) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 5.w),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Color(0x0D000000),
|
|
|
|
offset: Offset(0, 3),
|
|
|
|
blurRadius: 14,
|
|
|
|
spreadRadius: 0,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
children: [
|
|
|
|
MImage(
|
|
|
|
(storeInfo != null && storeInfo.promotionList != null)
|
|
|
|
? storeInfo.promotionList[position].image
|
|
|
|
: "",
|
|
|
|
aspectRatio: 2.14375,
|
|
|
|
radius: BorderRadius.only(
|
|
|
|
topRight: Radius.circular(8),
|
|
|
|
topLeft: Radius.circular(8),
|
|
|
|
),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorSrc: "assets/image/default_2_1.png",
|
|
|
|
fadeSrc: "assets/image/default_2_1.png",
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
(storeInfo != null &&
|
|
|
|
storeInfo.promotionList != null)
|
|
|
|
? storeInfo.promotionList[position].name
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xFF000000),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 4.h,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
(storeInfo != null &&
|
|
|
|
storeInfo.promotionList != null)
|
|
|
|
? storeInfo
|
|
|
|
.promotionList[position].description
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xFF727272),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
top: 0,
|
|
|
|
right: 0,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: 4.h,
|
|
|
|
horizontal: 8.w,
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.black.withAlpha(76),
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
bottomLeft: Radius.circular(8),
|
|
|
|
topRight: Radius.circular(8),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
(storeInfo != null && storeInfo.promotionList != null)
|
|
|
|
? storeInfo.promotionList[position].activityStartTime
|
|
|
|
.split(" ")[0]
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Color(0xD9FFFFFF),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: (storeInfo != null && storeInfo.promotionList != null)
|
|
|
|
? storeInfo.promotionList.length
|
|
|
|
: 0,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
printMin() async {
|
|
|
|
String miniAppId = storeInfo.mini.miniAppId;
|
|
|
|
print("print isExistsApp: ${await Min.isExistsApp(miniAppId)}");
|
|
|
|
print("print getAppBasePath: ${await Min.getAppBasePath()}");
|
|
|
|
print("print currentPageUrl: ${await Min.currentPageUrl()}");
|
|
|
|
print("print runingAppid: ${await Min.runingAppid()}");
|
|
|
|
print("print getAppVersionInfo: ${await Min.getAppVersionInfo(miniAppId)}");
|
|
|
|
}
|
|
|
|
|
|
|
|
_loginMin() async {
|
|
|
|
if (storeInfo == null) return;
|
|
|
|
if (!isEnable()) {
|
|
|
|
Fluttertoast.showToast(msg: S.of(context).zanbuzhichixianshangdiancan);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BaseData baseData = await apiService.minLogin(storeInfo.id);
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
UserEntity userEntity = UserEntity.fromJson(baseData.data);
|
|
|
|
startMin(userEntity.token, userEntity.userId);
|
|
|
|
} else {
|
|
|
|
Fluttertoast.showToast(msg: baseData.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
startMin(token, userId) async {
|
|
|
|
if (storeInfo == null) return;
|
|
|
|
if (storeInfo.mini == null) return;
|
|
|
|
if (!(await Min.isInitialize())) {
|
|
|
|
await Min.initialize();
|
|
|
|
}
|
|
|
|
String miniAppId = storeInfo.mini.miniAppId;
|
|
|
|
String filePath = "";
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
filePath = (await getExternalStorageDirectory()).path;
|
|
|
|
} else {
|
|
|
|
filePath = (await getApplicationDocumentsDirectory()).path;
|
|
|
|
}
|
|
|
|
filePath = "$filePath/$miniAppId.wgt";
|
|
|
|
|
|
|
|
if (!(await Min.isExistsApp(miniAppId))) {
|
|
|
|
// await downloadWgt(miniAppId, filePath);
|
|
|
|
await Min.reloadWgt(miniAppId, filePath);
|
|
|
|
} else {
|
|
|
|
String version = await Min.getAppVersionInfo(storeInfo.mini.miniAppId);
|
|
|
|
if (version != storeInfo.mini.miniVersion) {
|
|
|
|
// await downloadWgt(miniAppId, filePath);
|
|
|
|
await Min.reloadWgt(miniAppId, filePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//baseURL : 'http://192.168.10.130:8765/app/', // 本地
|
|
|
|
//baseURL : 'http://192.168.10.236:8766/app/', // 本地
|
|
|
|
// baseURL : 'https://pos-test.api.lotus-wallet.com/app/', //测试
|
|
|
|
// baseURL : 'https://pos.api.lotus-wallet.com/app/', //线上
|
|
|
|
// socketUrl: 'ws://192.168.10.130:9999/cart', // 本地
|
|
|
|
// socketUrl : 'wss://pos-test.api.lotus-wallet.com:10005/cart', //测试
|
|
|
|
// socketUrl : 'wss://pos.api.lotus-wallet.com:10015/cart', //线上
|
|
|
|
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
String nickname = sharedPreferences.getString("nick");
|
|
|
|
String mobile = sharedPreferences.getString("mobile");
|
|
|
|
String user = sharedPreferences.getString('user');
|
|
|
|
String latitude = sharedPreferences.getString("latitude");
|
|
|
|
String longitude = sharedPreferences.getString("longitude");
|
|
|
|
print(user);
|
|
|
|
UserInfo userInfo = UserInfo.fromJson(jsonDecode(user));
|
|
|
|
Min.startMin(miniAppId, {
|
|
|
|
"token": "Bearer $token",
|
|
|
|
"shopId": widget.arguments["id"],
|
|
|
|
"tenantCode": storeInfo.tenantCode,
|
|
|
|
if (latitude != null && longitude != null)
|
|
|
|
"position": "$latitude,$longitude",
|
|
|
|
"baseURL": 'http://192.168.10.236:8766/app/',
|
|
|
|
"uid": userId,
|
|
|
|
"userInfo": {
|
|
|
|
"nickname": nickname,
|
|
|
|
"headimg": userInfo.headimg,
|
|
|
|
"balance": userInfo.balance,
|
|
|
|
"money": userInfo.money,
|
|
|
|
"phone": mobile,
|
|
|
|
"isBind": userInfo.isBind,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//__UNI__ACD00DA
|
|
|
|
Function state;
|
|
|
|
double progressValue = 0;
|
|
|
|
String downText = "正在下载中...";
|
|
|
|
|
|
|
|
downloadWgt(appid, savePath) async {
|
|
|
|
showCupertinoDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: true,
|
|
|
|
builder: (context) {
|
|
|
|
return Material(
|
|
|
|
type: MaterialType.transparency,
|
|
|
|
child: StatefulBuilder(builder: (context, status) {
|
|
|
|
state = status;
|
|
|
|
return Center(
|
|
|
|
child: Container(
|
|
|
|
width: 130,
|
|
|
|
height: 130,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
height: 40.0.h,
|
|
|
|
width: 40.w,
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
value: progressValue,
|
|
|
|
backgroundColor: Colors.yellow,
|
|
|
|
color: Colors.blue,
|
|
|
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
downText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
Response response = await Dio()
|
|
|
|
.download(storeInfo.mini.miniDownloadUrl, savePath,
|
|
|
|
onReceiveProgress: (progress, max) {
|
|
|
|
progressValue = progress.toDouble() / max.toDouble();
|
|
|
|
print("print progressValue: $progressValue");
|
|
|
|
state(() {});
|
|
|
|
});
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
downText = "下载完成";
|
|
|
|
state(() {});
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> itemServer(String businessService) {
|
|
|
|
if (businessService == null || businessService == "") return [];
|
|
|
|
var list = businessService.split(",");
|
|
|
|
return list
|
|
|
|
.map((e) => Container(
|
|
|
|
margin: EdgeInsets.only(right: 8.w),
|
|
|
|
child: RoundButton(
|
|
|
|
height: 14.h,
|
|
|
|
text: "$e",
|
|
|
|
backgroup: Color(0xFFFF7A1A),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 2.w,
|
|
|
|
right: 2.w,
|
|
|
|
),
|
|
|
|
fontSize: 10.sp,
|
|
|
|
textColor: Colors.white,
|
|
|
|
),
|
|
|
|
))
|
|
|
|
.toList();
|
|
|
|
}
|
|
|
|
}
|