购物车

购物车实现分析及工程搭建、商品详情页面对加入购物车进行改造、添加购物车、展示购物车列表、修改购物车商品数量、删除购物车商品及购物车总结 购物车实现分析及工程搭建 关于购物车模块,京东和淘宝并不一样,京东允许用户在没有登录的情况下就使用购物车,而且加到购物车里面的商品可以一直保存着(其实是放到了Cookie当中,如果清空了Cookie也就清空购物车了)。而淘宝则是必须先登录才能将商品添加到购物车当中,就用户体验来说,京东的购物车模块用户体验更好。 我们看下京东购物车,如下图所示,可以看到域名是cart.jd.com,这与商品详情页面... 阅读详情

依赖

compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.facebook.fresco:fresco:0.13.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'io.reactivex.rxjava2:rxjava:2.1.6'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'

权限
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
package com.example.com.gouwuche;

住方法 

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.example.com.gouwuche.MyView.CarTitleView;
import com.example.com.gouwuche.R;
import com.example.com.gouwuche.adapter.CarShopAdapter;
import com.example.com.gouwuche.bean.Car_child_shop_Bean;
import com.example.com.gouwuche.bean.Car_shop_Bean;
import com.example.com.gouwuche.bean.SelBean;
import com.example.com.gouwuche.innter.CarShopCheckedInterface;
import com.example.com.gouwuche.innter.CarTitleInterface;
import com.example.com.gouwuche.innter.IVInterface;
import com.example.com.gouwuche.innter.NumberAndPrice;
import com.example.com.gouwuche.presenter.Persent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity implements IVInterface {
    @BindView(R.id.ctv_title)
    CarTitleView ctv_title;
    @BindView(R.id.pt_lv)
    ExpandableListView pt_lv;
    @BindView(R.id.btn_toBuy)
    Button btn_toBuy;
    @BindView(R.id.ll_toBuy)
    LinearLayout ll_toBuy;
    @BindView(R.id.cb_all)
    CheckBox cb_all;
    @BindView(R.id.tv_rental)
    TextView tv_rental;
    @BindView(R.id.tv_num)
    TextView tv_num;
    @BindView(R.id.btn_goto)
    Button btn_goto;
    @BindView(R.id.lll_one)
    LinearLayout lll_one;
    @BindView(R.id.cb_alldel)
    CheckBox cb_alldel;
    @BindView(R.id.btn_delete_all)
    Button btn_delete_all;
    @BindView(R.id.l_two)
    LinearLayout l_two;
    private ArrayList<Car_shop_Bean> list_shop;
    private ArrayList<List<Car_child_shop_Bean>> list_shop_chiled;
    private CarShopAdapter carShopAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        initTitle();
        initSelCar();
        initDelCar();
    }
    private void initDelCar() {
        Persent persent = new Persent(MainActivity.this);
        Map<String, String> map = new HashMap<>();
        map.put("uid",1299+"");
        persent.getData(map, "http://120.27.23.105/product/", 0);
    }

    private void initSelCar() {

    }
    //头布局的点击事件
    private void initTitle() {
        ctv_title.setCarTitleView(new CarTitleInterface() {
            boolean b = true;
            public TextView tv_compile;
            //点击编辑----
            @Override
            public void compileClick(View v) {
                b = !b;
                tv_compile = (TextView) v.findViewById(R.id.tv_compile);
                if (b) {
                    tv_compile.setText("编辑");
                    lll_one.setVisibility(View.VISIBLE);
                    l_two.setVisibility(View.GONE);
                    carShopAdapter.notifyDataSetChanged();

                } else {
                    tv_compile.setText("完成");
                    lll_one.setVisibility(View.GONE);
                    l_two.setVisibility(View.VISIBLE);
                    carShopAdapter.notifyDataSetChanged();
                }
            }
        });
    }

    @OnClick({R.id.btn_toBuy, R.id.cb_all, R.id.btn_goto, R.id.cb_alldel, R.id.btn_delete_all})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_toBuy:
                break;
            case R.id.cb_all:
                boolean checked = cb_all.isChecked();
                for (int i = 0; i < list_shop.size(); i++) {
                    list_shop.get(i).setFlag(checked);
                }

                for (List<Car_child_shop_Bean> i : list_shop_chiled) {
                    for (int j = 0; j < i.size(); j++) {
                        i.get(j).setChildCheck(checked);
                    }
                }
                carShopAdapter.notifyDataSetChanged();
                foreach(list_shop_chiled);
                break;
            case R.id.btn_goto:
                break;
            case R.id.cb_alldel:
                boolean checkeds = cb_alldel.isChecked();
                for (int i = 0; i < list_shop.size(); i++) {
                    list_shop.get(i).setFlag(checkeds);
                }

                for (List<Car_child_shop_Bean> i : list_shop_chiled) {
                    for (int j = 0; j < i.size(); j++) {
                        i.get(j).setChildCheck(checkeds);
                    }
                }
                carShopAdapter.notifyDataSetChanged();
                break;
            //点击删除
            case R.id.btn_delete_all:
                ArrayList<Car_shop_Bean> list_new_shop = new ArrayList<Car_shop_Bean>();
                ArrayList<List<Car_child_shop_Bean>> list_new_child = new ArrayList<List<Car_child_shop_Bean>>();
                for (int i = 0; i < list_shop.size(); i++) {
                    Car_shop_Bean car_shop_bean = list_shop.get(i);
                    List<Car_child_shop_Bean> car_child_shop_been = list_shop_chiled.get(i);
                    Boolean flag = list_shop.get(i).getFlag();
                    if (flag) {
                        list_new_shop.add(car_shop_bean);
                        list_new_child.add(car_child_shop_been);
                    }
                    ArrayList<Car_child_shop_Bean> list_child_new = new ArrayList<Car_child_shop_Bean>();
                    for (int j = 0; j < list_shop_chiled.get(i).size(); j++) {
                        Car_child_shop_Bean car_child_shop_bean = list_shop_chiled.get(i).get(j);
                        boolean childCheck = list_shop_chiled.get(i).get(j).isChildCheck();
                        if (childCheck) {
                            list_child_new.add(car_child_shop_bean);
                            int pid = car_child_shop_bean.getPid();
                            Map<String, String> map = new HashMap<String, String>();
                            map.put("pid", pid + "");
                            map.put("uid", 1299 + "");
                            Persent persent = new Persent(MainActivity.this);
                            persent.getData(map, "http://120.27.23.105/product/", 1);
                        }
                    }
                    list_shop_chiled.get(i).removeAll(list_child_new);
                }
                tv_rental.setText("合计:¥" + 0);
                tv_num.setText("数量:" + 0);
                list_shop.removeAll(list_new_shop);
                list_shop_chiled.removeAll(list_new_child);
                carShopAdapter.notifyDataSetChanged();
                initAllData(list_shop);
                break;
        }
    }
    //请求成功
    @Override
    public void Success(Object o,int tag) {
        //查询购物车
        if(tag==0){
            SelBean selBean = (SelBean)o;
            if(selBean!=null){
                List<SelBean.DataBean> data = selBean.getData();
                list_shop = new ArrayList<Car_shop_Bean>();
                list_shop_chiled = new ArrayList<List<Car_child_shop_Bean>>();
                //设置选择状态
                for (int i = 0; i < data.size(); i++) {
                    String sellerName = data.get(i).getSellerName();
                    list_shop.add(new Car_shop_Bean(sellerName, false));

                    List<SelBean.DataBean.ListBean> list = data.get(i).getList();

                    ArrayList<Car_child_shop_Bean> car_shop_been = new ArrayList<>();

                    for (SelBean.DataBean.ListBean childList : list) {
                        int num = childList.getNum();
                        float price = childList.getPrice();
                        String images = childList.getImages();
                        String title = childList.getTitle();
                        int pid = childList.getPid();
                        String[] split = images.toString().split("\\|");
                        car_shop_been.add(new Car_child_shop_Bean(pid, title, num, price, split[0], false));

                    }
                    list_shop_chiled.add(car_shop_been);
                }
                initAllData(list_shop);
                //设置适配器
                carShopAdapter = new CarShopAdapter(MainActivity.this, list_shop, list_shop_chiled);

                cb_all.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        boolean checked = cb_all.isChecked();
                        for (int i = 0; i < list_shop.size(); i++) {
                            list_shop.get(i).setFlag(checked);
                        }

                        for (List<Car_child_shop_Bean> i : list_shop_chiled) {
                            for (int j = 0; j < i.size(); j++) {
                                i.get(j).setChildCheck(checked);
                            }
                        }
                        carShopAdapter.notifyDataSetChanged();
                        foreach(list_shop_chiled);
                    }
                });


                cb_alldel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        boolean checked = cb_alldel.isChecked();
                        for (int i = 0; i < list_shop.size(); i++) {
                            list_shop.get(i).setFlag(checked);
                        }

                        for (List<Car_child_shop_Bean> i : list_shop_chiled) {
                            for (int j = 0; j < i.size(); j++) {
                                i.get(j).setChildCheck(checked);
                            }
                        }
                        carShopAdapter.notifyDataSetChanged();
                    }
                });


                carShopAdapter.setCarShop(new CarShopCheckedInterface() {
                    @Override
                    public void AllChecked(boolean ischeck) {
                        if (!ischeck) {
                            cb_all.setChecked(false);
                            cb_alldel.setChecked(false);
                        } else {
                            cb_all.setChecked(true);
                            cb_alldel.setChecked(true);
                        }
                    }
                });

                carShopAdapter.setNumberAndPrice(new NumberAndPrice() {
                    @Override
                    public void AllNumAndPriceClick(final ArrayList<List<Car_child_shop_Bean>> list_shop_child) {
                        int max = 0;
                        int nums = 0;
                        for (List<Car_child_shop_Bean> list_child : list_shop_child) {
                            for (int i = 0; i < list_child.size(); i++) {
                                boolean childCheck = list_child.get(i).isChildCheck();
                                Car_child_shop_Bean car_child_shop_bean = list_child.get(i);
                                if (childCheck) {
                                    int num = car_child_shop_bean.getNum();
                                    double price = car_child_shop_bean.getPrice();
                                    int prices = (int) price;
                                    max += prices * num;
                                    nums++;
                                }
                            }
                        }
                        tv_rental.setText("合计:¥" + max);
                        tv_num.setText("数量:" + nums);
                    }
                });

                pt_lv.setAdapter(carShopAdapter);
                //让他默认收回
                int count = pt_lv.getCount();
                for (int i = 0; i < count; i++) {
                    pt_lv.expandGroup(i);
                }
                pt_lv.setGroupIndicator(null);
            }
        }else
            //删除购物车
            if(tag==1){
            }
    }
    //请求失败
    @Override
    public void Failed(String message) {

    }

    //判断集合中有没有数据
    private void initAllData(ArrayList<Car_shop_Bean> list_shop) {
        if(list_shop.size()==0){
            ll_toBuy.setVisibility(View.VISIBLE);
        }else{
            ll_toBuy.setVisibility(View.GONE);
            pt_lv.setVisibility(View.VISIBLE);
        }
    }

    //计算总价和数量
    public void foreach(ArrayList<List<Car_child_shop_Bean>> list_shop_child) {
        carShopAdapter.notifyDataSetChanged();
        int max = 0;
        int nums = 0;
        for (List<Car_child_shop_Bean> list_child : list_shop_child) {
            for (int i = 0; i < list_child.size(); i++) {
                boolean childCheck = list_child.get(i).isChildCheck();
                Car_child_shop_Bean car_child_shop_bean = list_child.get(i);
                if (childCheck) {
                    int num = car_child_shop_bean.getNum();
                    double price = car_child_shop_bean.getPrice();
                    int prices = (int) price;
                    max += prices * num;
                    nums++;
                }
            }
        }
        tv_rental.setText("合计:¥" + max);
        tv_num.setText("数量:" + nums);
    }
}


主布局
 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.com.gouwuche.MainActivity">

    <com.example.com.gouwuche.MyView.CarTitleView
        android:id="@+id/ctv_title"
        android:layout_width="match_parent"
        android:layout_height="40dp"/>

    <ExpandableListView
        android:id="@+id/pt_lv"
        android:layout_below="@id/ctv_title"
        android:descendantFocusability = "blocksDescendants"
        android:divider="@null"
        android:scrollbars="none"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </ExpandableListView>


    <LinearLayout
        android:visibility="gone"
        android:orientation="vertical"
        android:id="@+id/ll_toBuy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ImageView

            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <Button
            android:layout_gravity="center"
            android:id="@+id/btn_toBuy"
            android:text="去逛逛"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/lll_one"
        android:orientation="horizontal"
        android:visibility="visible"
        android:background="#FFFFFF"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <CheckBox
            android:layout_gravity="center"
            android:id="@+id/cb_all"
            android:text="全选"
            android:textSize="16dp"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/tv_rental"
            android:layout_marginLeft="20dp"
            android:gravity="center_vertical"
            android:text="合计:¥0"
            android:textSize="20dp"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

        <TextView
            android:id="@+id/tv_num"
            android:layout_marginLeft="10dp"
            android:gravity="center_vertical"
            android:text="数量:0"
            android:textSize="20dp"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

        <Button
            android:id="@+id/btn_goto"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_gravity="right"
            android:gravity="center"
            android:layout_height="match_parent"
            android:background="#cc0000"
            android:text="去结算"
            android:textColor="#FFFF"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/l_two"
        android:orientation="horizontal"
        android:visibility="gone"
        android:background="#FFFFFF"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <CheckBox
            android:layout_gravity="center"
            android:id="@+id/cb_alldel"
            android:text="全选"
            android:textSize="16dp"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" />

        <TextView
            android:layout_marginLeft="20dp"
            android:gravity="center_vertical"
            android:text="分享"
            android:textSize="20dp"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

        <TextView
            android:layout_marginLeft="10dp"
            android:gravity="center_vertical"
            android:text="移出关注"
            android:textSize="20dp"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />

        <Button
            android:id="@+id/btn_delete_all"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_gravity="right"
            android:gravity="center"
            android:layout_height="match_parent"
            android:text="删除"
            android:textColor="#FFFF"
            android:textSize="20dp" />
    </LinearLayout>
</RelativeLayout>
car_shop_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:background="#F0F2F5"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:background="#F7FBF7"
        android:layout_width="match_parent"
        android:layout_height="200dp">
        <CheckBox
            android:id="@+id/rb_commodity"
            android:layout_gravity="center"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" />
        <LinearLayout
            android:layout_marginLeft="10dp"
            android:orientation="horizontal"
            android:layout_width="0dp"
            android:layout_weight="9"
            android:layout_height="300dp">
            <ImageView
                android:gravity="center"
                android:id="@+id/iv_commodityImg"
                android:layout_width="80dp"
                android:layout_height="80dp" />
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <TextView
                    android:id="@+id/tv_commodityName"
                    android:gravity="center"
                    android:layout_width="match_parent"
                    android:layout_weight="1"
                    android:layout_height="0dp" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1">

                    <TextView
                        android:textSize="20dp"
                        android:id="@+id/tv_commodityPrice"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_marginTop="20dp"
                        android:layout_height="wrap_content"
                        android:text="ooooooo" />

                    <LinearLayout
                        android:id="@+id/ll_num"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:gravity="right"
                        android:layout_height="match_parent"
                        >

                        <Button
                            android:id="@+id/btn_delete"
                            android:layout_width="0dp"
                            android:layout_weight="1"
                            android:layout_height="wrap_content"/>

                        <EditText
                            android:id="@+id/et_num"
                            android:gravity="center"
                            android:layout_width="0dp"
                            android:layout_weight="2"
                            android:layout_height="wrap_content" />

                        <Button
                            android:id="@+id/btn_add"
                            android:layout_width="0dp"
                            android:layout_weight="1"
                            android:layout_height="wrap_content" />
                    </LinearLayout>

                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
car_shop_one_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_marginTop="20dp"
        android:background="#F8F8F8"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <CheckBox
            android:id="@+id/rb_shop"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/tv_shopName"
            android:layout_marginLeft="10dp"
            android:textSize="20dp"
            android:layout_width="0dp"
            android:layout_weight="9"
            android:layout_height="wrap_content">

        </TextView>
    </LinearLayout>

</LinearLayout>
car_title_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:text="购物车"
        android:textSize="24dp"
        android:gravity="center"
        android:paddingLeft="80dp"
        android:layout_width="0dp"
        android:layout_weight="7"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_marginLeft="50dp"
        android:id="@+id/tv_compile"
        android:text="编辑"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="right"
        android:textSize="18dp" />
</LinearLayout>
adapter层
package com.example.com.gouwuche.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.example.com.gouwuche.R;
import com.example.com.gouwuche.bean.Car_child_shop_Bean;
import com.example.com.gouwuche.bean.Car_shop_Bean;
import com.example.com.gouwuche.innter.CarShopCheckedInterface;
import com.example.com.gouwuche.innter.NumberAndPrice;
import com.example.com.gouwuche.innter.ShopNumInterface;


import java.util.ArrayList;
import java.util.List;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class CarShopAdapter extends BaseExpandableListAdapter {
    private Context context;
    private ArrayList<Car_shop_Bean> list_shop;
    private ArrayList<List<Car_child_shop_Bean>> list_shop_child;
    private CarShopCheckedInterface carShopCheckedInterface;
    private ShopNumInterface shopNumInterface;
    private NumberAndPrice numberAndPrice;
    private TextView tv_shopName;
    private ImageView iv_commodityImg;
    private TextView tv_commodityName;
    private TextView tv_commodityPrice;
    private Button btn_delete;
    private Button btn_add;
    private EditText et_num;
    private int shopNum = 0;
    private int allNum = 0;
    private int allPrice = 0;
    private Button btn_delete_only;

    public CarShopAdapter(Context context, ArrayList<Car_shop_Bean> list_shop, ArrayList<List<Car_child_shop_Bean>> list_shop_child) {
        this.context = context;
        this.list_shop = list_shop;
        this.list_shop_child = list_shop_child;
    }
    public void setCarShop(CarShopCheckedInterface carShopCheckedInterface){
        this.carShopCheckedInterface = carShopCheckedInterface;
    }
    public void setShopList(ShopNumInterface shopNumInterface){
        this.shopNumInterface = shopNumInterface;
    }
    public void setNumberAndPrice(NumberAndPrice numberAndPrice){
        this.numberAndPrice = numberAndPrice;
    }
    @Override
    public int getGroupCount() {
        return list_shop.size();
    }

    @Override
    public int getChildrenCount(int i) {
        return list_shop_child.get(i).size();
    }

    @Override
    public Object getGroup(int i) {
        return list_shop.get(i);
    }

    @Override
    public Object getChild(int i, int i1) {
        return list_shop_child.get(i).get(i1);
    }

    @Override
    public long getGroupId(int i) {
        return i;
    }

    @Override
    public long getChildId(int i, int i1) {
        return i1;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
        final Car_shop_Bean car_shop_bean1 = list_shop.get(i);
        final List<Car_child_shop_Bean> car_child_shop_been = list_shop_child.get(i);
        view = View.inflate(context, R.layout.car_shop_one_fragment, null);
        final CheckBox rb_shop = (CheckBox)view.findViewById(R.id.rb_shop);
        tv_shopName = (TextView)view.findViewById(R.id.tv_shopName);
        rb_shop.setChecked(car_shop_bean1.getFlag());
        tv_shopName.setText(car_shop_bean1.getName());
        rb_shop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("---------点击:",rb_shop.isChecked()+"");
                list_shop.get(i).setFlag(rb_shop.isChecked());
                boolean checked = rb_shop.isChecked();
                car_shop_bean1.setFlag(checked);
                boolean a = true;
                for (int j = 0; j < list_shop.size(); j++) {
                    Boolean flag = list_shop.get(j).getFlag();
                    if(flag==false){
                        a = false;
                        carShopCheckedInterface.AllChecked(a);
                        break;
                    }else{
                        a = true;
                        carShopCheckedInterface.AllChecked(a);
                    }
                }
                for (int j = 0; j < car_child_shop_been.size(); j++) {
                    car_child_shop_been.get(j).setChildCheck(rb_shop.isChecked());
                }
                notifyDataSetChanged();
                for (Car_child_shop_Bean list_child:car_child_shop_been){
                    numberAndPrice.AllNumAndPriceClick(list_shop_child);
                }
            }
        });
        return view;
    }

    @Override
    public View getChildView(final int i, final int i1, final boolean b, View view, ViewGroup viewGroup) {
        final Car_shop_Bean car_shop_bean = list_shop.get(i);
        final Car_child_shop_Bean car_child_shop_bean = list_shop_child.get(i).get(i1);
        view = View.inflate(context, R.layout.car_shop_fragment, null);
        final CheckBox rb_commodity = (CheckBox)view.findViewById(R.id.rb_commodity);
        iv_commodityImg = (ImageView)view.findViewById(R.id.iv_commodityImg);
        tv_commodityName = (TextView)view.findViewById(R.id.tv_commodityName);
        tv_commodityPrice = (TextView)view.findViewById(R.id.tv_commodityPrice);
        btn_delete = (Button)view.findViewById(R.id.btn_delete);
        btn_add = (Button)view.findViewById(R.id.btn_add);
        et_num = (EditText)view.findViewById(R.id.et_num);
        et_num.setText(car_child_shop_bean.getNum()+"");
        rb_commodity.setChecked(car_child_shop_bean.isChildCheck());
        tv_commodityName.setText(car_child_shop_bean.getTitle());
        Glide.with(context).load(car_child_shop_bean.getImages()).into(iv_commodityImg);
        tv_commodityPrice.setText("¥:"+car_child_shop_bean.getPrice());
        btn_delete.setText("—");
        btn_add.setText("+");
        notifyDataSetChanged();


        rb_commodity.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                car_child_shop_bean.setChildCheck(rb_commodity.isChecked());
                boolean flag = true;
                for (int j = 0; j < list_shop_child.get(i).size(); j++) {
                    if(list_shop_child.get(i).get(j).isChildCheck()==false) {
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    list_shop.get(i).setFlag(true);
                }else{
                    list_shop.get(i).setFlag(false);
                }
                boolean c = true;
                for (int j = 0; j < list_shop.size(); j++) {
                    if(list_shop.get(j).getFlag() == false){
                        c = false;
                        break;
                    }else{
                        c = true;
                    }
                }
                if(c){
                    carShopCheckedInterface.AllChecked(true);
                }else{
                    carShopCheckedInterface.AllChecked(false);
                }

                Log.e("-----取到的索引:",i1+"");
                numberAndPrice.AllNumAndPriceClick(list_shop_child);
                notifyDataSetChanged();
            }
        });

        btn_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean childCheck = car_child_shop_bean.isChildCheck();
                int num1 = car_child_shop_bean.getNum();
                num1++;
                car_child_shop_bean.setNum(num1);
                numberAndPrice.AllNumAndPriceClick(list_shop_child);
                notifyDataSetChanged();
            }
        });
        final boolean childCheck = car_child_shop_bean.isChildCheck();
        btn_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int num1 = car_child_shop_bean.getNum();
                num1--;
                if(num1<1){
                    car_child_shop_bean.setNum(1);
                    Toast.makeText(context,"不能再少了···",Toast.LENGTH_SHORT).show();
                }else{
                    car_child_shop_bean.setNum(num1);
                }
                numberAndPrice.AllNumAndPriceClick(list_shop_child);
                notifyDataSetChanged();
            }
        });
        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return true;
    }
}
bean类
package com.example.com.gouwuche.bean;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class AddBean {

    /**
     * msg : 加购成功
     * code : 0
     */

    private String msg;
    private String code;

    public static AddBean objectFromData(String str) {

        return new Gson().fromJson(str, AddBean.class);
    }

    public static AddBean objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), AddBean.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<AddBean> arrayAddBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<AddBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<AddBean> arrayAddBeanFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<AddBean>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
package com.example.com.gouwuche.bean;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class Car_child_shop_Bean {
    private int pid;
    private String title;
    private int num;
    private double price;
    private String images;
    private boolean childCheck;

    public Car_child_shop_Bean(int pid, String title, int num, double price, String images, boolean childCheck) {
        this.pid = pid;
        this.title = title;
        this.num = num;
        this.price = price;
        this.images = images;
        this.childCheck = childCheck;
    }

    public int getPid() {
        return pid;
    }

    public void setPid(int pid) {
        this.pid = pid;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getImages() {
        return images;
    }

    public void setImages(String images) {
        this.images = images;
    }

    public boolean isChildCheck() {
        return childCheck;
    }

    public void setChildCheck(boolean childCheck) {
        this.childCheck = childCheck;
    }
}
package com.example.com.gouwuche.bean;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class Car_shop_Bean {
    private String name;
    private boolean flag;

    public Car_shop_Bean(String name, Boolean flag) {
        this.name = name;
        this.flag = flag;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getFlag() {
        return flag;
    }

    public void setFlag(Boolean flag) {
        this.flag = flag;
    }
}
package com.example.com.gouwuche.bean;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class DelBean {
    private String msg;
    private String code;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
package com.example.com.gouwuche.bean;

import java.util.List;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class SelBean {
    private String msg;
    private String code;
    private List<DataBean> data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public static class DataBean {

        private String sellerName;
        private String sellerid;
        private List<ListBean> list;

        public String getSellerName() {
            return sellerName;
        }

        public void setSellerName(String sellerName) {
            this.sellerName = sellerName;
        }

        public String getSellerid() {
            return sellerid;
        }

        public void setSellerid(String sellerid) {
            this.sellerid = sellerid;
        }

        public List<ListBean> getList() {
            return list;
        }

        public void setList(List<ListBean> list) {
            this.list = list;
        }

        public static class ListBean {

            private double bargainPrice;
            private String createtime;
            private String detailUrl;
            private String images;
            private int num;
            private int pid;
            private float price;
            private int pscid;
            private int selected;
            private int sellerid;
            private String subhead;
            private String title;

            public double getBargainPrice() {
                return bargainPrice;
            }

            public void setBargainPrice(double bargainPrice) {
                this.bargainPrice = bargainPrice;
            }

            public String getCreatetime() {
                return createtime;
            }

            public void setCreatetime(String createtime) {
                this.createtime = createtime;
            }

            public String getDetailUrl() {
                return detailUrl;
            }

            public void setDetailUrl(String detailUrl) {
                this.detailUrl = detailUrl;
            }

            public String getImages() {
                return images;
            }

            public void setImages(String images) {
                this.images = images;
            }

            public int getNum() {
                return num;
            }

            public void setNum(int num) {
                this.num = num;
            }

            public int getPid() {
                return pid;
            }

            public void setPid(int pid) {
                this.pid = pid;
            }

            public float getPrice() {
                return price;
            }

            public void setPrice(float price) {
                this.price = price;
            }

            public int getPscid() {
                return pscid;
            }

            public void setPscid(int pscid) {
                this.pscid = pscid;
            }

            public int getSelected() {
                return selected;
            }

            public void setSelected(int selected) {
                this.selected = selected;
            }

            public int getSellerid() {
                return sellerid;
            }

            public void setSellerid(int sellerid) {
                this.sellerid = sellerid;
            }

            public String getSubhead() {
                return subhead;
            }

            public void setSubhead(String subhead) {
                this.subhead = subhead;
            }

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }
        }
    }
}
inner接口
package com.example.com.gouwuche.innter;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public interface CarShopCheckedInterface {
    void AllChecked(boolean ischeck);
}
package com.example.com.gouwuche.innter;

import android.view.View;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public interface CarTitleInterface {
    void compileClick(View v);
}
 
package com.example.com.gouwuche.innter;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public interface IVInterface {
    void Success(Object o, int tag);
    void Failed(String message);
}
package com.example.com.gouwuche.innter;



import com.example.com.gouwuche.bean.Car_child_shop_Bean;

import java.util.ArrayList;
import java.util.List;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public interface NumberAndPrice {
    void AllNumAndPriceClick(ArrayList<List<Car_child_shop_Bean>> list_shop_child);
}
package com.example.com.gouwuche.innter;



import com.example.com.gouwuche.bean.Car_child_shop_Bean;

import java.util.List;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public interface ShopNumInterface {
    void ListClick(List<Car_child_shop_Bean> car_child_shop_been);
}
model层
package com.example.com.gouwuche.model;

import android.util.Log;

import com.example.com.gouwuche.bean.DelBean;
import com.example.com.gouwuche.bean.SelBean;
import com.example.com.gouwuche.presenter.Persent;
import com.example.com.gouwuche.utils.RetrofitUtils;

import java.util.Map;

import io.reactivex.Flowable;

/**
 * Created by linmeihui on 2018/4/25.
 */

public class Model implements ModelInterface {

    private Persent persent;
    private Flowable<SelBean> selFlowable;
    private Flowable<DelBean> delFlowable;

    public Model(Persent persent){
        this.persent = persent;
    }
    @Override
    public void getData(Map<String, String> map, String uri, int tag) {
        Log.e("-------M层的TAG值:",tag+"----");
        if(tag==0){
            selFlowable = RetrofitUtils.getInstance(map, uri, tag).getSelFlowable();
            persent.getSelCar(selFlowable,tag);
        }else
        if(tag==1){
            delFlowable = RetrofitUtils.getInstance(map, uri, tag).getDelFlowable();
            if(delFlowable!=null) {
                persent.getDelCar(delFlowable, tag);
            }
        }
    }
}
package com.example.com.gouwuche.model;

import java.util.Map;

/**
 * Created by linmeihui on 2018/4/25.
 */

public interface ModelInterface {
    void getData(Map<String, String> map, String uri, int tag);
}
MyView层
package com.example.com.gouwuche.MyView;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.com.gouwuche.R;
import com.example.com.gouwuche.innter.CarTitleInterface;


/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class CarTitleView extends LinearLayout implements View.OnClickListener{

    private CarTitleInterface carTitleInterface;
    private ImageView title_address;
    private TextView tv_compile;
    private ImageView iv_message;

    public void setCarTitleView(CarTitleInterface carTitleInterface){
        this.carTitleInterface = carTitleInterface;
    }

    public CarTitleView(Context context) {
        this(context,null);
    }

    public CarTitleView(Context context,  AttributeSet attrs) {
        this(context, attrs,0);
    }

    public CarTitleView(Context context,  AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        View.inflate(context, R.layout.car_title_fragment,this);
        initView();
    }

    private void initView() {
        tv_compile = (TextView)findViewById(R.id.tv_compile);
        tv_compile.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tv_compile:
                Log.e("-------点击事件:","--------");
                carTitleInterface.compileClick(view);
                break;
        }
    }
}
presenter层
package com.example.com.gouwuche.presenter;



import com.example.com.gouwuche.bean.DelBean;
import com.example.com.gouwuche.bean.SelBean;
import com.example.com.gouwuche.innter.IVInterface;
import com.example.com.gouwuche.model.Model;
import com.example.com.gouwuche.model.ModelInterface;

import java.util.Map;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.DefaultSubscriber;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class Persent implements PersentInterface{

    private IVInterface ivInterface;
    public Persent(IVInterface ivInterface){
        this.ivInterface = ivInterface;
    }
    @Override
    public void getData(Map<String, String> map, String uri, int tag) {
        ModelInterface modelInterface = new Model(this);
        modelInterface.getData(map,uri,tag);
    }

    //得到主页的网络请求
    public void getSelCar(Flowable<SelBean> builder, final int tag){
        builder.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new DefaultSubscriber<SelBean>() {
                    @Override
                    public void onNext(SelBean selBean) {
                        if(selBean!=null){
                            ivInterface.Success(selBean,tag);
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        ivInterface.Failed(t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    //得到详情的网络请求
    public void getDelCar(Flowable<DelBean> delBeanFlowable, final int tag){
        delBeanFlowable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new DefaultSubscriber<DelBean>() {
                    @Override
                    public void onNext(DelBean delBean) {
                        if (delBean!=null){
                            ivInterface.Success(delBean,tag);
                        }
                    }

                    @Override
                    public void onError(Throwable t) {
                        ivInterface.Failed(t.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
package com.example.com.gouwuche.presenter;

import java.util.Map;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public interface PersentInterface {
    void getData(Map<String, String> map, String uri, int tag);
}
utils层
package com.example.com.gouwuche.utils;

import java.io.IOException;

import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class Logger implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();
        HttpUrl url=original.url().newBuilder()
                .addQueryParameter("source","android")
                .build();
        //添加请求头
        Request request = original.newBuilder()
                .url(url)
                .build();
        return chain.proceed(request);
    }
}
package com.example.com.gouwuche.utils;

import android.util.Log;


import com.example.com.gouwuche.bean.DelBean;
import com.example.com.gouwuche.bean.SelBean;
import com.google.gson.Gson;

import java.util.Map;

import io.reactivex.Flowable;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public class RetrofitUtils {
    //单例模式
    private static volatile RetrofitUtils instance;
    private Flowable<SelBean> selBeanFlowable;
    private Flowable<DelBean> delBeanFlowable;

    private RetrofitUtils(Map<String,String> map, String uri, int tag){
        OkHttpClient build = new OkHttpClient.Builder()
                .addInterceptor(new Logger())
                .build();

        Retrofit build1 = new Retrofit.Builder()
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create(new Gson()))
                .client(build)
                .baseUrl(uri)
                .build();

        RxJava rxJava = build1.create(RxJava.class);
        Log.e("---TAG值:",tag+"");
        if(tag==0){
            selBeanFlowable = rxJava.Sel_Car(map);
        }else
        if(tag==1){
            delBeanFlowable = rxJava.Del_Car(map);
        }
    };

    public static RetrofitUtils getInstance(Map<String,String> map,String uri,int tag){
        instance = new RetrofitUtils(map,uri,tag);
        return instance;
    }

    public Flowable<SelBean> getSelFlowable(){
        return selBeanFlowable;
    }

    public Flowable<DelBean> getDelFlowable(){
        return delBeanFlowable;
    }

}
package com.example.com.gouwuche.utils;



import com.example.com.gouwuche.bean.AddBean;
import com.example.com.gouwuche.bean.DelBean;
import com.example.com.gouwuche.bean.SelBean;

import java.util.Map;

import io.reactivex.Flowable;
import retrofit2.http.GET;
import retrofit2.http.QueryMap;

/**
 * author:Created by jiangkerun on 2018/4/23.
 */
public interface RxJava {

    @GET("product/getCarts")
    Flowable<SelBean> Sel_Car(@QueryMap Map<String, String> map);

    @GET("product/deleteCart")
    Flowable<DelBean> Del_Car(@QueryMap Map<String, String> map);

    @GET("product/addCart")
    Flowable<AddBean> Add_Car(@QueryMap Map<String, String> map);


}



PHP购物车 这个购物车相对来说比较简单,用于短暂存储,并没有存储到数据库,购物车对于爱网购的人来说简直是熟悉的不能再熟悉了,在写购物车之前,我们首先要构思一下,我们需要先从数据库中调出一张表格,这里我用的是fruit表,其次是登录表,我用的是login表,用来调用户名和密码的,所有的都准备好之后就要考虑放入购物车是会有三种情况的: 第一种情况:购物车里面什么都没有 第二种情况:购物车里面已经有此产品了,再次加... 阅读详情

相关推荐

javaweb购物车

java web开发_购物车功能实现 之前没有接触过购物车的东东,也不知道购物车应该怎么做,所以在查询了很多资料,总结一下购物车的功能实现。 查询的资料,找到三种方法: 1.用cookie实现购物车; 2.用session实现购物车; 3.用cookie和数据库(购物车信息持久化)实现购物车; ==============================================...

小橙子 2048

如何实现购物车功能(购物车在数据库中)?

上一篇文章提到,将购物车放入session中的方法,这里来帮大家讲购物车放在数据库中,那么到底如何实现呢? 同样,购物车放在数据库中也应该实现8中操作: 1.向购物车添加商品,(首先,应该判断该商品是否在购物车中已经存在,若存在,该商品数量+1,若不存在,则将该商品加入购物车并数量设置为1) 2.修改商品的数量(请求一个servlet,并根据该商品的某个唯一属性修改其数量) 3.删除商品(通过请求...

潇洒不放纵的博客 2万+

基于redis购物车

基于redis的购物车流程(不是很详细)请勿喷哦!!>_< 我在之前的项目中,做过购物车的功能,当时从表设计到最后用postman进行接口的测试,都是我负责做的。 考虑到用户操作购物车的性能问题,我当时做的是基于redis的购物车,将购物车的所有数据都存储到redis中。 当时用了redis中的hash结构来存储所有用户购物车的数据,咱们都知道在使用hash的时候,涉及到key,fie...

javazongjiezhe的博客 797

MVC购物车

目录 1.什么是MVC? 2.MVC购物车案例 2.1.数据库的设计 2.2.需要开发的界面 2.3.购物车样式设计 2.4.购物车具体实现代码 第一步:进入购物首页页面绑定数据 第二步:点击加入购物车进入我的购物车页面 第三步:加入到我的购物车,对商品数量的更改以及商品总价的计算 第四步:实现删除我的购物车商品的方法 1.什么是MVC? MVC全名是Model(模型) View(视图) Controller(控制器)。是一种软件设计典范,用一种业务逻辑、数据、...

weixin_62332711的博客 3001

JavaWEB【session购物车部分功能讲解】

如需温习上一节的内容,请点击下方链接进行页面跳转: Javaweb之JSP标准标签&购物车项目布置_云彩123的博客-优快云博客https://blog.youkuaiyun.com/m0_64522859/article/details/124089892 目录 需实现的功能: 1.商品加入购物车 2.购物车商品的删除 (1)点击删除按钮 将当前点击的id传递到do页面 (2)获取session 遍历 利用集合remove进行移除 (3)重新进行保存 3.购...

m0_64522859的博客 1819

告别JSON!Anthropic发布Tool Calling 2.0,Agent上下文消耗骤降80%

Anthropic发布ToolCalling 2.0更新,彻底革新AI Agent开发模式。四大核心特性:1)程序化工具调用,允许模型直接输出可执行代码替代JSON交互,降低30-50%Token消耗;2)动态网页过滤,自动清洗网页内容减少24%无效信息;3)工具搜索机制,按需加载工具定义,最高优化80%上下文窗口;4)工具使用示例,通过Few-Shot示范提升复杂表单处理准确率至90%。这一升级将Agent范式从"大模型作为路由"推进到"大模型作为引擎",但需注意代

老孙 | Ethan Sun 的博客:AI 智能体与 AI 原生软件的工程实践 799

淘宝购物车的测试用例

关于淘宝购物车的测试用例可以从以下几个方面来进行考虑。 1.界面测试 打开淘宝购物车页面后,页面的布局是否合理,是否完整。 不同卖家的商品在不同的table区域显示,区分明显。 页面的功能按钮可以正常显示。 商品的最下方显示失效宝贝。 页面的最低端显示“你可能喜欢” 向下滑动页面,在购物车顶端展示“购物车”。 购物车中如果存在有商品降价、库存不足、限购件数等,在商品详情的下面,会有对应的字体展示。 2.基本功能 购物车页面的所有连接是否正常。 从商品信息页面添加的商品能显示在购物车中。 若未登录,点击

matilda_art的博客 1万+

Versal ACAP NoC实战:像理解计算机网络一样配置AXI NoC,打通PS与PL数据通路

本文深入探讨了Versal ACAP NoC的配置与优化,通过计算机网络类比解析NoC架构,详细介绍了在VD100开发板上配置AXI NoC实现PS与PL数据交互的实战步骤。文章涵盖NoC组件功能、Vivado配置技巧、性能优化方法及常见问题解决方案,帮助开发者高效打通Versal芯片的数据通路。

weixin_42665255的博客 294

关于电商项目的购物车总结和购物车实现

关于电商项目的购物车总结和购物车实现 本文中简述的购物车模仿京东的模式,用户没有登录,也可进行购物车的操作,如果用户登录了,则在数据库中操作购物车。我们基于存放在cookies里面。 先看添加到购物车的按钮 看这个界面是因为,如果放代码,因为代码中很多的数据是与其他相互关联的,所以只要理解了购物车的模式和方法,实现起来就没有那么复杂了,这里放一下,加入购物车需要哪些参数 <form...

chen_long的博客 1万+

ORCA(动态避障)算法

A物体沿着向量v1和v2移动,刚好能和B擦肩而过,不会发生碰撞;若V1和V2的夹角再小一点的话就一定会发生碰撞。A的速度为V1,B的速度为V2,A对于B的相对速度(也就是我们把B看做静止,A的速度)就是V1-V2。,那么怎么判定A的速度向量是不是在碰撞区域内呢?这就需要用A相对于B的速度来判定。红线画出来的锥形区域就是A相对于B的。

u012861978的专栏 4769

别慌!Oracle MOS登录页面大变样?5分钟搞定新旧账号登录全流程

本文详细解析Oracle MOS登录页面改版后的新旧账号登录流程,帮助用户快速适应账号体系变革。针对传统MOS账号和OCI账号的不同应用场景,提供5分钟内完成无缝切换的实用指南,包括登录步骤、书签设置和密码管理策略,助力数据库管理用户高效访问Oracle技术支持资源。

weixin_30275415的博客 519

购物车的实现及使用redis存储购物车数据

实体类有四个: Product、User、Cart、CartItem //Product实体类 @Data @AllArgsConstructor @NoArgsConstructor @Accessors(chain = true) public class Product implements Serializable { private Integer id; p...

zhang33565417的博客 9952

Figma做原型设计一篇教会你,全栈软件开发必备技能,前后端岗位锐减找工作的底牌

本文介绍了使用Figma进行前端应用原型设计的方法与优势。Figma作为主流设计工具,能够满足大多数应用系统的原型设计需求,强调系统设计应保持简洁合理。文章详细说明了Figma的基本操作流程,包括创建Frame页面、组件使用、交互设置等核心功能,并指出命名规范的重要性。同时对比了Axure、墨刀等其他设计工具的特点,建议根据具体需求选择合适的平台。最后强调原型设计主要关注交互功能展示,业务逻辑应通过需求文档表述。整体而言,Figma凭借其简洁高效的特点,已成为原型设计的优选工具。

有问题或资源连接有缺失的可以私信公众号新潮看世界获取 463

电商项目-购物车(合并购物车问题)

1.添加购物车分析 1.商品详情页添加购物车 2.商品详情页添加购物车时,先判断用户是否登陆,如果没有登录,在判断是否存在临时用户,如果cookie中也没有临时用户,则生成临时用户。 3.购物车商品与临时用户ID关联,当用户登录后,将临时用户ID的购物车商品与登录用户id的商品合并。 2.临时用户处理 1.因为userId我们是从网关统一传递过来的,那么临时用户ID我们也可以从网关传递过来,改造网关。 2.在过滤器中添加一个获取当前用户临时ID的方法 3.先

weixin_45596022的博客 5570

输入过欠压保护电路分析

输入过欠压保护电路仿真分析

HW-BASE的博客 6920

QGIS安装与使用教程

QGIS安装与使用教程

weixin_46713695的博客 2万+

vue购物车开发逻辑

vue开发中购物车逻辑总结 添加购物车后同步修改购物车徽标的显示数量 1、因为涉及到组件之间的传值,我将需要传递的数据,放在Vuex中,可以方便供整个Vue实例使用/修改。 import Vuex from 'vuex' Vue.use(Vuex) const store = new Vuex.Store({}) 2、使用change事件监听购买数量input框的修改,使用$emit触发父组件...

Fxhani的博客 1770

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

商城-购物车-购物车功能分析

商城-购物车-搭建购物车服务2.购物车功能分析2.1.需求2.2.流程图 2.购物车功能分析 2.1.需求 需求描述: 用户可以在登录状态下将商品添加到购物车 放入数据库 放入redis(采用) 用户可以在未登录状态下将商品添加到购物车 放入localstorage 用户可以使用购物车一起结算下单 用户可以查询自己的购物车 用户可以在购物车中修改购买商品的数量。 用户可以在购物车中删...

shenzhen_zsw的专栏 4953

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

PHP购物车功能

网上的购物网站很多,淘宝、当当 数不胜数,一个好的购物网站当然要有个购物车 car.php  主页,显示所有的商品分类   session_start();//开启session环境    //判断该用户是否点击过“放入购物车”按钮    if(isset($_POST['cart'])){   //循环方式赋值           foreach($_POST['cart'

7F 5307

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

17_购物车删除商品与清空购物车

购物车删除商品与清空购物车 步骤分析 1)步骤分析 从购物车中删除商品 在购物车页面上,点击删除:${path}/cart/remove?pid=xxx 在CartServlet处理删除路径 先获取商品pid 获取购物车 删除购物车项 重定向到/jsp/cart.jsp 清空购物车 在购物车页面上,有一个清空购物车的连接:${path}/cart/clear 在CartServlet中处...

方圆几里 8956

day16_购物车(添加购物车,购物车列表查询,删除购物车商品,更新选中商品状态,完成购物车商品的全选,清空购物车)

步骤如下所示:1、spzx-service-client模块创建:在spzx-parent下面创建该子模块spzx-service-client,并导入如下依赖:-- openfeign依赖 --> < dependency > < groupId > org.springframework.cloud < artifactId > spring-cloud-starter-openfeign

小丁的博客 2023

uni-app购物车的实现

前言 在电商项目中,购物车是电商项目的灵魂,支付是电商项目的血液,电商项目中离不开购物车。 开始了 第一步 加入购物车 在vuex中新建一个store.js文件,并且在store.js 文件中添加如下4个初识化Store的实例对象 // 1. 导入 Vue 和 Vuex import Vue from 'vue' import Vuex from 'vuex' // 2. 将 Vuex 安装为 Vue 的插件 Vue.use(Vuex) // 3. 创建 Store 的实例对象 const stor

小白在线学前端的博客 3123

Java购物车

1. 创建购物车实体类,模拟购物车功能(内部使用HashMap) 需求: 1) 添加商品到购物车(输入商品的编号和数量) 2) 删除商品(删除购物车中的指定购物项) 3) 修改商品(修改商品的数量) 4) 显示所购买的商品信息(按购买商品的总价进行升序显示) 之前老师说了两个方法,所以我就两个方法都写上来。 首先是不用HashMap的 测试类 public class

weixin_38839261的博客 2174

购物车列表设计

购物车排序后缓存key cart_order_shop:用户ID:地区码,如果地区码没有选择默认NO_AREA。购物车排序后缓存key cart_order_shop:用户ID:地区码,如果地区码没有选择默认NO_AREA。3、CartShopProcessor 店铺信息、店铺销售区域信息查询组装,销售区域校验处理、店铺状态校验处理。cart_order_sku:地区码:用户ID ,如果地区码没有选择默认NO_AREA。value:用户购物车店铺结果显示列表json。5、用户购物车店铺结果显示列表。

liangshf520的博客 933

对淘宝购物车进行测试用例设计

验证用户能否将商品添加到购物车后,购物车内的商品信息(如名称、价格、数量等)是否正确。验证用户能否将商品添加到购物车后,购物车内的商品价格总和是否正确。验证用户能否将商品添加到购物车后,购物车内的商品数量是否正确。2.4 验证用户能否在查看购物车时,调整商品的数量或删除商品。验证用户能否在添加商品到购物车时,选择商品的规格或颜色。2.5 验证用户能否在查看购物车时,编辑商品的规格或颜色。验证用户能否在添加商品到购物车时,输入商品的数量。

double222222的博客 2724
上一篇: 京东分类
下一篇: 登录注册
ch5211314
博客等级 码龄9年 21粉丝 83原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值