计算机毕业设计之android平台的出租打车软件app

  • Post author:
  • Post category:其他




基于安卓平台出租打车软件app

背景需求:

城市生活中,出租车已经成为人们日常出行经常使用的交通工具。但城市里每天上下班时间人流较大,给人的出行带来不便,有些偏远的地区也许只有少数的公交车,上下班时人数又比较多,上不了公交,而这些地方招出租车也比较困难。针对上下班高峰期以及偏远地区打的难的情况推出的一款基于android平台的打车软件,并提供打车功能,节约时间和出行成本。


本系统可分为三个端: 用户端,车主端,管理远端


(用户端):

登录,注册,发布订单,我的订单,支付(微信,支付宝),公告,修改密码,反馈意见,个人中心

在这里插入图片描述

在这里插入图片描述


(车主端):

登录,注册,接单,我的接单列表,个人中心,对用户订单反馈意见,公告,个人信息,修改密码

在这里插入图片描述


(管理员端):

登录,注册,用户管理,反馈管理(收入,支出),统计管理,公告管理

在这里插入图片描述

在这里插入图片描述


核心代码:

发布订单

/**
 * 发布订单
 */
public class PushActivity extends BaseActivity<ActivityPushBinding> {

    @Override
    protected ActivityPushBinding getViewBinding() {
        return ActivityPushBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void setListener() {


        mBinding.push.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String startAddress = mBinding.startAdress.getText().toString().trim();
                String endAddress = mBinding.endAdress.getText().toString().trim();
                String push_time = mBinding.timepicker.getText().toString().trim();
                if (TextUtils.isEmpty(startAddress) || TextUtils.isEmpty(endAddress) || TextUtils.isEmpty(push_time)) {
                    showToast("请完善信息");
                } else {
                    String price = Tools.getPrice();
                    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                    builder.setTitle("确定要发布吗?");
                    builder.setMessage("预计" + price + "元");
                    builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {

                        }
                    });
                    builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            push(startAddress, endAddress, price, push_time);
                        }
                    });
                    builder.show();
                }


            }
        });

        Calendar startDate = Calendar.getInstance();
        Calendar endDate = Calendar.getInstance();
        //正确设置方式 原因:注意事项有说明
        endDate.set(2100, 11, 31);
        mBinding.timepicker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TimePickerView pvTime = new TimePickerBuilder(mContext, new OnTimeSelectListener() {
                    @Override
                    public void onTimeSelect(Date date, View v) {
                        mBinding.timepicker.setText(getTime(date));

                    }
                })
                        .setType(new boolean[]{false, true, true, true, true, false})// 默认全部显示
                        .setLabel("年", "月", "日", "时", "分", "秒")//默认设置为年月日时分秒
                        .setRangDate(startDate, endDate)//起始终止年月日设定
                        .build();

                pvTime.show();
            }
        });

    }

    /**
     * 发布
     */
    public void push(String start_address, String end_address, String order_price, String push_time) {
        UserInfo userInfo = ApiConstants.getUserInfo();
        if (null != userInfo) {
            OkGo.<String>get(ApiConstants.PUSH_URL)
                    .params("push_username", userInfo.getUsername())
                    .params("mobile", userInfo.getMobile())
                    .params("start_address", start_address)
                    .params("end_address", end_address)
                    .params("order_price", order_price)
                    .params("push_state", 0)
                    .params("push_time", push_time)
                    .execute(new HttpStringCallback(this) {
                        @Override
                        protected void onSuccess(String msg, String response) {
                            showToast(msg);
                            setResult(1000);
                            finish();
                        }

                        @Override
                        protected void onError(String response) {
                            showToast(response);
                        }
                    });
        }

    }


    @Override
    protected void initData() {

    }

    private String getTime(Date date) {//可根据需要自行截取数据显示
        Log.d("getTime()", "choice date millis: " + date.getTime());
        SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:ss");
        return format.format(date);
    }

}

支付页面

/**
 * 支付页面
 */
public class PayDialogActivity extends BaseActivity<ActivityPayDialogBinding> {
    private OrderInfo orderInfo;

    @Override
    protected ActivityPayDialogBinding getViewBinding() {
        return ActivityPayDialogBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void setListener() {
        mBinding.cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        mBinding.confirmButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (null != orderInfo) {
                    payOrder(orderInfo.getUid());
                }
            }
        });
    }

    private void payOrder(int _uid) {
        OkGo.<String>get(ApiConstants.PAY_ORDER_URL)
                .params("uid", _uid)
                .params("order_state", 1)
                .execute(new HttpStringCallback(this) {
                    @Override
                    protected void onSuccess(String msg, String response) {
                        showToast(msg);
                        setResult(3000);
                        finish();

                    }

                    @Override
                    protected void onError(String response) {
                        showToast(response);
                    }
                });
    }

    @Override
    protected void initData() {
        orderInfo = (OrderInfo) getIntent().getSerializableExtra("orderInfo");
        if (null != orderInfo) {
            mBinding.discountPrice.setText("¥" + orderInfo.getOrder_price());
        }
    }
}

统计管理

/**
 * 统计管理
 */
public class StatisticalActivity extends BaseActivity<ActivityStatisticalBinding> {
    private String[] titles = {"乘客订单", "乘客支出", "车主收入"};
    private List<Fragment> fragmentList = new ArrayList<>();

    @Override
    protected ActivityStatisticalBinding getViewBinding() {
        return ActivityStatisticalBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void initData() {
        //造数据
        fragmentList.add(new OrderListFragment());
        fragmentList.add(new SpendingFragment());
        fragmentList.add(new InComeFragment());
        //如果处理成懒加载的话,其实很简单,只要是这个方法setOffscreenPageLimit不去设置,就可以了。
//        mBinding.viewPager.setOffscreenPageLimit(fragmentList.size());
        mBinding.viewPager.setAdapter(new FragmentStateAdapter(this) {
            @NonNull
            @Override
            public Fragment createFragment(int position) {
                return fragmentList.get(position);
            }

            @Override
            public int getItemCount() {
                return fragmentList.size();
            }
        });
        mBinding.tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                mBinding.viewPager.setCurrentItem(tab.getPosition(), false);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        TabLayoutMediator tabLayoutMediator = new TabLayoutMediator(mBinding.tabs, mBinding.viewPager, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                tab.setText(titles[position]);
            }
        });
        //这句话很重要
        tabLayoutMediator.attach();
    }
}



版权声明:本文为jky_yihuangxing原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。