no message

parent ac07dd74
...@@ -33,7 +33,7 @@ class MyApp extends StatelessWidget { ...@@ -33,7 +33,7 @@ class MyApp extends StatelessWidget {
home: MainShop() home: Favorite()
//home: EditProfile(), //home: EditProfile(),
......
class DeletefavoriteModel {
String message;
DeletefavoriteModel({this.message});
DeletefavoriteModel.fromJson(Map<String, dynamic> json) {
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['message'] = this.message;
return data;
}
}
\ No newline at end of file
class FavoriteModel { class FavoriteModel {
int id; int id;
int customerId; int customerId;
...@@ -117,7 +118,7 @@ class Product { ...@@ -117,7 +118,7 @@ class Product {
String excerpt; String excerpt;
String detail; String detail;
String price; String price;
String specialPrice; dynamic specialPrice;
String sku; String sku;
dynamic tax; dynamic tax;
int quantity; int quantity;
...@@ -146,11 +147,11 @@ class Product { ...@@ -146,11 +147,11 @@ class Product {
String status; String status;
int businessTypeId; int businessTypeId;
int businessCateId; int businessCateId;
dynamic businessServiceId; int businessServiceId;
int attributeSetId; int attributeSetId;
int vendorId; int vendorId;
String allowRoute; String allowRoute;
dynamic type; String type;
int star; int star;
List<Null> ratings; List<Null> ratings;
...@@ -289,7 +290,6 @@ class Product { ...@@ -289,7 +290,6 @@ class Product {
data['allow_route'] = this.allowRoute; data['allow_route'] = this.allowRoute;
data['type'] = this.type; data['type'] = this.type;
data['star'] = this.star; data['star'] = this.star;
return data; return data;
} }
} }
...@@ -321,8 +321,8 @@ class Store { ...@@ -321,8 +321,8 @@ class Store {
String storeLogo; String storeLogo;
String isFacilities; String isFacilities;
String distanceWithLocation; String distanceWithLocation;
int star; String star;
dynamic ratings; Ratings ratings;
Store( Store(
{this.id, {this.id,
...@@ -382,7 +382,8 @@ class Store { ...@@ -382,7 +382,8 @@ class Store {
isFacilities = json['is_facilities']; isFacilities = json['is_facilities'];
distanceWithLocation = json['distance_with_location']; distanceWithLocation = json['distance_with_location'];
star = json['star']; star = json['star'];
ratings = json['ratings']; ratings =
json['ratings'] != null ? new Ratings.fromJson(json['ratings']) : null;
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
...@@ -414,7 +415,122 @@ class Store { ...@@ -414,7 +415,122 @@ class Store {
data['is_facilities'] = this.isFacilities; data['is_facilities'] = this.isFacilities;
data['distance_with_location'] = this.distanceWithLocation; data['distance_with_location'] = this.distanceWithLocation;
data['star'] = this.star; data['star'] = this.star;
data['ratings'] = this.ratings; if (this.ratings != null) {
data['ratings'] = this.ratings.toJson();
}
return data;
}
}
class Ratings {
int id;
String title;
String rateType;
String rateCate;
String rateTb;
int rateRowId;
String isCustom;
dynamic customScore;
int rateRange;
int storeId;
int vendorId;
String createdAt;
String updatedAt;
List<RatingScore> ratingScore;
Ratings(
{this.id,
this.title,
this.rateType,
this.rateCate,
this.rateTb,
this.rateRowId,
this.isCustom,
this.customScore,
this.rateRange,
this.storeId,
this.vendorId,
this.createdAt,
this.updatedAt,
this.ratingScore});
Ratings.fromJson(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
rateType = json['rate_type'];
rateCate = json['rate_cate'];
rateTb = json['rate_tb'];
rateRowId = json['rate_row_id'];
isCustom = json['is_custom'];
customScore = json['custom_score'];
rateRange = json['rate_range'];
storeId = json['store_id'];
vendorId = json['vendor_id'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
if (json['rating_score'] != null) {
ratingScore = new List<RatingScore>();
json['rating_score'].forEach((v) {
ratingScore.add(new RatingScore.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['title'] = this.title;
data['rate_type'] = this.rateType;
data['rate_cate'] = this.rateCate;
data['rate_tb'] = this.rateTb;
data['rate_row_id'] = this.rateRowId;
data['is_custom'] = this.isCustom;
data['custom_score'] = this.customScore;
data['rate_range'] = this.rateRange;
data['store_id'] = this.storeId;
data['vendor_id'] = this.vendorId;
data['created_at'] = this.createdAt;
data['updated_at'] = this.updatedAt;
if (this.ratingScore != null) {
data['rating_score'] = this.ratingScore.map((v) => v.toJson()).toList();
}
return data;
}
}
class RatingScore {
int id;
int ratingId;
String ratingScore;
String createdAt;
String updatedAt;
int customerId;
RatingScore(
{this.id,
this.ratingId,
this.ratingScore,
this.createdAt,
this.updatedAt,
this.customerId});
RatingScore.fromJson(Map<String, dynamic> json) {
id = json['id'];
ratingId = json['rating_id'];
ratingScore = json['rating_score'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
customerId = json['customer_id'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['rating_id'] = this.ratingId;
data['rating_score'] = this.ratingScore;
data['created_at'] = this.createdAt;
data['updated_at'] = this.updatedAt;
data['customer_id'] = this.customerId;
return data; return data;
} }
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import 'package:feelverapp/model/Login/login_model.dart'; ...@@ -5,6 +5,7 @@ import 'package:feelverapp/model/Login/login_model.dart';
import 'package:feelverapp/model/base/base.dart'; import 'package:feelverapp/model/base/base.dart';
import 'package:feelverapp/model/editprofile/getprofilemodel.dart'; import 'package:feelverapp/model/editprofile/getprofilemodel.dart';
import 'package:feelverapp/model/favorite/delete_favorite_Model.dart';
import 'package:feelverapp/model/favorite/favorite_Model.dart'; import 'package:feelverapp/model/favorite/favorite_Model.dart';
import 'package:feelverapp/model/forgetpassword/forgetpassModel.dart'; import 'package:feelverapp/model/forgetpassword/forgetpassModel.dart';
...@@ -30,6 +31,26 @@ class Api<T> { ...@@ -30,6 +31,26 @@ class Api<T> {
}; };
static final String baseApi = "https://backend-uat.feelver.com/api"; static final String baseApi = "https://backend-uat.feelver.com/api";
Future<Response<T>> deletefavorite(Object body) async {
var _model;
var _fail;
var result;
print("this is body"+body.toString());
await _httpConnection("${this._baseApi}/wishlist-item/delete", this._headerApi, body).then((response){
print("ผลลัพท เท่ากับ"+"${response.body}");
if(response.statusCode == 200){
_model = DeletefavoriteModel.fromJson(json.decode(response.body));
}else{
_fail = FailModel.fromJson(json.decode(response.body));
}
result = new Response<T>(_model, _fail);
});
return result;
}
Future<Response<T>> favorite(Object body) async { Future<Response<T>> favorite(Object body) async {
var _model; var _model;
var _fail; var _fail;
......
...@@ -14,12 +14,15 @@ class _FavoriteState extends State<Favorite> { ...@@ -14,12 +14,15 @@ class _FavoriteState extends State<Favorite> {
FavoritePresenter presenter; FavoritePresenter presenter;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
presenter = FavoritePresenter(this); presenter = FavoritePresenter(this);
presenter.Favoriteitem(); presenter.Favoriteitem();
presenter.Deletefavoriteitem();
} }
@override @override
...@@ -120,7 +123,9 @@ class _FavoriteState extends State<Favorite> { ...@@ -120,7 +123,9 @@ class _FavoriteState extends State<Favorite> {
icon: Icon(Icons.favorite), icon: Icon(Icons.favorite),
color: Color(0xFFDD175F), color: Color(0xFFDD175F),
onPressed: () { onPressed: () {
print('delete'); setState(() {
});
}, },
), ),
], ],
...@@ -155,7 +160,7 @@ class _FavoriteState extends State<Favorite> { ...@@ -155,7 +160,7 @@ class _FavoriteState extends State<Favorite> {
color: Color(0xFFEEAFB7), color: Color(0xFFEEAFB7),
), ),
Text( Text(
"฿" + presenter.favoriteModel.wishListItem[index].product.specialPrice, "฿0000",
style: TextStyle( style: TextStyle(
decoration: TextDecoration.lineThrough, decoration: TextDecoration.lineThrough,
fontSize: SizeConfig.getFontSize(16), fontSize: SizeConfig.getFontSize(16),
......
import 'package:feelverapp/model/favorite/delete_favorite_Model.dart';
import 'package:feelverapp/model/favorite/favorite_Model.dart'; import 'package:feelverapp/model/favorite/favorite_Model.dart';
import 'package:feelverapp/service/api.dart'; import 'package:feelverapp/service/api.dart';
import 'package:feelverapp/service/base_presenter.dart'; import 'package:feelverapp/service/base_presenter.dart';
...@@ -8,6 +9,7 @@ class FavoritePresenter extends BasePresenter<Favorite> { ...@@ -8,6 +9,7 @@ class FavoritePresenter extends BasePresenter<Favorite> {
Api _api; Api _api;
final formkey = GlobalKey<FormState>(); final formkey = GlobalKey<FormState>();
FavoriteModel favoriteModel; FavoriteModel favoriteModel;
DeletefavoriteModel deletefavoriteModel;
FavoritePresenter(State<Favorite> state) : super(state); FavoritePresenter(State<Favorite> state) : super(state);
...@@ -25,4 +27,22 @@ class FavoritePresenter extends BasePresenter<Favorite> { ...@@ -25,4 +27,22 @@ class FavoritePresenter extends BasePresenter<Favorite> {
print('res Fail'); print('res Fail');
} }
} }
Deletefavoriteitem() async {
_api = Api<DeletefavoriteModel>();
var res = await _api.deletefavorite({
"id": "146",
});
if (res.fail == null) {
setState(() {
deletefavoriteModel = res.success;
});
} else {
print('res Fail');
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment