bug fixed

This commit is contained in:
nutchayut
2024-12-25 16:50:33 +07:00
parent e6e3de4b6a
commit f6b69c6c56
6 changed files with 114 additions and 33 deletions

View File

@@ -114,8 +114,9 @@ class _HomePageState extends State<HomePage> {
List<BannerModel> listBanner = [];
getBanner() {
/* getBanner() {
Api.get(context, Api.banner).then((value) => {
if (value != null)
{
value.forEach((v) {
@@ -128,26 +129,65 @@ class _HomePageState extends State<HomePage> {
else
{}
});
}*/
getBanner() {
Api.get(context, Api.banner).then((value) {
if (value != null) {
DateTime now = DateTime.now(); // วันปัจจุบัน
value.forEach((v) {
if (v["file_url"] != null &&
v["start_date"] != null &&
v["end_date"] != null) {
DateTime startDate = DateTime.parse(v["start_date"]);
DateTime endDate = DateTime.parse(v["end_date"]);
if (startDate.isBefore(now) && endDate.isAfter(now)) {
listBanner.add(BannerModel.fromJson(v));
}
}
});
refresh();
}
});
}
List<PromotionModel> listPromotion = [];
// getPromotion() {
// Api.get(context, Api.promotion).then((value) => {
// if (value != null)
// {
// value.forEach((v) {
// if (v["file_url"] != null) {
// listPromotion.add(PromotionModel.fromJson(v));
// }
// }),
// refresh()
// }
// else
// {}
// });
// }
getPromotion() {
Api.get(context, Api.promotion).then((value) => {
if (value != null)
{
value.forEach((v) {
if (v["file_url"] != null) {
listPromotion.add(PromotionModel.fromJson(v));
}
}),
refresh()
Api.get(context, Api.promotion).then((value) {
if (value != null) {
DateTime now = DateTime.now(); // วันปัจจุบัน
value.forEach((v) {
if (v["file_url"] != null &&
v["start_date"] != null &&
v["end_date"] != null) {
DateTime startDate = DateTime.parse(v["start_date"]);
DateTime endDate = DateTime.parse(v["end_date"]);
if (startDate.isBefore(now) && endDate.isAfter(now)) {
listPromotion.add(PromotionModel.fromJson(v));
}
else
{}
}
});
refresh();
}
});
}
getTokenAdmin() {
// Api.get(context, Api.getTokenAdmin).then((value) => {tokenAdmin = value["token"]});