|
|
|
@ -1,13 +1,13 @@
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/addToCartModel.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart';
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/specification.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/specification.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class ProductDetailService extends BaseService {
|
|
|
|
class ProductDetailService extends BaseService {
|
|
|
|
bool isLogin = false;
|
|
|
|
bool isLogin = false;
|
|
|
|
@ -28,7 +28,6 @@ class ProductDetailService extends BaseService {
|
|
|
|
List<SpecificationModel> get productSpecification => _productSpecification;
|
|
|
|
List<SpecificationModel> get productSpecification => _productSpecification;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future getProductReviews(productID) async {
|
|
|
|
Future getProductReviews(productID) async {
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL+productID+"?fields=reviews",
|
|
|
|
await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL+productID+"?fields=reviews",
|
|
|
|
@ -74,7 +73,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
}, body: request);
|
|
|
|
}, body: request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future addToCart(quantity, itemID) async {
|
|
|
|
Future<Map> addToCart(quantity, itemID) async {
|
|
|
|
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
Map<String, dynamic> request;
|
|
|
|
Map<String, dynamic> request;
|
|
|
|
@ -89,8 +88,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
"language_id": 1
|
|
|
|
"language_id": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false,
|
|
|
|
await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false,
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
@ -99,11 +97,14 @@ class ProductDetailService extends BaseService {
|
|
|
|
_addToCartModel.add(Wishlist.fromJson(item));
|
|
|
|
_addToCartModel.add(Wishlist.fromJson(item));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
AppToast.showSuccessToast(message: 'You have added a product to the cart');
|
|
|
|
AppToast.showSuccessToast(message: 'You have added a product to the cart');
|
|
|
|
|
|
|
|
localRes = response;
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
hasError = true;
|
|
|
|
hasError = true;
|
|
|
|
super.error = error;
|
|
|
|
super.error = error;
|
|
|
|
AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
|
|
|
|
AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
|
|
|
|
}, body: request);
|
|
|
|
}, body: request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future notifyMe(customerId, itemID) async {
|
|
|
|
Future notifyMe(customerId, itemID) async {
|
|
|
|
|