Merge branch 'pharmacy-Fatima' into 'development'

Pharmacy fatima

See merge request Cloud_Solution/diplomatic-quarter!298
merge-update-with-lab-changes
Mohammad Aljammal 5 years ago
commit 0a4f17dc88

@ -509,6 +509,8 @@ const LAKUM_GET_USER_TERMS_AND_CONDITIONS =
"Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy";
const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList';
const GET_RECOMMENDED_PRODUCT = 'alsoProduct/'; const GET_RECOMMENDED_PRODUCT = 'alsoProduct/';
const GET_MOST_VIEWED_PRODUCTS ="mostview?";
const GET_NEW_PRODUCTS = "newproducts?";
// Home Health Care // Home Health Care
const HHC_GET_ALL_SERVICES = const HHC_GET_ALL_SERVICES =

@ -316,4 +316,50 @@ class PharmacyCategoriseService extends BaseService {
}, },
); );
} }
Future getMostViewedProducts() async {
Map<String, String> queryParams = {
'fields':
'id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage',
};
try {
await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS,
onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
});
print("most viewed products ---------");
print(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
} catch (error) {
throw error;
}
}
Future getNewProducts() async {
Map<String, String> queryParams = {
'fields':
'Id,name,namen,localized_names,price,images,sku,stock_availability,published',
};
try {
await baseAppClient.getPharmacy(GET_NEW_PRODUCTS,
onSuccess: (dynamic response, int statusCode) {
_finalProducts.clear();
response['products'].forEach((item) {
_finalProducts.add(PharmacyProduct.fromJson(item));
});
print("new products ---------");
print(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
} catch (error) {
throw error;
}
}
} }

@ -203,4 +203,26 @@ class PharmacyCategoriseViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
Future getMostViewedProducts() async {
setState(ViewState.Busy);
await _pharmacyCategoriseService.getMostViewedProducts();
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
Future getNewProducts() async {
setState(ViewState.Busy);
await _pharmacyCategoriseService.getNewProducts();
if (_pharmacyCategoriseService.hasError) {
error = _pharmacyCategoriseService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
} }

@ -41,6 +41,10 @@ class _FinalProductsPageState extends State<FinalProductsPage> {
model.getManufacturerProducts(id); model.getManufacturerProducts(id);
} else if (widget.productType == 3) { } else if (widget.productType == 3) {
model.getLastVisitedProducts(); model.getLastVisitedProducts();
} else if (widget.productType == 4){
model.getMostViewedProducts();
} else if (widget.productType == 5){
model.getNewProducts();
} else { } else {
model.getBestSellerProducts(); model.getBestSellerProducts();
} }

@ -37,54 +37,56 @@ class _PharmacyCategorisePageState extends State<PharmacyCategorisePage> {
baseViewModel: model, baseViewModel: model,
body: Column( body: Column(
children: [ children: [
Container( Expanded(
height: 400, child: Container(
margin: EdgeInsets.only(bottom: 22), height: 400,
child: GridView.builder( margin: EdgeInsets.only(bottom: 22),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( child: GridView.builder(
crossAxisCount: 2, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisSpacing: 0.5, crossAxisCount: 2,
mainAxisSpacing: 1.0, crossAxisSpacing: 0.5,
childAspectRatio: 3.2, mainAxisSpacing: 1.0,
), childAspectRatio: 3.2,
itemCount: model.categorise.length, ),
itemBuilder: (BuildContext context, int index) { itemCount: model.categorise.length,
return Padding( itemBuilder: (BuildContext context, int index) {
padding: EdgeInsets.all(4.0), return Padding(
child: InkWell( padding: EdgeInsets.all(4.0),
child: Container( child: InkWell(
decoration: BoxDecoration( child: Container(
borderRadius: BorderRadius.circular(5), decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.24), borderRadius: BorderRadius.circular(5),
), color: Colors.grey.withOpacity(0.24),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Texts(
projectViewModel.isArabic
? model.categorise[index].namen
: model.categorise[index].name,
fontWeight: FontWeight.w600,
), ),
), child: Padding(
), padding: EdgeInsets.symmetric(horizontal: 10.0),
onTap: () => { child: Texts(
Navigator.push( projectViewModel.isArabic
context, ? model.categorise[index].namen
FadePage( : model.categorise[index].name,
page: model.categorise[index].id != '12' fontWeight: FontWeight.w600,
? ParentCategorisePage( ),
id: model.categorise[index].id,
titleName: model.categorise[index].name,
)
: FinalProductsPage(
id: model.categorise[index].id,
),
), ),
), ),
}, onTap: () => {
), Navigator.push(
); context,
}, FadePage(
page: model.categorise[index].id != '12'
? ParentCategorisePage(
id: model.categorise[index].id,
titleName: model.categorise[index].name,
)
: FinalProductsPage(
id: model.categorise[index].id,
),
),
),
},
),
);
},
),
), ),
), ),
Container( Container(
@ -110,7 +112,7 @@ class _PharmacyCategorisePageState extends State<PharmacyCategorisePage> {
FadePage( FadePage(
page: FinalProductsPage( page: FinalProductsPage(
id: "", id: "",
productType: 4, productType: 6,
), ),
), ),
); );
@ -140,21 +142,35 @@ class _PharmacyCategorisePageState extends State<PharmacyCategorisePage> {
Expanded( Expanded(
child: Padding( child: Padding(
padding: EdgeInsets.all(4.0), padding: EdgeInsets.all(4.0),
child: Container( child: InkWell(
height: 50.0, onTap: () {
width: 55.0, Navigator.push(
decoration: BoxDecoration( context,
color: Colors.orangeAccent.shade200 FadePage(
.withOpacity(0.34), page: FinalProductsPage(
borderRadius: BorderRadius.circular(5.0), id: "",
), productType: 4,
child: Padding( ),
padding: EdgeInsets.symmetric(horizontal: 10.0), ),
child: Texts( );
projectViewModel.isArabic },
? 'الاكثر مشاهدة' child: Container(
: 'Most Viewed', height: 50.0,
fontWeight: FontWeight.w600, width: 55.0,
decoration: BoxDecoration(
color: Colors.orangeAccent.shade200
.withOpacity(0.34),
borderRadius: BorderRadius.circular(5.0),
),
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: 10.0),
child: Texts(
projectViewModel.isArabic
? 'الاكثر مشاهدة'
: 'Most Viewed',
fontWeight: FontWeight.w600,
),
), ),
), ),
), ),
@ -167,20 +183,34 @@ class _PharmacyCategorisePageState extends State<PharmacyCategorisePage> {
Expanded( Expanded(
child: Padding( child: Padding(
padding: EdgeInsets.all(4.0), padding: EdgeInsets.all(4.0),
child: Container( child: InkWell(
height: 50.0, onTap: () {
width: 55.0, Navigator.push(
decoration: BoxDecoration( context,
color: Colors.blue.shade200.withOpacity(0.34), FadePage(
borderRadius: BorderRadius.circular(5.0), page: FinalProductsPage(
), id: "",
child: Padding( productType: 5,
padding: EdgeInsets.symmetric(horizontal: 10.0), ),
child: Texts( ),
projectViewModel.isArabic );
? 'منتجات جديدة' },
: 'New Products', child: Container(
fontWeight: FontWeight.w600, height: 50.0,
width: 55.0,
decoration: BoxDecoration(
color: Colors.blue.shade200.withOpacity(0.34),
borderRadius: BorderRadius.circular(5.0),
),
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: 10.0),
child: Texts(
projectViewModel.isArabic
? 'منتجات جديدة'
: 'New Products',
fontWeight: FontWeight.w600,
),
), ),
), ),
), ),

Loading…
Cancel
Save