Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

您好 这个group 可以支持单选吗? #4

Closed
Yn1025 opened this issue Apr 23, 2019 · 7 comments
Closed

您好 这个group 可以支持单选吗? #4

Yn1025 opened this issue Apr 23, 2019 · 7 comments

Comments

@Yn1025
Copy link

Yn1025 commented Apr 23, 2019

No description provided.

@OCNYang
Copy link
Owner

OCNYang commented Apr 23, 2019

这是购物车的逻辑,不支持单选的。

@OCNYang OCNYang closed this as completed Apr 23, 2019
@Yn1025
Copy link
Author

Yn1025 commented Apr 24, 2019

这是购物车的逻辑,不支持单选的。
我看了下源码 想修改成 group 可以单选 可是能力有限 大神能给一点思路吗?

@Yn1025
Copy link
Author

Yn1025 commented Apr 24, 2019

就是只可以选择一个店铺里面的商品

@OCNYang
Copy link
Owner

OCNYang commented Apr 24, 2019

我明白你说的逻辑,但是这个库我是按照普通购物车封装的,如果你有特殊需求,可以下载源码,在源码内拓展逻辑以符合你的需求

@Yn1025
Copy link
Author

Yn1025 commented Apr 24, 2019

下载了 改乱了都.... 大神有空的话 提供一点思路呗 拜托了.......

@OCNYang
Copy link
Owner

OCNYang commented Apr 24, 2019

这个逻辑也很明确:

1. 用一个变量 currentGroup 保存勾选的当前店铺的下标,默认为 -1;
2. 当勾选一个店铺时,判断 currentGroup 的值,不为 -1 时把这个下标的店铺 item 勾选状态改变,然后把当前勾选的店铺下标再赋值给 currentGroup;
3. 当取消勾选店铺时,把 currentGroup 的值重置为-1;
4. 当勾选一个商品时,先获取这个商品所属的店铺下标,和 currentGroup 不等时执行步骤 2 ,相等时不执行任何逻辑;
5. 当取消一个商品时,先判断同店铺下是否还有其他商品是勾选状态,如果没有执行 3 ,如果有不执行任何逻辑;  

目前我只想到这些逻辑应该就可以了。是否有漏洞要靠实践。

@Yn1025
Copy link
Author

Yn1025 commented Apr 24, 2019

谢谢谢谢 非常感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants