购物车数量加减修复,评论区图片修改

hmxc
张萌 4 years ago
parent 2bd339a3bc
commit c0f92ba5f1

@ -47,7 +47,11 @@ class _ViewCommentsPageState extends State<ViewCommentsPage> {
'name': '马泽鹏',
'subtitle': "47天前 尺码[170-185cm] 颜色分类:黑色",
'content': '太好蓝了,现在天气有点热,赶快到秋天',
'contentImageList': imageUrl,
'contentImageList': [
'https://img.alicdn.com/imgextra/i3/409405727/O1CN01yNXzbp1sB0pPy06vu_!!409405727.jpg',
'https://img.alicdn.com/imgextra/i3/409405727/O1CN01yNXzbp1sB0pPy06vu_!!409405727.jpg',
'https://img.alicdn.com/imgextra/i2/409405727/O1CN01oaedss1sB0pPDo1JB_!!409405727.jpg'
],
'viewNum': '532',
},
{
@ -56,7 +60,11 @@ class _ViewCommentsPageState extends State<ViewCommentsPage> {
'name': '王珂珂',
'subtitle': "4天前 尺码[170-185cm] 颜色分类:黑色",
'content': '面料和版型都不错,会回购',
'contentImageList': imageUrl,
'contentImageList': [
'https://img.alicdn.com/bao/uploaded/i4/O1CN01XIzuhk1FdADbW7Cwf_!!0-rate.jpg_400x400.jpg',
'https://img.alicdn.com/bao/uploaded/i1/O1CN01KNMhVC242YySXXE4f_!!0-rate.jpg_400x400.jpg',
'https://img.alicdn.com/bao/uploaded/i4/O1CN01A2q4Bb2LhBZJ5elrj_!!0-rate.jpg_400x400.jpg',
],
'viewNum': '235',
},
];

@ -132,9 +132,9 @@ class _SignInPageState extends State<SignInPage> {
return InkWell(
onTap: () {
if (TextUtil.isEmpty(_phone.text))
showToast('号不能为空');
showToast('手机号不能为空');
else if (TextUtil.isEmpty(_code.text))
showToast('码不能为空');
showToast('验证码不能为空');
else {
showCupertinoDialog(
context: context,
@ -142,7 +142,7 @@ class _SignInPageState extends State<SignInPage> {
return CupertinoAlertDialog(
title: Text('点击登录即表示您已阅读并同意'),
content: Text(
'''点击登录即表示您已阅读并同意《闲鱼用户服务协议》《支付服务协议》(特别是免除或限制责任、管辖等粗体下划线标注的条款)。如您不同意上述协议的任何条款,您应立即停止登录及使用本软件及服务。'''),
'''点击登录即表示您已阅读并同意《小蜜蜂用户协议》《小蜜蜂隐私政策》(特别是免除或限制责任、管辖等粗体下划线标注的条款)。如您不同意上述协议的任何条款,您应立即停止登录及使用本软件及服务。'''),
actions: [
CupertinoDialogAction(
child: Text('同意'),
@ -151,8 +151,8 @@ class _SignInPageState extends State<SignInPage> {
Duration(milliseconds: 1000 + Random().nextInt(500)),
() {
Navigator.pop(context);
(_phone.text == '17855823545') &&
(_code.text == '000000')
(_phone.text == '18067170899') &&
(_code.text == '123456')
? ARoute.push(context, UserAuthenticationPage())
: showToast('账号或密码错误!');
},
@ -239,17 +239,28 @@ class _SignInPageState extends State<SignInPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
FlatButton(
padding: EdgeInsets.zero,
onPressed: () {
ARoute.push(context, AgreementPage());
},
child: Text('用户协议'),
child: Text(
'《小蜜蜂用户协议》',
style: TextStyle(
color: Colors.lightBlue,
),
SizedBox(width: Screenutil.length(15)),
)),
SizedBox(width: 15.w),
FlatButton(
padding: EdgeInsets.zero,
onPressed: () {
ARoute.push(context, PrivacyPage());
},
child: Text('隐私政策'))
child: Text(
'《小蜜蜂隐私政策》',
style: TextStyle(
color: Colors.lightBlue,
),
))
],
),
],

@ -37,7 +37,12 @@ class CartProvidde with ChangeNotifier {
"isCheck": false
};
tempList.add(newGoods);
cartList.add(AkuShopModel.fromJson(newGoods));
AkuShopModel _newgoods= AkuShopModel.fromJson(newGoods);
int _goodIndex= cartList.indexWhere((element) {
return element.itemid==_newgoods.itemid;
});
_goodIndex>-1?cartList[_goodIndex].count+=count:
cartList.add(_newgoods);
}
cartString = json.encode(tempList).toString();
print(cartString);
@ -139,26 +144,27 @@ class CartProvidde with ChangeNotifier {
}
///
addOrReduceAction(var cartItem, String todo) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
cartString = prefs.getString("cartInfo");
List<Map> tempList = (json.decode(cartString.toString()) as List).cast();
int tempIndex = 0;
int changeIndex = 0;
tempList.forEach((item) {
if (item["itemid"] == cartItem.itemid) {
changeIndex = tempIndex;
}
tempIndex++;
});
addOrReduceAction(AkuShopModel cartItem, String todo) async {
// SharedPreferences prefs = await SharedPreferences.getInstance();
// cartString = prefs.getString("cartInfo");
// List<Map> tempList = (json.decode(cartString.toString()) as List).cast();
// int tempIndex = 0;
// int changeIndex = 0;
// tempList.forEach((item) {
// if (item["itemid"] == cartItem.itemid) {
// changeIndex = tempIndex;
// }
// tempIndex++;
// });
if (todo == 'add') {
cartItem.count++;
} else if (cartItem.count > 1) {
cartItem.count--;
}
tempList[changeIndex] = cartItem.toJson();
cartString = json.encode(tempList).toString();
prefs.setString("cartInfo", cartString);
await getCartInfo();
notifyListeners();
// tempList[changeIndex] = cartItem.toJson();
// cartString = json.encode(tempList).toString();
// // prefs.setString("cartInfo", cartString);
// await getCartInfo();
}
}

Loading…
Cancel
Save