Commit 452f5847 authored by zhang_z's avatar zhang_z

收款页面基本完成;

parent 12c81300
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xingdata.zzdpos">
package="com.xingdata.zzdpos">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:name=".App"
......@@ -19,15 +19,16 @@
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:label="@string/main_title"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustUnspecified|stateHidden" >
android:windowSoftInputMode="adjustUnspecified|stateHidden">
</activity>
<activity
android:name=".ui.splash.SplashActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:theme="@style/AppTheme">
</activity>
</activity>
<activity
android:name=".ui.login.LoginActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
......@@ -47,11 +48,15 @@
android:windowSoftInputMode="adjustUnspecified|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.settle.SettleActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="adjustUnspecified|stateHidden" />
</application>
</manifest>
\ No newline at end of file
......@@ -396,6 +396,8 @@ public class C {
public final class EXTRA_KEY {
public static final String EXCEPTION = "extra.key.exception";
public static final String SETTLE_MODE = "extra.key.settle.mode";
public static final String SETTLE_EXTRA = "extra.key.settle.extra";
}
......@@ -465,4 +467,9 @@ public class C {
//商品
public static final int SKU = 4;
}
public final class SETTLE_MODE {
public static final int PAYMENT = 1;
public static final int STORE = 2;
}
}
package com.xingdata.zzdpos.ui.payment;
import android.content.Intent;
import com.blankj.utilcode.util.ActivityUtils;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.databinding.ActivityPaymentBinding;
import com.xingdata.zzdpos.ui.payment.fragment.PaymentFragment;
import com.xingdata.zzdpos.ui.settle.SettleActivity;
public class PaymentActivity extends BaseActivity<PaymentPresenter, ActivityPaymentBinding> implements PaymentContract.View {
......@@ -19,4 +24,12 @@ public class PaymentActivity extends BaseActivity<PaymentPresenter, ActivityPaym
loadRootFragment(R.id.f_payment, mPaymentFragment);
}
@Override
public void showSettle(Long amt) {
Intent intent = new Intent(PaymentActivity.this, SettleActivity.class);
intent.putExtra(C.EXTRA_KEY.SETTLE_MODE, C.SETTLE_MODE.PAYMENT);
intent.putExtra(C.EXTRA_KEY.SETTLE_EXTRA, amt);
ActivityUtils.startActivity(intent);
}
}
......@@ -7,9 +7,14 @@ import com.xingdata.zzdpos.base.BaseView;
interface PaymentContract {
interface View extends BaseView {
/**
* 显示结算页面
*/
void showSettle(Long amt);
}
abstract class Presenter extends BasePresenter<PaymentContract.View> {
abstract class Presenter extends BasePresenter<View> {
/**
* 收款界面 - 点击收款
*
......
......@@ -8,6 +8,6 @@ public class PaymentPresenter extends PaymentContract.Presenter {
@Override
public void clickSettle(Long amt) {
mView.showSettle(amt);
}
}
......@@ -9,7 +9,7 @@ import com.xingdata.zzdpos.util.ConvertUtil;
public class PaymentFragment extends BaseFragment<PaymentPresenter, FragmentPaymentBinding> {
private CalculatorView mCalculatorView = new CalculatorView();
private CalculatorView<PaymentPresenter> mCalculatorView = new CalculatorView<>();
@Override
public int getLayoutId() {
......@@ -19,10 +19,9 @@ public class PaymentFragment extends BaseFragment<PaymentPresenter, FragmentPaym
@Override
public void initView() {
loadRootFragment(R.id.f_inputer, mCalculatorView);
mCalculatorView.setOnResultChangeListener((exp, result) -> {
mViewBinding.tvExp.setText(exp);
String strResult = ConvertUtil.fenToYuan(result);
mViewBinding.tvExp.setText(exp);
mViewBinding.tvResult.setText(strResult);
mViewBinding.tvAmt.setText(strResult);
});
......
......@@ -7,15 +7,15 @@ import android.widget.TextView;
import com.blankj.utilcode.util.LogUtils;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.base.BasePresenter;
import com.xingdata.zzdpos.databinding.ViewCalculatorBinding;
import com.xingdata.zzdpos.ui.payment.PaymentPresenter;
import com.xingdata.zzdpos.util.ConvertUtil;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculatorBinding> {
public class CalculatorView<P extends BasePresenter> extends BaseFragment<P, ViewCalculatorBinding> {
private String mExp;
private String mValue;
......@@ -123,7 +123,7 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
/**
* 解析计算四则运算表达式,例:2+((3+4)*2-22)/2*3
* 解析计算四则运算表达式
*
* @param exp 算式
* @return 结果
......
package com.xingdata.zzdpos.ui.settle;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.databinding.ActivitySettleBinding;
public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettleBinding> implements SettleContract.View {
@Override
public int getLayoutId() {
return R.layout.activity_settle;
}
@Override
public void initView() {
}
}
package com.xingdata.zzdpos.ui.settle;
import com.xingdata.zzdpos.base.BasePresenter;
import com.xingdata.zzdpos.base.BaseView;
public interface SettleContract {
interface View extends BaseView {
}
abstract class Presenter extends BasePresenter<View> {
}
}
package com.xingdata.zzdpos.ui.settle;
import com.blankj.utilcode.util.LogUtils;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.util.ConvertUtil;
public class SettlePresenter extends SettleContract.Presenter {
@Override
public void onAttached() {
int settleMode = getIntent().getIntExtra(C.EXTRA_KEY.SETTLE_MODE, -1);
switch (settleMode) {
case C.SETTLE_MODE.PAYMENT:
LogUtils.e("创建收款订单,订单金额" + ConvertUtil.fenToYuan(getIntent().getLongExtra(C.EXTRA_KEY.SETTLE_EXTRA, 0), true));
break;
}
}
}
package com.xingdata.zzdpos.ui.settle.fragment;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentPayCashBinding;
import com.xingdata.zzdpos.ui.settle.SettlePresenter;
public class CashPayFragment extends BaseFragment<SettlePresenter, FragmentPayCashBinding> {
@Override
public int getLayoutId() {
return R.layout.fragment_pay_cash;
}
@Override
public void initView() {
}
}
package com.xingdata.zzdpos.ui.settle.fragment;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentSettleBinding;
import com.xingdata.zzdpos.ui.settle.SettlePresenter;
public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettleBinding> {
@Override
public int getLayoutId() {
return R.layout.fragment_settle;
}
@Override
public void initView() {
}
}
package com.xingdata.zzdpos.ui.settle.view;
import android.view.View;
import android.widget.TextView;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.base.BasePresenter;
import com.xingdata.zzdpos.databinding.ViewInputerBinding;
import com.xingdata.zzdpos.util.ConvertUtil;
public class InpterView<P extends BasePresenter> extends BaseFragment<P, ViewInputerBinding> {
private String mValue;
private OnResultChangeListener mOnResultChangeListener;
private onSettleClickListener mOnSettleClickListener;
public interface OnResultChangeListener {
void onResultChange(Long result);
}
public interface onSettleClickListener {
void onSettleClick(Long result);
}
@Override
public int getLayoutId() {
return R.layout.view_inputer;
}
@Override
public void initView() {
View.OnClickListener mOnClickListener = view -> {
switch (view.getId()) {
case R.id.tv_del:
delete();
break;
case R.id.tv_clear:
clear();
break;
case R.id.tv_settle:
settle();
break;
default:
if (view instanceof TextView) {
}
break;
}
if (mOnResultChangeListener != null) {
mOnResultChangeListener.onResultChange(ConvertUtil.yuanToFen(mValue));
}
};
mViewBinding.setOnClick(mOnClickListener);
}
/**
* 删除
*/
private void delete() {
if (mValue.length() > 0) mValue = mValue.substring(0, mValue.length() - 1);
}
/**
* 结账
*/
private void settle() {
if (mOnSettleClickListener != null) {
mOnSettleClickListener.onSettleClick(ConvertUtil.yuanToFen(mValue));
}
}
/**
* 清空
*/
private void clear() {
mValue = "";
if (mOnResultChangeListener != null) {
mOnResultChangeListener.onResultChange(ConvertUtil.yuanToFen(mValue));
}
}
public void setOnResultChangeListener(OnResultChangeListener onResultChangeListener) {
this.mOnResultChangeListener = onResultChangeListener;
mOnResultChangeListener.onResultChange(ConvertUtil.yuanToFen(mValue));
}
public void setOnSettleClickListener(onSettleClickListener onSettleClickListener) {
this.mOnSettleClickListener = onSettleClickListener;
}
}
<?xml version="1.0" encoding="utf-8"?>
<layout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/black_zhangfei">
<ImageButton
android:layout_width="@dimen/title_height"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/all_go_back"
android:gravity="center"
android:padding="@dimen/all_margin"
android:src="@mipmap/back_white" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/payment_title"
android:textColor="@color/white_caocao"
android:textSize="@dimen/all_sub_title_size" />
</FrameLayout>
<FrameLayout
android:id="@+id/f_payment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.constraint.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -16,16 +16,18 @@
android:gravity="bottom"
android:paddingBottom="@dimen/all_margin">
<TextView
android:id="@+id/tv_exp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/all_spacing"
android:layout_marginEnd="@dimen/all_margin"
android:gravity="end|center_vertical"
android:gravity="end"
android:textColor="@color/white_caocao"
android:textSize="@dimen/all_title_size"
app:layout_constraintBottom_toTopOf="@id/tv_result"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
......@@ -47,6 +49,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/all_margin"
android:gravity="end|center_vertical"
android:maxLines="1"
android:textColor="@color/white_caocao"
android:textSize="@dimen/fragment_settle_bigtextsize"
app:layout_constraintBottom_toBottomOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<layout>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.constraint.ConstraintLayout>
</layout>
\ No newline at end of file
This diff is collapsed.
......@@ -155,9 +155,6 @@
<string name="card_num">卡号:</string>
<string name="card_num_hint">请输入储值卡卡号</string>
<!--结算页面 <WHERE>_<DESCRIPTION>-->
<string name="settle_title">结算页面</string>
<string name="settle_amt">应收:</string>
<string name="settle_channel_hint">请选择支付方式</string>
<string name="settle_channel_cash">现金</string>
<string name="settle_channel_cash_not_enough">金额不足,无法支付</string>
......@@ -493,5 +490,9 @@
<string name="payment_title">收款</string>
<string name="payment_total">总计:</string>
<!--支付-->
<string name="settle_title">收款</string>
<string name="settle_amt">应收金额:</string>
<string name="settle_select_vip">请选择会员</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment