Commit 5608590f authored by zhang_z's avatar zhang_z

添加换购;

parent 39b0166f
......@@ -28,10 +28,6 @@ public class AddFragment extends BaseFragment<SsskuPresenter, FragmentSsskuAddBi
@Override
public void initView() {
mViewBinding.etBarcode.requestFocus();
KeyboardUtils.showSoftInput(mViewBinding.etBarcode);
mViewBinding.etBarcode.setOnEditorActionListener((textView, i, keyEvent) -> {
if ((i == EditorInfo.IME_ACTION_SEARCH || i == EditorInfo.IME_ACTION_UNSPECIFIED) && !StringUtils.isEmpty(textView.getText())) {
KeyboardUtils.hideSoftInput(textView);
......@@ -57,6 +53,12 @@ public class AddFragment extends BaseFragment<SsskuPresenter, FragmentSsskuAddBi
});
}
@Override
public void onStart() {
super.onStart();
KeyboardUtils.showSoftInput(mViewBinding.etBarcode);
}
public void loadCheckSkus(List<Sssku> ssskus) {
mSkuAdapter.setNewData(ssskus);
}
......
......@@ -209,6 +209,11 @@ interface MsContract {
*/
public abstract void clickTypeSkuSearch();
/**
* 编辑页面 - 点击营销类型商品的扫描键
*/
public abstract void clickTypeSkuScan();
/**
* 编辑页面 - 点击搜索按钮
*
......
......@@ -123,6 +123,11 @@ public class MsPresenter<Sku extends BaseSku> extends MsContract.Presenter<Sku>
mView.showSearchFragment(C.TITLE_MODE.GIFT);
}
@Override
public void clickTypeSkuScan() {
mView.showScanFragment(C.TITLE_MODE.GIFT);
}
@Override
public void clickSearchButton(String keyword) {
......
......@@ -96,7 +96,8 @@ public class MsAdapter extends BaseAdapter<Ms, ItemMsBinding> {
strType = mContext.getResources().getString(R.string.ms_type_money_off_info, ConvertUtil.fenToYuan(ms.getPayAmt()), ConvertUtil.fenToYuan(ms.getGiftOffAmt()));
break;
case C.MS_TYPE.GIFT:
strType = mContext.getResources().getString(R.string.ms_type_gift_info, ConvertUtil.fenToYuan(ms.getPayAmt()), ConvertUtil.fenToYuan(ms.getGiftSkuPrice()), ms.getGiftSkuName());
String spuName = DBFactory.Marketing.Ms.querySpuNameBySkuId(ms.getGiftSkuId());
strType = mContext.getResources().getString(R.string.ms_type_gift_info, ConvertUtil.fenToYuan(ms.getPayAmt()), ConvertUtil.fenToYuan(ms.getGiftSkuPrice()), spuName);
break;
}
return strGroup + strType;
......
......@@ -176,7 +176,6 @@ public class EditorFragment extends BaseFragment<MsPresenter, FragmentMsEditorBi
*/
public <Sku extends BaseSku> void loadGroupSku(Sku sssku) {
if (mGroupView instanceof GroupSkuView) ((GroupSkuView) mGroupView).loadSssku(sssku);
}
/**
......@@ -185,6 +184,7 @@ public class EditorFragment extends BaseFragment<MsPresenter, FragmentMsEditorBi
* @param sssku 商品
*/
public <Sku extends BaseSku> void loadTypeSku(Sku sssku) {
if (mTypeView instanceof TypeGiftView) ((TypeGiftView) mTypeView).loadSssku(sssku);
}
/**
......
......@@ -29,9 +29,7 @@ public class GroupSkuView<Sku extends BaseSku> extends BaseGroupView<ViewGroupSk
mViewBinding.etSearch.setOnFocusChangeListener((view, b) -> {
if (b) mPresenter.clickGroupSkuSearch();
});
mViewBinding.btnScan.setOnClickListener(view -> {
mPresenter.clickGroupSkuScan();
});
mViewBinding.btnScan.setOnClickListener(view -> mPresenter.clickGroupSkuScan());
}
@SuppressLint("SetTextI18n")
......@@ -39,8 +37,6 @@ public class GroupSkuView<Sku extends BaseSku> extends BaseGroupView<ViewGroupSk
protected void setViewByMs() {
if (mMs.getMsTouchTag2() == null || mMs.getMsTouchTag2() != C.MS_GROUP.SKU) return;
mViewBinding.llProduct.setVisibility(View.VISIBLE);
mViewBinding.etSearch.setText(ConvertUtil.longToString(mMs.getSkuBarCode()));
mViewBinding.setName(mMs.getSkuName());
mViewBinding.setPrice(ConvertUtil.fenToYuan(mMs.getSkuPrice1(), true));
}
......@@ -57,7 +53,6 @@ public class GroupSkuView<Sku extends BaseSku> extends BaseGroupView<ViewGroupSk
public void loadSssku(Sku sku) {
this.mSku = sku;
if (sku != null) {
mViewBinding.etSearch.setText(ConvertUtil.longToString(sku.getSpuBarcode()));
mViewBinding.setName(sku.getSpuName());
mViewBinding.setPrice(ConvertUtil.fenToYuan(sku.getSkuRetailPrice1(), true));
mViewBinding.llProduct.setVisibility(View.VISIBLE);
......
package com.xingdata.zzdpos.ui.marketing.ms.view;
import android.annotation.SuppressLint;
import android.view.View;
import android.widget.EditText;
import com.blankj.utilcode.util.StringUtils;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseSku;
import com.xingdata.zzdpos.databinding.ViewTypeGiftBinding;
import com.xingdata.zzdpos.model.Ms;
import com.xingdata.zzdpos.util.ConvertUtil;
import com.xingdata.zzdpos.util.InputFilters;
/**
* 促销页面
*/
public class TypeGiftView extends BaseTypeView<ViewTypeGiftBinding> {
public class TypeGiftView<Sku extends BaseSku> extends BaseTypeView<ViewTypeGiftBinding> {
private Sku mSssku;
private View.OnFocusChangeListener mOnFocusChangeListener;
public TypeGiftView() {
mOnFocusChangeListener = (view, b) -> {
if (view instanceof EditText) {
EditText editText = (EditText) view;
if (b && editText.getText().toString().equals("0.00")) {
editText.setText("");
} else if (!b && editText.getText().length() == 0) {
editText.setText("0.00");
}
}
};
}
@Override
public int getLayoutId() {
return R.layout.view_type_gift;
}
@Override
public void initView() {
super.initView();
mViewBinding.etAmt.setFilters(InputFilters.getMoneyFilter(6));
mViewBinding.etAddAmt.setFilters(InputFilters.getMoneyFilter(6));
mViewBinding.etAmt.setOnFocusChangeListener(mOnFocusChangeListener);
mViewBinding.etAddAmt.setOnFocusChangeListener(mOnFocusChangeListener);
mViewBinding.etSearch.setOnFocusChangeListener((view, b) -> {
if (b) mPresenter.clickTypeSkuSearch();
});
mViewBinding.btnScan.setOnClickListener(view -> mPresenter.clickTypeSkuScan());
}
@SuppressLint("SetTextI18n")
@Override
protected void setViewByMs() {
if (mMs.getMsTools() == null || mMs.getMsTools() != C.MS_TYPE.GIFT) return;
mViewBinding.etAmt.setText(ConvertUtil.fenToYuan(mMs.getPayAmt()));
mViewBinding.etAddAmt.setText(ConvertUtil.fenToYuan(mMs.getGiftSkuPrice()));
mViewBinding.llProduct.setVisibility(View.VISIBLE);
mViewBinding.setName(mMs.getGiftSkuName());
mViewBinding.setPrice(ConvertUtil.fenToYuan(mMs.getGiftSkuPrice1(), true));
}
@Override
public boolean processMs(Ms ms) {
ms.setMsTools(C.MS_TYPE.GIFT);
String strAmt = mViewBinding.etAmt.getText().toString();
if (StringUtils.isEmpty(strAmt)) return false;
ms.setPayAmt(ConvertUtil.yuanToFen(strAmt));
String strAddAmt = mViewBinding.etAddAmt.getText().toString();
if (StringUtils.isEmpty(strAddAmt)) return false;
ms.setGiftSkuPrice(ConvertUtil.yuanToFen(strAddAmt));
if (mSssku == null && ms.getGiftSkuId() == null) return false;
if (mSssku != null) ms.setGiftSkuId(mSssku.getSkuId());
return true;
}
@SuppressLint("SetTextI18n")
public void loadSssku(Sku sku) {
this.mSssku = sku;
if (sku != null) {
mViewBinding.setName(mMs.getGiftSkuName());
mViewBinding.setPrice(ConvertUtil.fenToYuan(mMs.getGiftSkuPrice1(), true));
mViewBinding.llProduct.setVisibility(View.VISIBLE);
} else {
mViewBinding.llProduct.setVisibility(View.GONE);
}
}
}
......@@ -48,6 +48,7 @@
style="@style/searchBarEditor"
android:layout_width="0dp"
android:layout_weight="1"
android:inputType="text"
android:labelFor="@+id/et_search" />
</LinearLayout>
......
......@@ -53,6 +53,7 @@
android:layout_weight="1"
android:background="@color/transparent"
android:gravity="center_vertical"
android:imeOptions="actionSearch"
android:inputType="number"
android:labelFor="@+id/et_barcode"
android:saveEnabled="false"
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<layout>
<LinearLayout
<data>
<import type="android.view.View" />
<variable
name="name"
type="String" />
<variable
name="price"
type="String" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="@color/white_caocao"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/ms_editor_type_gift_text1"
android:textColor="@color/black"
android:textSize="@dimen/big_text_size" />
<EditText
android:id="@+id/et_amt"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:layout_weight="1"
android:background="@color/transparent"
android:inputType="numberDecimal"
android:labelFor="@+id/et_amt"
android:saveEnabled="false"
android:textSize="@dimen/all_body_size" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/ms_editor_type_gift_text2"
android:textColor="@color/black"
android:textSize="@dimen/big_text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:background="@color/gray_kongming" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/ms_editor_type_gift_text3"
android:textColor="@color/black"
android:textSize="@dimen/big_text_size" />
<EditText
android:id="@+id/et_add_amt"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:layout_weight="1"
android:background="@color/transparent"
android:inputType="numberDecimal"
android:labelFor="@+id/et_add_amt"
android:textSize="@dimen/all_body_size" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/ms_editor_type_gift_text2"
android:textColor="@color/black"
android:textSize="@dimen/big_text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:background="@color/gray_kongming" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white_caocao"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/all_margin"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:layout_marginTop="@dimen/all_margin">
<EditText
android:id="@+id/et_search"
style="@style/searchBarEditor"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/all_spacing"
android:layout_weight="1"
android:hint="@string/ms_editor_type_gift_search_hint"
android:inputType="text"
android:labelFor="@+id/et_search"
android:saveEnabled="false" />
<ImageButton
android:id="@+id/btn_scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:contentDescription="@string/store_scan"
android:foreground="?android:attr/actionBarItemBackground"
android:src="@mipmap/but_sweep_yard" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="@{name.length()>0?View.VISIBLE:View.GONE }">
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:background="@color/gray_kongming" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/tv_product_pic"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/all_margin"
app:placeholderImage="@mipmap/icon_goods_default" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/all_spacing"
android:orientation="vertical"
android:padding="@dimen/all_margin">
<TextView
android:id="@+id/tv_product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{@string/ms_editor_group_sku_name+name}" />
<TextView
android:id="@+id/tv_product_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/all_margin"
android:text="@{@string/ms_editor_group_sku_price+price}" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -366,8 +366,8 @@
<string name="ms_editor_type_money_off_text2"></string>
<string name="ms_editor_type_money_off_text3"></string>
<string name="ms_editor_type_gift_text1"></string>
<string name="ms_editor_type_gift_text2">,加</string>
<string name="ms_editor_type_gift_text3">元换购</string>
<string name="ms_editor_type_gift_text2"></string>
<string name="ms_editor_type_gift_text3"></string>
<string name="ms_editor_type_gift_text4">1件</string>
<string name="ms_editor_type_gift_hint">条码:请扫码或输入条码</string>
<string name="ms_editor_type_gift_name">品名:</string>
......
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