|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
|
import 'package:flutter_swiper/flutter_swiper.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/home/home_view/discount_zone.dart';
|
|
|
|
import 'package:huixiang/home/home_view/home_recommend_goods.dart';
|
|
|
|
import 'package:huixiang/home/home_view/top_selling_list.dart';
|
|
|
|
import 'package:huixiang/home/home_view/union_entry.dart';
|
|
|
|
import 'package:huixiang/home/home_view/welfare_core.dart';
|
|
|
|
import 'package:huixiang/home/points_mall_view/points_goods_title.dart';
|
|
|
|
import 'package:huixiang/home/points_mall_view/points_goods_view.dart';
|
|
|
|
import 'package:huixiang/main.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/activity_pos.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/article.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/banner.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/brand.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/coupon.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/founder.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/goods.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/goods_category.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/home_rank.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/login_info.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/page.dart';
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart';
|
|
|
|
import 'package:huixiang/utils/event_type.dart';
|
|
|
|
import 'package:huixiang/view_widget/activity_coupons.dart';
|
|
|
|
import 'package:huixiang/view_widget/activity_poster.dart';
|
|
|
|
import 'package:huixiang/view_widget/classic_header.dart';
|
|
|
|
import 'package:huixiang/view_widget/invite_success_dialog.dart';
|
|
|
|
import 'package:huixiang/view_widget/request_permission.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
import '../retrofit/data/user_info.dart';
|
|
|
|
import '../utils/flutter_utils.dart';
|
|
|
|
import '../view_widget/channel_dialog.dart';
|
|
|
|
import '../view_widget/custom_image.dart';
|
|
|
|
import 'home_view/happy_help_farmers.dart';
|
|
|
|
import 'home_view/shortcut_operation.dart';
|
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
final Function changeTab;
|
|
|
|
final String invite;
|
|
|
|
final List<InterviewCouponList> interviewCouponList;
|
|
|
|
final List<FirstLoginCouponList> firstLoginCouponList;
|
|
|
|
|
|
|
|
HomePage(Key key, this.changeTab,
|
|
|
|
{this.invite, this.interviewCouponList, this.firstLoginCouponList})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return HomePageState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
|
|
|
|
ApiService apiService;
|
|
|
|
final RefreshController refreshController = RefreshController();
|
|
|
|
String categoryId;
|
|
|
|
bool showInvite = false;
|
|
|
|
bool showNew = false;
|
|
|
|
|
|
|
|
//排序类型枚举:1-自然排序,2-销量,3-价格
|
|
|
|
int orderType = 1;
|
|
|
|
|
|
|
|
//是否降序排列
|
|
|
|
bool orderDesc = true;
|
|
|
|
List<Goods> goods = [];
|
|
|
|
List<GoodsCategory> gooodsCategorys = [];
|
|
|
|
List<BannerData> bannerData = [];
|
|
|
|
List<BannerData> activityBannerData = [];
|
|
|
|
List<Brand> brandData = [];
|
|
|
|
List<Article> articles = [];
|
|
|
|
Founder founder;
|
|
|
|
bool isSigned = false;
|
|
|
|
int totalMsg = 0;
|
|
|
|
List<Coupon> coupons = [];
|
|
|
|
int state = 1;
|
|
|
|
HomeRank homeRank;
|
|
|
|
UserInfo userInfo;
|
|
|
|
dynamic mRaiseMoney = 0; //众筹金余额
|
|
|
|
int _loadCount = 0;
|
|
|
|
DioErrorType dioErrorType;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
eventBus.on<EventType>().listen((event) {
|
|
|
|
if (event.type < 3) {
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_onRefresh(isFirstIn: true);
|
|
|
|
if (showInvite) {
|
|
|
|
inviteShowAlertDialog(widget.invite, widget.interviewCouponList[0]);
|
|
|
|
showInvite = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((widget.invite ?? "") != "" ||
|
|
|
|
widget.interviewCouponList != null &&
|
|
|
|
widget.interviewCouponList.length > 0) showInvite = true;
|
|
|
|
|
|
|
|
//判断新人弹窗
|
|
|
|
// if (widget.firstLoginCouponList != null && widget.firstLoginCouponList.length > 0)
|
|
|
|
// showNew = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
///邀请成功
|
|
|
|
inviteShowAlertDialog(invite, InterviewCouponList interviewCouponList) {
|
|
|
|
//显示对话框
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return InviteSuccessDialog(invite, interviewCouponList);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///活动海报弹窗
|
|
|
|
posterShowAlertDialog(ActivityPos activityPos, firstLoginCouponList) {
|
|
|
|
var today = DateTime.now().day;
|
|
|
|
SharedPreferences.getInstance().then((value) {
|
|
|
|
if (value.getInt("today") == today &&
|
|
|
|
(value.getString("ActivityPosCode") ?? "")
|
|
|
|
.contains("${activityPos.code}_${value.getString("userId")};"))
|
|
|
|
return;
|
|
|
|
value.setString("ActivityPosCode",
|
|
|
|
"${(value.getString("ActivityPosCode") ?? "")}${activityPos.code}_${value.getString("userId")};");
|
|
|
|
value.setInt("today", today);
|
|
|
|
//显示对话框
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return ActivityPoster(activityPos, firstLoginCouponList);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///推荐渠道弹窗
|
|
|
|
channelShowAlertDialog() {
|
|
|
|
//显示对话框
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return ChannelDialog();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///头部banner
|
|
|
|
queryBanner() async {
|
|
|
|
try {
|
|
|
|
BaseData<PageInfo<BannerData>> baseData = await apiService.queryBanner({
|
|
|
|
"model": {"type": "HOME_PAGE"},
|
|
|
|
}).catchError((onError) {
|
|
|
|
dioErrorType = onError.type;
|
|
|
|
});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
bannerData = baseData.data.records;
|
|
|
|
// if (bannerData.length > 0) swiperController.move(0, animation: false);
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
addLoadCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///宣传banner
|
|
|
|
queryActivityBanner() async {
|
|
|
|
try {
|
|
|
|
BaseData<PageInfo<BannerData>> baseData = await apiService.queryBanner({
|
|
|
|
"model": {"type": "HOME_STORE_PAGE"},
|
|
|
|
}).catchError((onError) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
activityBannerData = baseData.data.records;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
addLoadCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addLoadCount() {
|
|
|
|
_loadCount += 1;
|
|
|
|
if (_loadCount == 7) {
|
|
|
|
_loadCount = 0;
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
if (dioErrorType == null)
|
|
|
|
refreshController.refreshCompleted();
|
|
|
|
else {
|
|
|
|
SmartDialog.showToast(AppUtils.dioErrorTypeToString(dioErrorType),
|
|
|
|
alignment: Alignment.center);
|
|
|
|
refreshController.refreshFailed();
|
|
|
|
}
|
|
|
|
if (mounted) setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///推荐排行
|
|
|
|
queryRecommendRank() async {
|
|
|
|
try {
|
|
|
|
BaseData<HomeRank> rank =
|
|
|
|
await apiService.recommendRank().catchError((onError) {});
|
|
|
|
if (rank != null && rank.isSuccess) {
|
|
|
|
homeRank = rank.data;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
addLoadCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///积分商城商品分類列表
|
|
|
|
queryGoodsCategory() async {
|
|
|
|
try {
|
|
|
|
BaseData<PageInfo<GoodsCategory>> dataCategory =
|
|
|
|
await apiService.goodsCategory({
|
|
|
|
"current": 1,
|
|
|
|
"map": {},
|
|
|
|
"model": {"pageNum": 1, "pageSize": 20, "searchKey": ""},
|
|
|
|
"order": "descending",
|
|
|
|
"size": 20,
|
|
|
|
"sort": "sortOrder"
|
|
|
|
}).catchError((onError) {});
|
|
|
|
if (dataCategory != null &&
|
|
|
|
dataCategory.isSuccess &&
|
|
|
|
dataCategory.data != null &&
|
|
|
|
dataCategory.data.records != null &&
|
|
|
|
dataCategory.data.records.length > 0) {
|
|
|
|
gooodsCategorys.clear();
|
|
|
|
gooodsCategorys.add(GoodsCategory(name: S.of(context).quanbu));
|
|
|
|
gooodsCategorys.addAll(dataCategory.data.records);
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
addLoadCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///积分商城商品列表
|
|
|
|
queryPointsProductList(bool isRefresh) async {
|
|
|
|
try {
|
|
|
|
if (!isRefresh)
|
|
|
|
EasyLoading.show(
|
|
|
|
status: S.current.zhengzaijiazai,
|
|
|
|
maskType: EasyLoadingMaskType.black);
|
|
|
|
var param = {
|
|
|
|
"categoryId": categoryId ?? "",
|
|
|
|
"orderDesc": orderDesc,
|
|
|
|
"orderType": orderType,
|
|
|
|
"pageNum": 1,
|
|
|
|
"pageSize": 100,
|
|
|
|
"state": 1
|
|
|
|
};
|
|
|
|
BaseData<PageInfo<Goods>> pageGoods =
|
|
|
|
await apiService.creditGoods(param).catchError((onError) {});
|
|
|
|
if (pageGoods != null && pageGoods.isSuccess) {
|
|
|
|
goods = pageGoods.data.list;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (isRefresh)
|
|
|
|
addLoadCount();
|
|
|
|
else {
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///查询会员信息
|
|
|
|
queryUserBalance() async {
|
|
|
|
try {
|
|
|
|
BaseData<UserInfo> baseData =
|
|
|
|
await apiService.queryInfo().catchError((onError) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
userInfo = baseData.data;
|
|
|
|
mRaiseMoney = double.tryParse(userInfo.raiseMoney);
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
addLoadCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///消息数量
|
|
|
|
// queryMsgStats() async {
|
|
|
|
// if (apiService == null) {
|
|
|
|
// SharedPreferences value = await SharedPreferences.getInstance();
|
|
|
|
// apiService = ApiService(
|
|
|
|
// Dio(),
|
|
|
|
// context: context,
|
|
|
|
// token: value.getString("token"),
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// BaseData<List<MsgStats>> baseData = await apiService.stats().catchError((onError) {});
|
|
|
|
// if (baseData != null && baseData.isSuccess) {
|
|
|
|
// // setState(() {
|
|
|
|
// totalMsg = 0;
|
|
|
|
// baseData.data.forEach((element) {
|
|
|
|
// totalMsg += element.number;
|
|
|
|
// // });
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// EasyLoading.dismiss();
|
|
|
|
// }
|
|
|
|
|
|
|
|
///活动弹窗
|
|
|
|
queryActivity() async {
|
|
|
|
BaseData<ActivityPos> baseData =
|
|
|
|
await apiService.appPopup().catchError((onError) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
if (baseData.data?.enabled ?? true)
|
|
|
|
posterShowAlertDialog(baseData.data, widget.firstLoginCouponList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///核销用户优惠券
|
|
|
|
queryWiped(memberCouponId) async {
|
|
|
|
BaseData baseData =
|
|
|
|
await apiService.wiped(memberCouponId).catchError((onError) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
SmartDialog.showToast("核销成功", alignment: Alignment.center);
|
|
|
|
} else {
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
queryCoupon() async {
|
|
|
|
try {
|
|
|
|
BaseData<PageInfo<Coupon>> baseData = await apiService.queryCoupon({
|
|
|
|
"centre": true,
|
|
|
|
"pageNum": 1,
|
|
|
|
"pageSize": 10,
|
|
|
|
"searchKey": "",
|
|
|
|
"state": 0
|
|
|
|
}).catchError((onError) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
coupons = baseData.data.list;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
addLoadCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_onRefresh({bool isFirstIn = false}) async {
|
|
|
|
EasyLoading.show(
|
|
|
|
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black);
|
|
|
|
if (apiService == null) {
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance();
|
|
|
|
apiService = ApiService(
|
|
|
|
Dio(),
|
|
|
|
context: context,
|
|
|
|
token: value.getString("token"),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
dioErrorType = null;
|
|
|
|
if (isFirstIn) queryActivity();
|
|
|
|
queryBanner();
|
|
|
|
queryActivityBanner();
|
|
|
|
queryRecommendRank();
|
|
|
|
queryGoodsCategory();
|
|
|
|
queryPointsProductList(true);
|
|
|
|
queryUserBalance();
|
|
|
|
// queryMsgStats();
|
|
|
|
queryCoupon();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
if (refreshController != null) refreshController.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
super.build(context);
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
// MyAppBar(
|
|
|
|
// title: "首页",
|
|
|
|
// leading: false,
|
|
|
|
// actions: [
|
|
|
|
// Container(
|
|
|
|
// height: 24,
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
// margin: EdgeInsets.only(
|
|
|
|
// right: 12.w,
|
|
|
|
// ),
|
|
|
|
// child: GestureDetector(
|
|
|
|
// onTap: () {
|
|
|
|
// Navigator.of(context).pushNamed('/router/system_msg_page').then((value) {
|
|
|
|
// setState(() {
|
|
|
|
// totalMsg = 0;
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// // Navigator.of(context).pushNamed('/router/web_turntable_activity');
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// height: 24,
|
|
|
|
// alignment:Alignment.center,
|
|
|
|
// child:Stack(
|
|
|
|
// children: [
|
|
|
|
// SvgPicture.asset(
|
|
|
|
// "assets/svg/tixing.svg",
|
|
|
|
// width: 24,
|
|
|
|
// height: 24,
|
|
|
|
// ),
|
|
|
|
// if(totalMsg != 0)
|
|
|
|
// Container(
|
|
|
|
// width:36,
|
|
|
|
// alignment: Alignment.topRight,
|
|
|
|
// child:Container(
|
|
|
|
// width:22,
|
|
|
|
// height:14,
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// borderRadius: BorderRadius.circular(100),
|
|
|
|
// border: Border.all(
|
|
|
|
// width: 1,
|
|
|
|
// color: Colors.white,
|
|
|
|
// style: BorderStyle.solid,
|
|
|
|
// ),
|
|
|
|
// color:Color(0xFFFF441A),
|
|
|
|
// ),
|
|
|
|
// child:RoundButton(
|
|
|
|
// text:totalMsg.toString(),
|
|
|
|
// textColor: Colors.white,
|
|
|
|
// fontWeight: MyFontWeight.regular,
|
|
|
|
// backgroup: Color(0xFFFF441A),
|
|
|
|
// fontSize:8.sp,
|
|
|
|
// radius: 100,
|
|
|
|
// )
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// )
|
|
|
|
// ),
|
|
|
|
// Container(
|
|
|
|
// margin: EdgeInsets.only(right: 16.w),
|
|
|
|
// child: GestureDetector(
|
|
|
|
// onTap: () {
|
|
|
|
// toScan();
|
|
|
|
// },
|
|
|
|
// child: SvgPicture.asset(
|
|
|
|
// "assets/svg/saoyisao.svg",
|
|
|
|
// width: 24,
|
|
|
|
// height: 24,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
child: SmartRefresher(
|
|
|
|
controller: refreshController,
|
|
|
|
enablePullDown: true,
|
|
|
|
enablePullUp: false,
|
|
|
|
header: MyHeader(),
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
onRefresh: _onRefresh,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
///banner
|
|
|
|
homeBanner(),
|
|
|
|
|
|
|
|
///吃喝玩
|
|
|
|
UnionEntry((int jpIndex) {
|
|
|
|
widget.changeTab(1, jpIndex);
|
|
|
|
}),
|
|
|
|
|
|
|
|
///快捷操作
|
|
|
|
ShortcutOperation((int jpIndex) {
|
|
|
|
widget.changeTab(1, jpIndex);
|
|
|
|
}),
|
|
|
|
|
|
|
|
///推广图
|
|
|
|
if(activityBannerData.length > 0)
|
|
|
|
spread(),
|
|
|
|
|
|
|
|
// ///签到
|
|
|
|
// SignView(isSigned, (value) {
|
|
|
|
// setState(() {
|
|
|
|
// isSigned = value;
|
|
|
|
// });
|
|
|
|
// }),
|
|
|
|
|
|
|
|
///特惠专区
|
|
|
|
if (coupons != null && coupons.length != 0)
|
|
|
|
DiscountZone(coupons),
|
|
|
|
|
|
|
|
///特惠专区-推荐商品展示
|
|
|
|
if (homeRank != null &&
|
|
|
|
homeRank.commodityZone.length != 0)
|
|
|
|
HomeRecommendGoods(homeRank),
|
|
|
|
|
|
|
|
if((homeRank?.commodityZone?.length ??0) == 0)
|
|
|
|
SizedBox(height: 20.h,),
|
|
|
|
|
|
|
|
///助农专区
|
|
|
|
// if(mRaiseMoney != 0)
|
|
|
|
HappyHelpFarmers(),
|
|
|
|
|
|
|
|
///福利中心
|
|
|
|
WelfareCore(),
|
|
|
|
|
|
|
|
///吃喝玩商品热销榜
|
|
|
|
if (homeRank != null &&
|
|
|
|
homeRank.commodityList.length != 0)
|
|
|
|
TopSellingList(homeRank),
|
|
|
|
|
|
|
|
// ///店铺推荐
|
|
|
|
// QuickOrder(),
|
|
|
|
|
|
|
|
// ///超级优惠券
|
|
|
|
// CouponView(),
|
|
|
|
|
|
|
|
// ///精选活动
|
|
|
|
// FeaturedActivity(),
|
|
|
|
|
|
|
|
// ///积分商城
|
|
|
|
// HomeIntegralStore(gooods),
|
|
|
|
|
|
|
|
///积分商品头Tab
|
|
|
|
PointsGoodsTitle(
|
|
|
|
gooodsCategorys,
|
|
|
|
(orderType, orderDesc) {
|
|
|
|
this.orderType = orderType;
|
|
|
|
this.orderDesc = orderDesc;
|
|
|
|
queryPointsProductList(false);
|
|
|
|
},
|
|
|
|
(index) {
|
|
|
|
categoryId = gooodsCategorys[index].id;
|
|
|
|
queryPointsProductList(false);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
///积分商品列表
|
|
|
|
PointGoods(
|
|
|
|
goods,
|
|
|
|
(index) {
|
|
|
|
_toDetails(index);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 80.h,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget homeBanner() {
|
|
|
|
return Container(
|
|
|
|
child: AspectRatio(
|
|
|
|
aspectRatio: 1.25,
|
|
|
|
child: bannerData != null && bannerData.isNotEmpty
|
|
|
|
? Swiper(
|
|
|
|
pagination: SwiperPagination(
|
|
|
|
margin: EdgeInsets.only(bottom: 12.h),
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
builder: DotSwiperPaginationBuilder(
|
|
|
|
size: 8,
|
|
|
|
activeSize: 8,
|
|
|
|
space: 5,
|
|
|
|
activeColor: Colors.white,
|
|
|
|
color: Colors.white.withAlpha(76),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
autoplay: true,
|
|
|
|
duration: 1000,
|
|
|
|
autoplayDelay: 2000,
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
itemBuilder: (context, position) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
bannerClick(bannerData[position]);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
child: MImage(
|
|
|
|
bannerData[position].imgUrl,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorSrc: "assets/image/default_2_1.webp",
|
|
|
|
fadeSrc: "assets/image/default_2_1.webp",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: bannerData.length,
|
|
|
|
)
|
|
|
|
: Image.asset(
|
|
|
|
"assets/image/default_2_1.webp",
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程,7:门店跳转)
|
|
|
|
bannerClick(BannerData bannerData) async {
|
|
|
|
switch (bannerData.contentType) {
|
|
|
|
case 1:
|
|
|
|
Navigator.of(context).pushNamed('/router/integral_store_page',
|
|
|
|
arguments: {"goodsId": bannerData.content});
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Navigator.of(context).pushNamed('/router/web_page', arguments: {
|
|
|
|
"activityId": bannerData.content,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Navigator.of(context).pushNamed('/router/web_page', arguments: {
|
|
|
|
"articleId": bannerData.content,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
String router = bannerData.content;
|
|
|
|
// String router = "/router/store_order?{\"id\":\"1512378184161558528\",\"tenant\":\"1188\",\"storeName\":\"农场煮意\"}";
|
|
|
|
if (router.contains("?")) {
|
|
|
|
String params = router.substring(router.indexOf("?") + 1);
|
|
|
|
Map map = jsonDecode(params);
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
router.substring(0, router.indexOf("?")),
|
|
|
|
arguments: map);
|
|
|
|
} else {
|
|
|
|
Navigator.of(context).pushNamed(router);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
Navigator.of(context).pushNamed('/router/class_details', arguments: {
|
|
|
|
"id": bannerData.content,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
String params =
|
|
|
|
bannerData.content.substring(bannerData.content.indexOf("?") + 1);
|
|
|
|
Map map = jsonDecode(params);
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
bannerData.content.substring(0, bannerData.content.indexOf("?")),
|
|
|
|
arguments: map);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget spread() {
|
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
|
|
|
// margin: EdgeInsets.symmetric(horizontal:14.w),
|
|
|
|
height: 85.h,
|
|
|
|
child: activityBannerData != null && activityBannerData.isNotEmpty
|
|
|
|
? Swiper(
|
|
|
|
pagination: SwiperPagination(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
margin: EdgeInsets.only(top: 5.h,),
|
|
|
|
builder: DotSwiperPaginationBuilder(
|
|
|
|
size: 8.w,
|
|
|
|
activeSize: 8.w,
|
|
|
|
space: 5.w,
|
|
|
|
activeColor: Colors.white,
|
|
|
|
color: Colors.white.withAlpha(76),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
autoplay: true,
|
|
|
|
duration: 1000,
|
|
|
|
autoplayDelay: 2000,
|
|
|
|
itemBuilder: (context, position) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
spreadBannerClick(activityBannerData[position]);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 14.w),
|
|
|
|
child: MImage(
|
|
|
|
activityBannerData[position].imgUrl,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
radius: BorderRadius.circular(6),
|
|
|
|
errorSrc: "assets/image/default_2_1.webp",
|
|
|
|
fadeSrc: "assets/image/default_2_1.webp",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: activityBannerData.length,
|
|
|
|
)
|
|
|
|
: Image.asset(
|
|
|
|
"assets/image/default_2_1.webp",
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程,7:门店跳转)
|
|
|
|
spreadBannerClick(BannerData activityBannerData) async {
|
|
|
|
switch (activityBannerData.contentType) {
|
|
|
|
case 1:
|
|
|
|
Navigator.of(context).pushNamed('/router/integral_store_page',
|
|
|
|
arguments: {"goodsId": activityBannerData.content});
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Navigator.of(context).pushNamed('/router/web_page', arguments: {
|
|
|
|
"activityId": activityBannerData.content,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Navigator.of(context).pushNamed('/router/web_page', arguments: {
|
|
|
|
"articleId": activityBannerData.content,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
String router = activityBannerData.content;
|
|
|
|
// String router = "/router/store_order?{\"id\":\"1512378184161558528\",\"tenant\":\"1188\",\"storeName\":\"农场煮意\"}";
|
|
|
|
if (router.contains("?")) {
|
|
|
|
String params = router.substring(router.indexOf("?") + 1);
|
|
|
|
Map map = jsonDecode(params);
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
router.substring(0, router.indexOf("?")),
|
|
|
|
arguments: map);
|
|
|
|
} else {
|
|
|
|
Navigator.of(context).pushNamed(router);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
Navigator.of(context).pushNamed('/router/class_details', arguments: {
|
|
|
|
"id": activityBannerData.content,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
String params = activityBannerData.content
|
|
|
|
.substring(activityBannerData.content.indexOf("?") + 1);
|
|
|
|
Map map = jsonDecode(params);
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
activityBannerData.content
|
|
|
|
.substring(0, activityBannerData.content.indexOf("?")),
|
|
|
|
arguments: map);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///扫码
|
|
|
|
toScan() async {
|
|
|
|
if (await Permission.camera.isPermanentlyDenied) {
|
|
|
|
showCupertinoDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) {
|
|
|
|
return RequestPermission(
|
|
|
|
"assets/image/icon_camera_permission_tips.webp",
|
|
|
|
S.of(context).ninxiangjiquanxianweikaiqi,
|
|
|
|
S.of(context).weilekaipaizhaoxuanzhetouxiang,
|
|
|
|
S.of(context).kaiqiquanxian,
|
|
|
|
(result) async {
|
|
|
|
if (result) {
|
|
|
|
await openAppSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
heightRatioWithWidth: 0.82,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
} else if (await Permission.camera.isGranted) {
|
|
|
|
// http://pos.app.gznl.top/placeorder/?tableId=1315903669597634560&tenantCode=1166&shopId=1300372027722432512
|
|
|
|
// 新版桌子码跳转
|
|
|
|
// http://miniscan.lotus-wallet.com/placeorder?tenant_code=1194&table_id=1669609340031467520&store_id=1637659387134738432
|
|
|
|
var result = await Navigator.of(context).pushNamed('/router/qr_scan');
|
|
|
|
if (result.toString().contains("type\":\"coupon")) {
|
|
|
|
///活动优惠券赠送弹窗
|
|
|
|
activityShowAlertDialog(result.toString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (result.toString().contains("type\":\"wiped")) {
|
|
|
|
///核销券
|
|
|
|
queryWiped(jsonDecode(result.toString())["memberCouponId"]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// String result = await scanner.scan();
|
|
|
|
Uri uri = Uri.parse(result);
|
|
|
|
String tableId =
|
|
|
|
uri.queryParameters["tableId"] ?? uri.queryParameters["table_id"];
|
|
|
|
String tenantCode = uri.queryParameters["tenantCode"] ??
|
|
|
|
uri.queryParameters["tenant_code"];
|
|
|
|
String shopId =
|
|
|
|
uri.queryParameters["shopId"] ?? uri.queryParameters["store_id"];
|
|
|
|
if (tableId != null &&
|
|
|
|
tableId != "" &&
|
|
|
|
tenantCode != null &&
|
|
|
|
tenantCode != "" &&
|
|
|
|
shopId != null &&
|
|
|
|
shopId != "") {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
'/router/store_order',
|
|
|
|
arguments: {
|
|
|
|
"id": shopId,
|
|
|
|
"tenant": tenantCode,
|
|
|
|
"storeName": "",
|
|
|
|
"tableId": int.tryParse(tableId),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showCupertinoDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) {
|
|
|
|
return RequestPermission(
|
|
|
|
"assets/image/icon_camera_permission_tips.webp",
|
|
|
|
S.of(context).ninxiangjiquanxianweikaiqi,
|
|
|
|
S.of(context).weilekaipaizhaoxuanzhetouxiang,
|
|
|
|
S.of(context).kaiqiquanxian,
|
|
|
|
(result) async {
|
|
|
|
if (result) {
|
|
|
|
await Permission.camera.request();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
heightRatioWithWidth: 0.82,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_toDetails(index) async {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
'/router/integral_store_page',
|
|
|
|
arguments: {"goodsId": goods[index].id},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
activityShowAlertDialog(String result) {
|
|
|
|
//显示对话框
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return ActivityCoupons(result);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get wantKeepAlive => true;
|
|
|
|
}
|