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.

1158 lines
47 KiB

4 years ago
import 'dart:convert';
4 years ago
import 'dart:io';
4 years ago
4 years ago
import 'package:dio/dio.dart';
4 years ago
import 'package:flutter/cupertino.dart';
4 years ago
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
4 years ago
import 'package:flutter_swiper/flutter_swiper.dart';
4 years ago
import 'package:huixiang/generated/l10n.dart';
4 years ago
import 'package:huixiang/retrofit/data/activity.dart';
4 years ago
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
4 years ago
import 'package:huixiang/retrofit/data/user_entity.dart';
4 years ago
import 'package:huixiang/retrofit/data/user_info.dart';
4 years ago
import 'package:huixiang/retrofit/retrofit_api.dart';
4 years ago
import 'package:huixiang/utils/min.dart';
4 years ago
import 'package:huixiang/view_widget/classic_header.dart';
4 years ago
import 'package:huixiang/view_widget/custom_image.dart';
4 years ago
import 'package:huixiang/view_widget/item_title.dart';
4 years ago
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/receive_success.dart';
4 years ago
import 'package:huixiang/view_widget/round_button.dart';
import 'package:huixiang/view_widget/separator.dart';
4 years ago
import 'package:path_provider/path_provider.dart';
4 years ago
import 'package:shared_preferences/shared_preferences.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
4 years ago
import 'package:pull_to_refresh/pull_to_refresh.dart';
4 years ago
import 'package:url_launcher/url_launcher.dart';
4 years ago
class UnionDetailsPage extends StatefulWidget {
4 years ago
final Map<String, dynamic> arguments;
UnionDetailsPage({this.arguments});
4 years ago
@override
State<StatefulWidget> createState() {
return _UnionDetailsPage();
}
}
class _UnionDetailsPage extends State<UnionDetailsPage> {
4 years ago
ApiService apiService;
3 years ago
@override
void dispose() {
super.dispose();
refreshController.dispose();
}
4 years ago
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
4 years ago
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
4 years ago
queryStoreInfo(),
});
}
StoreInfo storeInfo;
4 years ago
List<Activity> activitys;
4 years ago
queryStoreInfo() async {
4 years ago
BaseData baseData = await apiService
.queryStoreInfo(widget.arguments["id"])
.catchError((error) {
refreshController.refreshFailed();
});
4 years ago
if (baseData != null && baseData.isSuccess) {
4 years ago
refreshController.refreshCompleted();
4 years ago
storeInfo = StoreInfo.fromJson(baseData.data);
activitys = storeInfo.informationVOPageVO.list
.map((e) => Activity.fromJson(e))
.toList();
4 years ago
if (mounted) setState(() {});
4 years ago
} else {
refreshController.refreshFailed();
}
4 years ago
}
4 years ago
RefreshController refreshController = RefreshController();
4 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
4 years ago
appBar: MyAppBar(
background: Color(0xFFF7F7F7),
title: storeInfo == null ? "" : storeInfo.storeName,
titleColor: Colors.black87,
titleSize: 18.sp,
leadingColor: Colors.black,
4 years ago
),
body: Column(
children: [
Expanded(
4 years ago
child: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
4 years ago
physics: BouncingScrollPhysics(),
4 years ago
onRefresh: queryStoreInfo,
child: SingleChildScrollView(
4 years ago
physics: NeverScrollableScrollPhysics(),
4 years ago
child: Column(
children: [
AspectRatio(
aspectRatio: 1,
child: GestureDetector(
4 years ago
onTap: () {},
4 years ago
child: Container(
margin: EdgeInsets.fromLTRB(16, 20, 16, 8),
padding: EdgeInsets.fromLTRB(10, 20, 10, 14),
decoration: BoxDecoration(
4 years ago
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(8)),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0,
)
],
),
4 years ago
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,
),
4 years ago
),
4 years ago
Expanded(
child: Container(
alignment: Alignment.centerRight,
child: Text(
S.of(context).ren(
storeInfo != null
? storeInfo
.perCapitaConsumption
: "",
),
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF353535),
),
4 years ago
),
4 years ago
),
4 years ago
)
],
),
Text(
storeInfo != null
? storeInfo.address
: "",
maxLines: 2,
4 years ago
textAlign: TextAlign.justify,
4 years ago
style: TextStyle(
4 years ago
color: Color(0xFF353535),
4 years ago
fontSize: 12.sp,
4 years ago
),
4 years ago
),
Row(
4 years ago
children: itemServer(
storeInfo != null
? storeInfo.businessService
: "",
),
4 years ago
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Expanded(
child: Text(
S.of(context).yingyeshijian(storeInfo ==
null
? ""
: (storeInfo.openStartTime ==
null &&
storeInfo.openEndTime ==
null)
4 years ago
? S.of(context).quantian
: "${storeInfo.openStartTime.substring(0, storeInfo.openStartTime.lastIndexOf(":"))} - ${storeInfo.openEndTime.substring(0, storeInfo.openEndTime.lastIndexOf(":"))}"),
4 years ago
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
),
)),
SizedBox(
width: 16.w,
),
3 years ago
InkWell(
onTap: () {
if (storeInfo == null ||
storeInfo.latitude == null ||
storeInfo.longitude == null ||
storeInfo.latitude == "" ||
storeInfo.longitude == "")
return;
Navigator.of(context).pushNamed(
'/router/location_map',
arguments: {
"lat": storeInfo.latitude,
"lng": storeInfo.longitude,
"storeName":
storeInfo.storeName,
});
},
child: Image.asset(
"assets/image/icon_union_location.png",
width: 24.w,
height: 24.h,
),
4 years ago
),
SizedBox(
width: 16.w,
),
4 years ago
InkWell(
onTap: () {
showCallMobile();
},
child: Image.asset(
"assets/image/icon_union_call.png",
width: 24.w,
height: 24.h,
),
4 years ago
)
],
),
],
),
4 years ago
),
4 years ago
flex: 1,
)
],
),
4 years ago
),
),
),
4 years ago
buildVip(),
4 years ago
Container(
4 years ago
margin: EdgeInsets.only(top: 10.h, bottom: 10.h),
4 years ago
child: ItemTitle(
text: S.of(context).youhuiquan,
imgPath: "assets/image/icon_union_coupons.png",
),
4 years ago
),
4 years ago
(storeInfo != null && storeInfo.couponVOList != null)
? buildCoupon()
: Container(
width: double.infinity,
height: 50.h,
alignment: Alignment.center,
child: Text(
S.of(context).zanwuyouhuiquankelingqu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Color(0xFFA0A0A0),
),
),
),
4 years ago
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",
),
4 years ago
),
4 years ago
(activitys != null && activitys.length > 0)
? Container(
margin: EdgeInsets.only(bottom: 30.h),
child: AspectRatio(
aspectRatio: 1.55,
child: buildSwiper2Bottom(),
),
)
: Container(
width: double.infinity,
height: 30.h,
margin: EdgeInsets.only(bottom: 30.h),
alignment: Alignment.center,
child: Text(
S.of(context).muqianzanwuxingdianhuodong,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Color(0xFFA0A0A0),
),
),
),
4 years ago
],
),
4 years ago
),
),
flex: 1,
),
InkWell(
4 years ago
onTap: _loginMin,
4 years ago
child: Container(
4 years ago
padding: EdgeInsets.only(top: 16.h, bottom: 16.h),
4 years ago
decoration: BoxDecoration(
4 years ago
color: isEnable() ? Color(0xFF32A060) : Color(0xFFD8D8D8),
4 years ago
borderRadius: BorderRadius.only(
topLeft: Radius.circular(4),
topRight: Radius.circular(4),
),
),
4 years ago
alignment: Alignment.center,
child: Text(
4 years ago
isEnable()
3 years ago
? S.of(context).jinrushangdian
: S.of(context).zanwuxianshangjindian,
4 years ago
style: TextStyle(
4 years ago
fontSize: 16.sp,
4 years ago
color: isEnable() ? Colors.white : Color(0xFFA0A0A0),
4 years ago
fontWeight: FontWeight.bold,
),
4 years ago
),
),
),
],
),
);
}
4 years ago
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;
}
}
4 years ago
Widget buildVip() {
return Container(
4 years ago
margin: EdgeInsets.symmetric(
vertical: (storeInfo != null && storeInfo.isVip) ? 12.h : 20.h,
horizontal: 16.w),
4 years ago
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage("assets/image/icon_vip_bg.png"),
),
),
4 years ago
child: (storeInfo != null && storeInfo.isVip)
? Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
4 years ago
children: [
4 years ago
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Text(
S.of(context).huiyuanyue,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
SizedBox(
width: 8.w,
),
Text(
"¥${(storeInfo != null && storeInfo.memberSource != null) ? storeInfo.memberSource.balance : ""}",
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
Container(
color: Colors.white,
width: 1.w,
height: 20.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Text(
S.of(context).huiyuanjifen,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
SizedBox(
width: 8.w,
),
Text(
(storeInfo != null && storeInfo.memberSource != null)
? "${storeInfo.memberSource.integral}"
: "",
4 years ago
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
],
4 years ago
),
SizedBox(
height: 10.h,
),
4 years ago
Text(
4 years ago
S.of(context).gongxinichengweibendianhuiyuan,
4 years ago
style: TextStyle(
fontSize: 10.sp,
fontWeight: FontWeight.bold,
4 years ago
color: Color(0xFFEDC98E),
4 years ago
),
)
],
4 years ago
)
: 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(
S.of(context).chengweidianpuzhuanshuhuiyuan,
style: TextStyle(
fontSize: 10.sp,
color: Color(0xCFFFFFFF),
fontWeight: FontWeight.bold,
),
),
],
),
flex: 1,
),
InkWell(
onTap: () {
receiveVip();
},
child: RoundButton(
text: isReceive
? S.of(context).dianwolingqu
: S.of(context).yilingqu,
4 years ago
textColor: isReceive ? Colors.white : Color(0xFF484D66),
backgroup: isReceive ? Color(0xFF242B45) : Colors.white,
padding:
EdgeInsets.symmetric(vertical: 5.h, horizontal: 16.w),
radius: 14,
),
),
],
4 years ago
),
);
}
4 years ago
bool isReceive = true;
4 years ago
4 years ago
Widget buildCoupon() {
return Container(
4 years ago
height: 109.h,
4 years ago
child: ListView.builder(
itemCount: (storeInfo != null && storeInfo.couponVOList != null)
? storeInfo.couponVOList.length
: 0,
physics: BouncingScrollPhysics(parent: PageScrollPhysics()),
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,
4 years ago
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(left: 5),
child: Text.rich(TextSpan(children: [
TextSpan(
text: (storeInfo != null &&
storeInfo.couponVOList != null &&
storeInfo
.couponVOList[position].bizType ==
1)
? "¥"
: "",
style: TextStyle(
fontSize: 22.sp,
color: Color(0xFFFF7A1A),
fontWeight: FontWeight.bold,
4 years ago
),
),
TextSpan(
text: (storeInfo != null &&
storeInfo.couponVOList != null &&
storeInfo
.couponVOList[position].bizType ==
1)
? "${double.tryParse(storeInfo.couponVOList[position].discountAmount).toInt()}"
4 years ago
: (storeInfo != null &&
4 years ago
storeInfo.couponVOList != null &&
storeInfo.couponVOList[position]
.bizType ==
5)
? S.of(context).duihuanquan
: "${storeInfo.couponVOList[position].discountPercent / 10}",
style: TextStyle(
fontSize: 36.sp,
color: Color(0xFFFF7A1A),
fontWeight: FontWeight.bold,
4 years ago
),
),
])),
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),
4 years ago
),
),
Expanded(
child: Container(
4 years ago
margin: EdgeInsets.only(
bottom: 12.h,
top: 12.h,
4 years ago
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
(storeInfo != null &&
storeInfo.couponVOList != null)
? storeInfo
.couponVOList[position].couponName
: "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 10.sp,
fontWeight: FontWeight.bold,
color: Color(0xFF727272),
4 years ago
),
),
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),
4 years ago
),
),
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]}"
: "",
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 8.sp,
color: Color(0xFFA29E9E),
4 years ago
),
),
],
4 years ago
),
4 years ago
),
),
InkWell(
onTap: () {
if (storeInfo != null &&
storeInfo.couponVOList != null &&
storeInfo.couponVOList[position].status == 0) {
receiveCoupon(
storeInfo.couponVOList[position].id);
}
},
child: Container(
height: 25.h,
child: RoundButton(
text: (storeInfo != null &&
storeInfo.couponVOList != null &&
storeInfo.couponVOList[position].status >
0)
? S.of(context).yilingqu
: S.of(context).lingqu,
textColor: Colors.white,
backgroup: (storeInfo != null &&
storeInfo.couponVOList != null &&
storeInfo.couponVOList[position].status >
0)
? Colors.grey
: Color(0xFF32A060),
padding: EdgeInsets.fromLTRB(8, 4, 8, 4),
fontSize: 12.sp,
4 years ago
),
),
),
],
),
)
],
4 years ago
),
),
);
},
),
4 years ago
);
4 years ago
}
4 years ago
///领取优惠券
receiveCoupon(couponId) async {
BaseData baseData = await apiService.receiveCoupon(couponId);
if (baseData != null && baseData.isSuccess) {
4 years ago
queryStoreInfo();
showAlertDialog();
}
}
/// 领取成功弹窗
showAlertDialog() {
//显示对话框
showDialog(
context: context,
builder: (BuildContext context) {
return ReceiveSuccess();
},
);
}
///领取VIP
4 years ago
receiveVip() async {
BaseData baseData = await apiService.minLogin(storeInfo.id);
if (baseData != null && baseData.isSuccess) {
4 years ago
SmartDialog.showToast(S.of(context).lingquchenggong,
alignment: Alignment.center);
4 years ago
setState(() {
4 years ago
isReceive = false;
4 years ago
});
}
}
4 years ago
Widget buildSwiper2Bottom() {
return Container(
child: Swiper(
4 years ago
viewportFraction: 0.95,
loop: false,
4 years ago
itemBuilder: (context, position) {
4 years ago
return InkWell(
onTap: () {
3 years ago
if (widget.arguments["source"] != null &&
widget.arguments["source"] == activitys[position].id) {
3 years ago
Navigator.of(context).pop();
} else {
Navigator.of(context).pushNamed('/router/store_detail_page',
3 years ago
arguments: {
"activityId": activitys[position].id,
"source": widget.arguments["id"]
});
3 years ago
}
4 years ago
},
child: 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(
(activitys != null && activitys.length > position)
4 years ago
? activitys[position].coverImg
: "",
aspectRatio: 2.2,
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",
4 years ago
),
4 years ago
Container(
padding: EdgeInsets.all(8),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
4 years ago
(activitys != null &&
activitys.length > position)
4 years ago
? activitys[position].storeName
: "",
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Color(0xFF000000),
),
4 years ago
),
4 years ago
SizedBox(
height: 4.h,
4 years ago
),
4 years ago
Text(
4 years ago
(activitys != null &&
activitys.length > position)
4 years ago
? activitys[position].mainTitle
: "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.bold,
color: Color(0xFF727272),
),
),
],
),
4 years ago
),
4 years ago
],
4 years ago
),
4 years ago
),
Positioned(
top: 0,
right: 0,
child: Container(
padding: EdgeInsets.symmetric(
vertical: 4.h,
horizontal: 8.w,
4 years ago
),
4 years ago
decoration: BoxDecoration(
color: Colors.black.withAlpha(76),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: Text(
(activitys != null && activitys.length > position)
? activitys[position].startTime.split(" ")[0]
4 years ago
: "",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12.sp,
color: Color(0xD9FFFFFF),
),
4 years ago
),
),
),
4 years ago
],
),
4 years ago
),
);
},
4 years ago
itemCount:
(activitys != null && activitys.length > 0) ? activitys.length : 0,
4 years ago
),
4 years ago
);
}
Widget buildSwiper() {
return Container(
child: Swiper(
pagination: SwiperPagination(
4 years ago
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8.w,
activeSize: 8.w,
space: 5.w,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
),
),
4 years ago
itemBuilder: (context, position) {
return Container(
4 years ago
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",
4 years ago
),
);
},
4 years ago
itemCount: (storeInfo != null && storeInfo.bannerList != null)
? storeInfo.bannerList.length
: 1),
4 years ago
);
}
4 years ago
4 years ago
//{"uid":"1412687522458238976",
// "userInfo":{"headimg":"https:\/\/pos.upload.gznl.top\/admin\/2021\/07\/4ed055e5-5341-4080-a6f0-fe97c62d078f.jpg",
// "balance":null,
// "money":"0.00",
// "phone":"13800138000",
// "isBind":true,
// "nickname":"你这橘子洋气呀"
// },
// "baseURL":"https:\/\/pos-test.api.lotus-wallet.com\/app\/",
// "shopId":"1344490596986781696",
// "tenantCode":"1177",
// "position":"30.554638,114.34394500000002",
// "token":"Bearer eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX3R5cGUiOiJNSU5JIiwibmFtZSI6IiIsInRva2VuX3R5cGUiOiJ0b2tlbiIsInVzZXJpZCI6IjE0MTI2ODc1MjI0NTgyMzg5NzYiLCJhY2NvdW50IjoiIiwiZXhwIjoxNjI2Nzk1Nzc0LCJuYmYiOjE2MjY3NjY5NzR9.cggcx_vqTozKS-z9uygjV4uA2yHQ4eWssMAngd2c-i0"}
4 years ago
printMin() async {
4 years ago
String miniAppId = storeInfo.mini.miniAppId;
print("print isExistsApp: ${await Min.isExistsApp(miniAppId)}");
4 years ago
print("print getAppBasePath: ${await Min.getAppBasePath(miniAppId)}");
4 years ago
print("print currentPageUrl: ${await Min.currentPageUrl()}");
print("print runingAppid: ${await Min.runingAppid()}");
// print("print getAppVersionInfo: ${await Min.getAppVersionInfo(miniAppId)}");
4 years ago
}
_loginMin() async {
if (storeInfo == null) return;
4 years ago
if (!isEnable()) {
4 years ago
SmartDialog.showToast(S.of(context).zanbuzhichixianshangdiancan,
alignment: Alignment.center);
4 years ago
return;
}
4 years ago
BaseData baseData = await apiService.minLogin(storeInfo.id);
4 years ago
if (baseData != null && baseData.isSuccess) {
4 years ago
UserEntity userEntity = UserEntity.fromJson(baseData.data);
startMin(userEntity.token, userEntity.userId);
}
}
startMin(token, userId) async {
4 years ago
if (storeInfo == null) return;
4 years ago
if (storeInfo.mini == null) return;
4 years ago
if (!(await Min.isInitialize())) {
await Min.initialize();
}
4 years ago
printMin();
4 years ago
String miniAppId = storeInfo.mini.miniAppId;
4 years ago
String filePath = "";
4 years ago
if (Platform.isAndroid) {
4 years ago
filePath = (await getExternalStorageDirectory()).path;
} else {
filePath = (await getApplicationDocumentsDirectory()).path;
}
4 years ago
filePath = "$filePath/$miniAppId.wgt";
4 years ago
4 years ago
if (!(await Min.isExistsApp(miniAppId))) {
await downloadWgt(miniAppId, filePath);
4 years ago
await Min.reloadWgt(miniAppId, filePath);
4 years ago
} else {
String version = await Min.getAppVersionInfo(storeInfo.mini.miniAppId);
4 years ago
if (version != storeInfo.mini.miniVersion) {
await downloadWgt(miniAppId, filePath);
4 years ago
await Min.reloadWgt(miniAppId, filePath);
4 years ago
}
4 years ago
}
4 years ago
//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', //线上
4 years ago
4 years ago
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
String nickname = sharedPreferences.getString("nick");
String mobile = sharedPreferences.getString("mobile");
String user = sharedPreferences.getString('user');
4 years ago
String latitude = sharedPreferences.getString("latitude");
String longitude = sharedPreferences.getString("longitude");
4 years ago
print(user);
4 years ago
UserInfo userInfo = UserInfo.fromJson(jsonDecode(user));
4 years ago
Min.startMin(miniAppId, {
4 years ago
"token": "Bearer $token",
"shopId": widget.arguments["id"],
"tenantCode": storeInfo.tenantCode,
4 years ago
if (latitude != null && longitude != null)
"position": "$latitude,$longitude",
4 years ago
"baseURL": "https://pos.api.lotus-wallet.com/app/",
4 years ago
"uid": userId,
"userInfo": {
"nickname": nickname,
"headimg": userInfo.headimg,
"balance": userInfo.balance,
"money": userInfo.money,
"phone": mobile,
"isBind": userInfo.isBind,
},
});
}
4 years ago
4 years ago
Function state;
double progressValue = 0;
String downText = "正在下载中...";
downloadWgt(appid, savePath) async {
4 years ago
downText = S.of(context).zhengzaixiazaizhong;
4 years ago
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.w,
height: 130.h,
4 years ago
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 40.h,
4 years ago
width: 40.w,
4 years ago
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,
),
4 years ago
),
4 years ago
],
),
),
);
}),
);
});
4 years ago
Response response = await Dio()
.download(storeInfo.mini.miniDownloadUrl, savePath,
onReceiveProgress: (progress, max) {
4 years ago
progressValue = progress.toDouble() / max.toDouble();
4 years ago
// print("print progressValue: $progressValue");
4 years ago
state(() {});
});
if (response.statusCode == 200) {
downText = "下载完成";
4 years ago
SharedPreferences.getInstance().then((value) {
4 years ago
value.setStringList(
"miniAppid",
(value.getStringList("miniAppid") != null
? value.getStringList("miniAppid")
: [])
..add(appid));
4 years ago
});
4 years ago
state(() {});
Future.delayed(Duration(seconds: 1), () {
if (Navigator.canPop(context)) {
Navigator.of(context).pop();
}
});
4 years ago
} else {
print("print 下载失败");
4 years ago
}
}
4 years ago
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();
}
4 years ago
showCallMobile() {
showCupertinoModalPopup(
context: context,
builder: (contetx) {
return CupertinoActionSheet(
title: Text(S.of(context).bodadianhua),
actions: [
4 years ago
if (storeInfo != null &&
storeInfo.headMobile != null &&
storeInfo.headMobile != "")
4 years ago
CupertinoActionSheetAction(
4 years ago
child: Text(storeInfo.headMobile),
4 years ago
onPressed: () {
4 years ago
callMobile(storeInfo.headMobile);
4 years ago
Navigator.of(context).pop();
},
isDefaultAction: true,
isDestructiveAction: false,
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(S.of(context).quxiao),
isDestructiveAction: true,
),
);
});
}
callMobile(mobile) async {
String url = "tel:$mobile";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
4 years ago
}