|
|
@@ -1,193 +0,0 @@
|
|
|
-package com.itant.shibei.ui.mine.goods;
|
|
|
-
|
|
|
-import android.content.Intent;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.text.TextUtils;
|
|
|
-import android.view.Menu;
|
|
|
-import android.view.MenuItem;
|
|
|
-import android.view.View;
|
|
|
-import android.widget.Button;
|
|
|
-import android.widget.CheckBox;
|
|
|
-
|
|
|
-import androidx.annotation.NonNull;
|
|
|
-
|
|
|
-import com.google.android.material.textfield.TextInputEditText;
|
|
|
-import com.itant.shibei.R;
|
|
|
-import com.itant.shibei.base.BaseBeiActivity;
|
|
|
-import com.itant.shibei.constant.ConstantUrl;
|
|
|
-import com.itant.shibei.ui.home.goods.GoodsBean;
|
|
|
-import com.miekir.common.utils.ActivityTool;
|
|
|
-import com.miekir.common.utils.ToastTool;
|
|
|
-import com.miekir.common.utils.ViewTool;
|
|
|
-import com.miekir.mvp.presenter.InjectPresenter;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author Miekir
|
|
|
- * @date 2020/6/18 16:48
|
|
|
- * Description: 添加京东商品界面
|
|
|
- */
|
|
|
-public class AddGoodsActivity extends BaseBeiActivity implements View.OnClickListener, IAddGoodsView {
|
|
|
- public static final String KEY_MODIFY_GOODS = "key_modify_goods";
|
|
|
-
|
|
|
- private TextInputEditText et_goods_title;
|
|
|
- private TextInputEditText et_cover_url;
|
|
|
- private TextInputEditText et_video_url;
|
|
|
- private TextInputEditText et_desc;
|
|
|
- private TextInputEditText et_reason;
|
|
|
- private TextInputEditText et_old_price;
|
|
|
- private TextInputEditText et_rebate_all;
|
|
|
- private TextInputEditText et_province;
|
|
|
- private TextInputEditText et_coupon;
|
|
|
- private TextInputEditText et_goods_url;
|
|
|
- private TextInputEditText et_sales_per_month;
|
|
|
- private TextInputEditText et_good_comment_percent;
|
|
|
- private TextInputEditText et_shop_name;
|
|
|
- private TextInputEditText et_comment_num;
|
|
|
- private CheckBox cb_self;
|
|
|
- private CheckBox cb_enable;
|
|
|
-
|
|
|
- private GoodsBean mGoodsBean;
|
|
|
-
|
|
|
- @InjectPresenter
|
|
|
- AddGoodsPresenter presenter;
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getLayoutID() {
|
|
|
- return R.layout.activity_goods_add;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
- getMenuInflater().inflate(R.menu.menu_done, menu);
|
|
|
- MenuItem item = menu.findItem(R.id.action_done);
|
|
|
- item.setTitle(" 返利链接 ");
|
|
|
- return super.onCreateOptionsMenu(menu);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
|
|
- switch (item.getItemId()) {
|
|
|
- case R.id.action_done:
|
|
|
- // 注册
|
|
|
- ActivityTool.openUrl(this, ConstantUrl.URL_JD_UNION);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- return super.onOptionsItemSelected(item);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void initViews(Bundle savedInstanceState) {
|
|
|
- et_goods_title = findViewById(R.id.et_goods_title);
|
|
|
- et_cover_url = findViewById(R.id.et_cover_url);
|
|
|
- et_video_url = findViewById(R.id.et_video_url);
|
|
|
- et_desc = findViewById(R.id.et_desc);
|
|
|
- et_reason = findViewById(R.id.et_reason);
|
|
|
- et_old_price = findViewById(R.id.et_old_price);
|
|
|
- et_rebate_all = findViewById(R.id.et_rebate_all);
|
|
|
- et_province = findViewById(R.id.et_province);
|
|
|
- et_coupon = findViewById(R.id.et_coupon);
|
|
|
- et_goods_url = findViewById(R.id.et_goods_url);
|
|
|
- et_sales_per_month = findViewById(R.id.et_sales_per_month);
|
|
|
- et_good_comment_percent = findViewById(R.id.et_good_comment_percent);
|
|
|
- et_shop_name = findViewById(R.id.et_shop_name);
|
|
|
- et_comment_num = findViewById(R.id.et_comment_num);
|
|
|
- cb_self = findViewById(R.id.cb_self);
|
|
|
- cb_enable = findViewById(R.id.cb_enable);
|
|
|
- ViewTool.setOnClickListener(this, this, new int[]{R.id.btn_add_goods});
|
|
|
- Button btn_add_goods = findViewById(R.id.btn_add_goods);
|
|
|
-
|
|
|
- mGoodsBean = (GoodsBean) getIntent().getSerializableExtra(KEY_MODIFY_GOODS);
|
|
|
- if (mGoodsBean != null) {
|
|
|
- initGoods();
|
|
|
- setTitle("更新商品");
|
|
|
- btn_add_goods.setText("立即更新");
|
|
|
- } else {
|
|
|
- setTitle("上架新的商品");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void initGoods() {
|
|
|
- et_goods_title.setText(mGoodsBean.title);
|
|
|
- et_cover_url.setText(mGoodsBean.coverImageUrl);
|
|
|
- et_video_url.setText(mGoodsBean.videoUrl);
|
|
|
- et_desc.setText(mGoodsBean.description);
|
|
|
- et_reason.setText(mGoodsBean.reason);
|
|
|
- et_old_price.setText(String.valueOf(mGoodsBean.oldPrice));
|
|
|
- et_rebate_all.setText(String.valueOf(mGoodsBean.rebate));
|
|
|
- et_province.setText(mGoodsBean.province);
|
|
|
- et_coupon.setText(mGoodsBean.couponInfo);
|
|
|
- et_goods_url.setText(mGoodsBean.goodsUrl);
|
|
|
- et_sales_per_month.setText(String.valueOf(mGoodsBean.salesPerMonth));
|
|
|
- et_good_comment_percent.setText(String.valueOf(mGoodsBean.goodCommentPercent));
|
|
|
- et_shop_name.setText(mGoodsBean.shopName);
|
|
|
- et_comment_num.setText(String.valueOf(mGoodsBean.commentNum));
|
|
|
- cb_self.setChecked(mGoodsBean.isSelfBusiness);
|
|
|
- cb_enable.setChecked(mGoodsBean.enable);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- switch (v.getId()) {
|
|
|
- case R.id.btn_add_goods:
|
|
|
- String title = et_goods_title.getEditableText().toString();
|
|
|
- String coverUrl = et_cover_url.getEditableText().toString();
|
|
|
- String videoUrl = et_video_url.getEditableText().toString();
|
|
|
- String description = et_desc.getEditableText().toString();
|
|
|
- String reason = et_reason.getEditableText().toString();
|
|
|
- long oldPrice = Long.parseLong(et_old_price.getEditableText().toString());
|
|
|
- long rebate = Long.parseLong(et_rebate_all.getEditableText().toString());
|
|
|
- long nowPrice = oldPrice - rebate/2;
|
|
|
- String province = et_province.getEditableText().toString();
|
|
|
- String shopName = et_shop_name.getEditableText().toString();
|
|
|
- String coupon = et_coupon.getEditableText().toString();
|
|
|
- String goodsUrl = et_goods_url.getEditableText().toString();
|
|
|
- String salesPerMonth = et_sales_per_month.getEditableText().toString();
|
|
|
- String goodCommentPercent = et_good_comment_percent.getEditableText().toString();
|
|
|
- String commentNum = et_comment_num.getEditableText().toString();
|
|
|
- boolean isSelf = cb_self.isChecked();
|
|
|
- boolean isEnable = cb_enable.isChecked();
|
|
|
-
|
|
|
- if (mGoodsBean == null) {
|
|
|
- mGoodsBean = new GoodsBean();
|
|
|
- }
|
|
|
- mGoodsBean.title = title;
|
|
|
- mGoodsBean.coverImageUrl = coverUrl;
|
|
|
- mGoodsBean.videoUrl = videoUrl;
|
|
|
- mGoodsBean.description = description;
|
|
|
- mGoodsBean.reason = reason;
|
|
|
- mGoodsBean.oldPrice = oldPrice;
|
|
|
- mGoodsBean.nowPrice = nowPrice;
|
|
|
- mGoodsBean.rebate = rebate;
|
|
|
- mGoodsBean.province = province;
|
|
|
- mGoodsBean.shopName = shopName;
|
|
|
- mGoodsBean.couponInfo = coupon;
|
|
|
- mGoodsBean.goodsUrl = goodsUrl;
|
|
|
- mGoodsBean.salesPerMonth = Long.parseLong(salesPerMonth);
|
|
|
- mGoodsBean.goodCommentPercent = Double.parseDouble(goodCommentPercent);
|
|
|
- mGoodsBean.commentNum = Long.parseLong(commentNum);
|
|
|
- mGoodsBean.isSelfBusiness = isSelf;
|
|
|
- mGoodsBean.enable = isEnable;
|
|
|
- mGoodsBean.hasCoupon = !TextUtils.isEmpty(coupon);
|
|
|
-
|
|
|
- showLoading();
|
|
|
- presenter.addGoods(mGoodsBean);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onAddGoodsResult(boolean success, String message) {
|
|
|
- dismissLoading();
|
|
|
- ToastTool.showShort(message);
|
|
|
- if (success) {
|
|
|
- Intent intent = getIntent();
|
|
|
- intent.putExtra(KEY_MODIFY_GOODS, mGoodsBean);
|
|
|
- setResult(RESULT_OK, intent);
|
|
|
- finish();
|
|
|
- }
|
|
|
- }
|
|
|
-}
|