zoukankan      html  css  js  c++  java
  • STD二手图书交流平台团队博客-商品属性与操作

    更新完善商品属性 使得商品信息更加全面 形象更加立体

    便于买家进行判断和分析

    实现对商品的操作 加入购物车以及购买支付的功能

    遇到问题:商品支付不能跳转 并未得到权限

    商品细节

    package com.example.secondhand;

    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.TextView;

    import androidx.appcompat.app.AppCompatActivity;


    import static com.example.secondhand.UiUtils.getContext;


    //商品细节显示

    public class DetailActivity extends AppCompatActivity {
    ImageView ivGoodsPic;
    TextView tvGoodsName;
    TextView tvGoodsPrice;
    TextView tvGoodsCategory;
    TextView tvGoodsPhone;
    TextView tvGoodsTime;
    Button btnAddPurchase;
    Button btnAddBuycar;
    TextView tvLiuyan;
    String id;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    ivGoodsPic = findViewById(R.id.ivGoodsPic);
    tvGoodsName = findViewById(R.id.tvGoodsName);
    tvGoodsPrice = findViewById(R.id.tvGoodsPrice);
    tvGoodsCategory = findViewById(R.id.tvGoodsCategory);
    tvGoodsPhone = findViewById(R.id.tvGoodsPhone);
    tvGoodsTime = findViewById(R.id.tvGoodsTime);
    btnAddBuycar = findViewById(R.id.btnAddBuycar);
    btnAddPurchase = findViewById(R.id.btnAddPurchase);
    tvLiuyan = findViewById(R.id.tvLiuyan);
    Bundle b = getIntent().getExtras();
    if (b != null) {
    Bitmap bitmap = b.getParcelable("bitmap");
    ivGoodsPic.setImageBitmap(bitmap);
    tvGoodsName.setText("商品名称:"+b.getString("商品名称:"));
    tvGoodsPrice.setText("商品价格:"+b.getString("商品价格:"));
    tvGoodsCategory.setText("商品分类:"+b.getString("商品分类:")+ "¥");
    tvGoodsPhone.setText("联系电话:"+b.getString("联系电话:"));
    tvGoodsTime.setText("发布时间:"+b.getString("发布时间:"));
    btnAddBuycar.setOnClickListener(listener1);
    btnAddPurchase.setOnClickListener(listener2);
    tvLiuyan.setOnClickListener(listener3);
    id=b.getString("goodsId");
    }
    }
    private View.OnClickListener listener3= new View.OnClickListener(){
    @Override
    public void onClick(View v) {
    Bundle b = getIntent().getExtras();
    Intent intent = new Intent(getContext(), CommentActivity.class);
    intent.putExtras(b);
    startActivity(intent);
    }
    };

    private View.OnClickListener listener2= new View.OnClickListener(){
    @Override
    public void onClick(View v) {
    String goodsId = id;
    int checkId;
    System.out.println("goodsId : " + goodsId);
    int raw = ProductDao.getInstance().updateGoodsBuyed(goodsId);
    if (raw > 0){
    showDropOutDialog();
    }else {
    UiUtils.toast("购买失败!");
    }
    }
    };

    private void showDropOutDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("提示");
    builder.setMessage("请确认是否支付?");
    builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    UiUtils.toast("支付成功");
    }
    });
    builder.setNegativeButton("取消",new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
    }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
    }

    private View.OnClickListener listener1 = new View.OnClickListener(){
    @Override
    public void onClick(View v) {
    //UiUtils.toast("已加入购物车");
    String goodsId1 = id;
    System.out.println("goodsId : " + goodsId1);
    int raw1 = ProductDao.getInstance().updateGoodsAddBuyCar(goodsId1);
    if (raw1 > 0){
    UiUtils.toast("已加入购物车");
    }else {
    UiUtils.toast("加入失败");
    }
    }
    };
    }

     

  • 相关阅读:
    原生AJAX基础讲解及兼容处理
    JS子元素oumouseover触发父元素onmouseout
    IE6常见bug
    让IE6支持position:fixed的方法,CSS expression与JavaScript eval讲解
    Alpha通道
    网络游戏开发前的pixel像素画习作
    网络游戏开发其一(游戏美工)
    周内琐记
    地图重置与各项绘图优化
    四足机器人搭建尝试
  • 原文地址:https://www.cnblogs.com/jz-no-bug/p/14760270.html
Copyright © 2011-2022 走看看