Commit 6c1feb88 authored by zhang_z's avatar zhang_z

营销方案;

parent 8afa25ee
......@@ -101,8 +101,7 @@ public abstract class BaseDialog<P extends BasePresenter, B extends ViewDataBind
mBaseBinding = DataBindingUtil.inflate(inflater, R.layout.dialog_base, container, false);
mBaseBinding.vsCenter.getViewStub().setLayoutResource(getLayoutId());
mBaseBinding.vsCenter.getViewStub().setOnInflateListener((viewStub, view) -> mViewBinding
= DataBindingUtil.bind(view));
mBaseBinding.vsCenter.getViewStub().setOnInflateListener((viewStub, view) -> mViewBinding = DataBindingUtil.bind(view));
mBaseBinding.vsCenter.getViewStub().inflate();
if (!isShowTitle() || getTitle() < 0) mBaseBinding.tvTitle.setVisibility(View.GONE);
......
package com.xingdata.zzdpos.ui.settle.fragment;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
......@@ -58,6 +59,17 @@ public class SettleFragment extends BaseFragment<SettlePresenter, FragmentSettle
mViewBinding.cbPoint.setButtonDrawable(b ? R.mipmap.but_elect01 : R.mipmap.but_elect02);
mPresenter.changePointState(b);
});
BottomSheetBehavior.from(mViewBinding.llSheet).setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
mViewBinding.tvSettle.setAlpha(1 - slideOffset);
}
});
// init
mPresenter.initSettle();
......
......@@ -163,7 +163,7 @@ interface StoreContract {
* @param sku 商品
* @param <Sku> 商品类型
*/
public abstract <Sku extends BaseSku> void clickAddSku(Sku sku);
public abstract <Sku extends BaseSku> void clickAddSku(Sku sku, int value);
/**
* 商店页面 - 点击删除商品
......@@ -171,7 +171,7 @@ interface StoreContract {
* @param sku 商品
* @param <Sku> 商品类型
*/
public abstract <Sku extends BaseSku> void clickRemoveSku(Sku sku);
public abstract <Sku extends BaseSku> void clickRemoveSku(Sku sku, int value);
/**
* 购物车页面 - 购物车发生变化
......
......@@ -126,9 +126,9 @@ public class StorePresenter extends StoreContract.Presenter {
}
@Override
public <Sku extends BaseSku> void clickAddSku(Sku sku) {
public <Sku extends BaseSku> void clickAddSku(Sku sku, int value) {
//更新购物车信息
updateCart(sku, 1);
updateCart(sku, value);
//发送购物车信息(不需要刷新页面)
mView.loadSaledetails(mSaledetails, false);
//购物车发生变化
......@@ -136,15 +136,16 @@ public class StorePresenter extends StoreContract.Presenter {
}
@Override
public <Sku extends BaseSku> void clickRemoveSku(Sku sku) {
public <Sku extends BaseSku> void clickRemoveSku(Sku sku, int value) {
//更新购物车信息
updateCart(sku, -1);
updateCart(sku, value);
//发送购物车信息(不需要刷新页面)
mView.loadSaledetails(mSaledetails, false);
//购物车发生变化
this.cartChanged();
}
@Override
public void cartChanged() {
//设置订单信息
......
package com.xingdata.zzdpos.ui.store.adapter;
import android.support.annotation.Nullable;
import android.view.View;
import com.xingdata.zzdpos.R;
......@@ -39,24 +38,22 @@ public class SkuAdapter<T extends BaseSku> extends BaseAdapter<T, ItemStoreSkuBi
mViewBinding.tvName.setText(item.getSpuName());
mViewBinding.tvAmt.setText(ConvertUtil.fenToYuan(item.getSkuRetailPrice1()));
mViewBinding.ivIncrease.setOnClickListener(view -> {
if (mViewBinding.getCount() >= 99) return;
mViewBinding.setCount(mViewBinding.getCount() + 1);
setViewByCount(mViewBinding);
if (mOnCountChangeListener != null) {
mOnCountChangeListener.onCountChange(item, 1);
mOnCountChangeListener.onCountChange(mViewBinding.ivPic, item, 1);
}
});
mViewBinding.ivReduce.setOnClickListener(view -> {
mViewBinding.setCount(mViewBinding.getCount() - 1);
setViewByCount(mViewBinding);
if (mOnCountChangeListener != null) {
mOnCountChangeListener.onCountChange(item, -1);
mOnCountChangeListener.onCountChange(mViewBinding.ivPic, item, -1);
}
});
mViewBinding.setCount(0);
for (int i = 0; i < mSaledetails.size(); i++) {
if (mSaledetails.get(i).getSkuId().longValue() == item.getSkuId()) {
......@@ -77,12 +74,6 @@ public class SkuAdapter<T extends BaseSku> extends BaseAdapter<T, ItemStoreSkuBi
mViewBinding.ivReduce.setVisibility(View.GONE);
mViewBinding.tvCount.setVisibility(View.GONE);
}
}
@Override
public void setOnItemClickListener(@Nullable OnItemClickListener listener) {
super.setOnItemClickListener(listener);
}
}
......@@ -35,9 +35,9 @@ public class SearchFragment extends BaseFragment<StorePresenter, FragmentStoreSe
// set sku listener
mSkuAdapter.setOnLoadMoreListener(this::loadMoreSku, mViewBinding.rlSku);
mSkuAdapter.setOnCountChangeListener((sku, value) -> {
if (value > 0) mPresenter.clickAddSku(sku);
else mPresenter.clickRemoveSku(sku);
mSkuAdapter.setOnCountChangeListener((view, sku, value) -> {
if (value > 0) mPresenter.clickAddSku(sku, value);
else mPresenter.clickRemoveSku(sku, value);
});
// set empty
......
package com.xingdata.zzdpos.ui.store.fragment;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.support.constraint.ConstraintLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.StringUtils;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
......@@ -26,10 +34,12 @@ public class StoreFragment extends BaseFragment<StorePresenter, FragmentStoreBin
private SkugrpAdapter mSkugrpAdapter;
private SkuAdapter mSkuAdapter;
public interface OnCountChangeListener {
void onCountChange(BaseSku sku, int value);
void onCountChange(View view, BaseSku sku, int value);
}
@Override
public int getLayoutId() {
return R.layout.fragment_store;
......@@ -50,11 +60,11 @@ public class StoreFragment extends BaseFragment<StorePresenter, FragmentStoreBin
// set sku listener
mViewBinding.srlSku.setOnRefreshListener(this::refreshSku);
mSkuAdapter.setOnLoadMoreListener(this::loadMoreSku, mViewBinding.rlSku);
mSkuAdapter.setOnCountChangeListener((sku, value) -> {
if (value > 0) mPresenter.clickAddSku(sku);
else mPresenter.clickRemoveSku(sku);
});
mSkuAdapter.setOnCountChangeListener((view, sku, value) -> {
if (value > 0) this.clickAdd(view, sku, value);
else mPresenter.clickRemoveSku(sku, value);
});
// set grp listener
mSkugrpAdapter.setOnItemClickListener((adapter, view, position) -> mPresenter.clickSkugrp(mSkugrpAdapter.getData().get(position)));
......@@ -71,6 +81,7 @@ public class StoreFragment extends BaseFragment<StorePresenter, FragmentStoreBin
mPresenter.initStore();
}
/**
* 刷新商品
*/
......@@ -218,4 +229,97 @@ public class StoreFragment extends BaseFragment<StorePresenter, FragmentStoreBin
}
/**
* 点击添加按钮
*
* @param view 按钮
* @param sku 商品信息
* @param value 数量
*/
private void clickAdd(View view, BaseSku sku, int value) {
// 路径测量
PathMeasure mPathMeasure;
// 贝塞尔曲线中间过程点坐标
float[] mCurrentPosition = new float[2];
final ImageView icon = new ImageView(mContext);
icon.setImageDrawable(((ImageView) view).getDrawable());
ConstraintLayout.LayoutParams params = new ConstraintLayout.LayoutParams(view.getWidth(), view.getHeight());
mViewBinding.clStore.addView(icon, params);
int[] parentLocation = new int[2];
mViewBinding.clStore.getLocationInWindow(parentLocation);
int startLoc[] = new int[2];
view.getLocationInWindow(startLoc);
// 得到购物车图片的坐标(用于计算动画结束后的坐标)
int endLoc[] = new int[]{0, ScreenUtils.getScreenHeight()};
float startX = startLoc[0] - parentLocation[0];
float startY = startLoc[1] - parentLocation[1];
// 商品掉落后的终点坐标:购物车起始点-父布局起始点+购物车图片的1/5
float toX = endLoc[0] - parentLocation[0];
float toY = endLoc[1] - parentLocation[1];
// 开始绘制贝塞尔曲线
Path path = new Path();
// 移动到起始点(贝塞尔曲线的起点)
path.moveTo(startX, startY);
// 使用二阶贝塞尔曲线:注意第一个起始坐标越大,贝塞尔曲线的横向距离就会越大,一般按照下面的式子取即可
path.quadTo((startX + toX) / 2, startY, toX, toY);
// mPathMeasure用来计算贝塞尔曲线的曲线长度和贝塞尔曲线中间插值的坐标,如果是true,path会形成一个闭环
mPathMeasure = new PathMeasure(path, false);
// 属性动画实现(从0到贝塞尔曲线的长度之间进行插值计算,获取中间过程的距离值)
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, mPathMeasure.getLength());
valueAnimator.setDuration(500);
// 匀速线性插值器
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
// 当插值计算进行时,获取中间的每个值,
// 这里这个值是中间过程中的曲线长度(下面根据这个值来得出中间点的坐标值)
float value = (Float) animation.getAnimatedValue();
// 获取当前点坐标封装到mCurrentPosition
// boolean getPosTan(float distance, float[] pos, float[] tan) :
// 传入一个距离distance(0<=distance<=getLength()),然后会计算当前距离的坐标点和切线,pos会自动填充上坐标,这个方法很重要。
// mCurrentPosition此时就是中间距离点的坐标值
mPathMeasure.getPosTan(value, mCurrentPosition, null);
// 移动的商品图片(动画图片)的坐标设置为该中间点的坐标
icon.setTranslationX(mCurrentPosition[0]);
icon.setTranslationY(mCurrentPosition[1]);
}
});
// 开始执行动画
valueAnimator.start();
// 动画结束后的处理
valueAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
mPresenter.clickAddSku(sku, value);
// 把执行动画的商品图片从父布局中移除
mViewBinding.clStore.removeView(icon);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
}
......@@ -15,14 +15,6 @@
name="dateEnd"
type="String" />
<variable
name="timeStart"
type="String" />
<variable
name="timeEnd"
type="String" />
<variable
name="user"
type="String" />
......@@ -192,6 +184,12 @@
android:textSize="@dimen/all_text_size" />
</LinearLayout>
<ViewStub
android:id="@+id/vs_time_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/view_time_detail" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
......@@ -328,6 +326,18 @@
android:layout_marginBottom="@dimen/all_margin"
android:background="@color/gray_huanggai" />
<Button
android:id="@+id/btn_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/all_margin"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:background="@drawable/shape_red_r1"
android:foreground="?android:attr/selectableItemBackground"
android:text="@string/all_confirm"
android:textColor="@color/white_caocao"
android:textSize="@dimen/all_text_size" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</layout>
\ No newline at end of file
......@@ -157,12 +157,16 @@
<Button
android:id="@+id/btn_confirm"
style="@style/button_positive"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/all_margin"
android:layout_marginEnd="@dimen/all_margin"
android:layout_marginStart="@dimen/all_margin"
android:background="@drawable/shape_red_r1"
android:foreground="?android:attr/selectableItemBackground"
android:text="@{payResult?@string/settle_complete:@string/settle_retry}" />
android:text="@{payResult?@string/settle_complete:@string/settle_retry}"
android:textColor="@color/white_caocao"
android:textSize="@dimen/all_text_size" />
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -82,30 +82,38 @@
android:layout_marginTop="@dimen/all_margin"
android:background="@color/gray_huanggai" />
<LinearLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/cl_store"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rl_skugrp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/srl_sku"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srl_sku"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/white_caocao">
android:layout_height="0dp"
android:background="@color/white_caocao"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="3"
app:layout_constraintLeft_toRightOf="@id/rl_skugrp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rl_sku"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -9,7 +9,6 @@
<variable
name="count"
type="int" />
</data>
<android.support.constraint.ConstraintLayout
......
<?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">
<data>
<variable
name="timeStart"
type="String" />
<variable
name="timeEnd"
type="String" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<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:background="@color/white_caocao"
android:gravity="center_vertical"
android:paddingEnd="@dimen/all_margin"
android:paddingStart="@dimen/all_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/ms_editor_time"
android:textColor="@color/black_baozheng"
android:textSize="@dimen/all_text_size" />
<TextView
android:id="@+id/tv_time_start"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/all_margin"
android:layout_weight="1"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center"
android:text="@{timeStart}"
android:textColor="@color/black_likui"
android:textSize="@dimen/all_text_size" />
<View
android:layout_width="@dimen/view_line_L1"
android:layout_height="match_parent"
android:layout_margin="@dimen/all_margin"
android:background="@color/golden_yuji" />
<TextView
android:id="@+id/tv_time_end"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center"
android:text="@{timeEnd}"
android:textColor="@color/black_likui"
android:textSize="@dimen/all_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" />
<TextView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/white_caocao"
android:gravity="center_vertical"
android:paddingEnd="@dimen/all_margin"
android:paddingStart="@dimen/all_margin"
android:text="@string/ms_editor_week"
android:textColor="@color/black_baozheng"
android:textSize="@dimen/all_text_size" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white_caocao"
android:paddingEnd="@dimen/all_margin"
android:paddingStart="@dimen/all_margin">
<CheckBox
android:id="@+id/cb_mon"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:text="@string/week_mon"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/cb_tue"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/cb_tue"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:text="@string/week_tue"
app:layout_constraintLeft_toRightOf="@id/cb_mon"
app:layout_constraintRight_toLeftOf="@id/cb_wed"
app:layout_constraintTop_toTopOf="@id/cb_mon" />
<CheckBox
android:id="@+id/cb_wed"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:text="@string/week_wed"
app:layout_constraintLeft_toRightOf="@id/cb_tue"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/cb_mon" />
<CheckBox
android:id="@+id/cb_thu"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:text="@string/week_thu"
app:layout_constraintLeft_toLeftOf="@id/cb_mon"
app:layout_constraintTop_toBottomOf="@id/cb_mon" />
<CheckBox
android:id="@+id/cb_fri"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:text="@string/week_fri"
app:layout_constraintLeft_toLeftOf="@id/cb_tue"
app:layout_constraintTop_toTopOf="@id/cb_thu" />
<CheckBox
android:id="@+id/cb_sat"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:text="@string/week_sat"
app:layout_constraintLeft_toLeftOf="@id/cb_wed"
app:layout_constraintTop_toTopOf="@id/cb_thu" />
<CheckBox
android:id="@+id/cb_sun"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:text="@string/week_sun"
app:layout_constraintTop_toBottomOf="@id/cb_thu" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -203,4 +203,8 @@
<dimen name="store_cart_count">20dp</dimen>
<!--新标准-->
<dimen name="headline">20dp</dimen>
</resources>
......@@ -333,8 +333,8 @@
<string name="ms_editor_date">起止时间:</string>
<string name="ms_editor_date_start">开始时间</string>
<string name="ms_editor_date_end">结束时间</string>
<string name="ms_editor_time">限定时段:</string>
<string name="ms_editor_week">限定星期:</string>
<string name="ms_editor_time">限定时段</string>
<string name="ms_editor_week">限定星期</string>
<string name="ms_editor_subtitle_ms">活动信息</string>
<string name="ms_editor_type">营销方式:</string>
<string name="ms_editor_group">营销主体</string>
......@@ -365,6 +365,9 @@
<string name="ms_editor_type_gift_hint">条码:请扫码或输入条码</string>
<string name="ms_editor_type_gift_name">品名:</string>
<string name="ms_editor_type_gift_price">售价:</string>
<string name="ms_editor_date_format">%s年%s月%s日</string>
<string name="ms_editor_time_format">%s:%s</string>
<!--商品管理-->
<string name="sssku_title">商品维护</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