|
|
@ -110,21 +110,22 @@ class CartProvidde with ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
|
|
///单选商品
|
|
|
|
///单选商品
|
|
|
|
changeCheckState(AkuShopModel cartItem) async {
|
|
|
|
changeCheckState(AkuShopModel cartItem) async {
|
|
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
cartString = prefs.getString("cartInfo");
|
|
|
|
// cartString = prefs.getString("cartInfo");
|
|
|
|
List<Map> tempList = (json.decode(cartString.toString()) as List).cast();
|
|
|
|
// List<Map> tempList = (json.decode(cartString.toString()) as List).cast();
|
|
|
|
int tempIndex = 0;
|
|
|
|
// int tempIndex = 0;
|
|
|
|
int changeIndex = 0;
|
|
|
|
// int changeIndex = 0;
|
|
|
|
tempList.forEach((item) {
|
|
|
|
// tempList.forEach((item) {
|
|
|
|
if (item["itemid"] == cartItem.itemid) {
|
|
|
|
// if (item["itemid"] == cartItem.itemid) {
|
|
|
|
changeIndex = tempIndex;
|
|
|
|
// changeIndex = tempIndex;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
tempIndex++;
|
|
|
|
// tempIndex++;
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
tempList[changeIndex] = cartItem.toJson();
|
|
|
|
// tempList[changeIndex] = cartItem.toJson();
|
|
|
|
cartString = json.encode(tempList).toString();
|
|
|
|
// cartString = json.encode(tempList).toString();
|
|
|
|
prefs.setString("cartInfo", cartString);
|
|
|
|
// prefs.setString("cartInfo", cartString);
|
|
|
|
await getCartInfo();
|
|
|
|
// await getCartInfo();
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///全选商品
|
|
|
|
///全选商品
|
|
|
|