完成购买商品功能

master
fangshicai 3 years ago
parent 45ee16f6fb
commit 1ca1bdf37d

@ -3,11 +3,11 @@
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/HP/Desktop/android_Course_setting/androidF/android_course_design/app/src/main/res/layout/goods_show_item.xml" value="0.25" />
<entry key="..\:/Users/HP/Desktop/android_Course_setting/androidF/android_course_design/app/src/main/res/layout/item_stagger.xml" value="0.3729166666666667" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/add_shopping_cart_24.xml" value="0.108" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/baseline_account_circle_18.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/baseline_account_circle_20.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/baseline_account_circle_24.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/baseline_add_shopping_cart_24.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/baseline_explore_24.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/baseline_favorite_24.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/baseline_feedback_24.xml" value="0.1345" />
@ -21,15 +21,22 @@
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/ic_person_outline_black_24dp.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/ic_visibility_black_24dp.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/drawable/ic_visibility_off_black_24dp.xml" value="0.1345" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/activity_confirm_purchase.xml" value="0.2" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/activity_detail.xml" value="0.11354166666666667" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/activity_home_page.xml" value="0.152" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/activity_goods_details.xml" value="0.1" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/activity_home_page.xml" value="0.2" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/activity_login.xml" value="0.176" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/activity_main.xml" value="0.1" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_home_page.xml" value="0.4" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_goods_type.xml" value="0.15208333333333332" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_home_page.xml" value="0.12" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_message_page.xml" value="0.13229166666666667" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_my_page.xml" value="0.13229166666666667" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_shop_page.xml" value="0.1837916063675832" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/list_good_stype_item.xml" value="0.264" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_phone.xml" value="0.10572916666666667" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_publish_page.xml" value="0.264" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/fragment_shop_page.xml" value="0.2" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/goods_show_item.xml" value="0.128" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/item_stagger.xml" value="0.2" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/layout/list_good_stype_item.xml" value="0.2" />
<entry key="..\:/andriod/Android_Couser_Design/app/src/main/res/menu/bottom_navigation_menu.xml" value="0.176" />
</map>
</option>

@ -4,6 +4,9 @@ plugins {
android {
compileSdk 32
viewBinding {
enabled = true
}
defaultConfig {
applicationId "com.android"

@ -26,31 +26,35 @@
android:theme="@style/Theme.Android_Couser_Design"
tools:targetApi="31">
<activity
android:name=".activity.GoodsDetailsActivity"
android:launchMode="singleTask"
android:name=".activity.ConfirmPurchaseActivity"
android:exported="false" />
<activity
android:name=".activity.GoodsDetailsActivity"
android:exported="false"
android:launchMode="singleTask" />
<activity
android:name=".activity.HomePageActivity"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
android:exported="false"
android:launchMode="singleTask">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".activity.LoginActivity"
android:exported="false">
android:exported="true"
android:launchMode="singleTask">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.android.MainActivity"></activity>
<activity android:name="com.android.MainActivity" />
</application>
</manifest>

@ -0,0 +1,129 @@
package com.android.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.android.R;
import com.android.bean.Good;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.bean.postBean.UserPurchase;
import com.android.databinding.ActivityConfirmPurchaseBinding;
import com.android.databinding.ActivityMainBinding;
import com.android.model.purchase.GoodsTradeListener;
import com.android.model.purchase.GoodsTradingModel;
import com.android.model.purchase.GoodsTradingModelimpl;
import com.android.utils.ToastUtil;
import com.bumptech.glide.Glide;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public class ConfirmPurchaseActivity extends AppCompatActivity implements View.OnClickListener, GoodsTradeListener {
private Good goods;
private User user;
private GoodsTradingModel tradingModel;
private UserPurchase userPurchase;
//视图绑定
private ActivityConfirmPurchaseBinding binding;
private View view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//注册eventbus
EventBus.getDefault().register(this);
// setContentView(R.layout.activity_confirm_purchase);
//初始化binding
binding = ActivityConfirmPurchaseBinding.inflate(getLayoutInflater());
view = binding.getRoot();
setContentView(view);
//初始化View
initView();
tradingModel = new GoodsTradingModelimpl();
//设置购买按钮监听器
binding.btnConfirm.setOnClickListener(this);
}
private void initView() {
if (goods != null){
binding.tvPrice.setText(goods.getPrice().toString());
binding.tvTotalPrice.setText(goods.getPrice().toString());
binding.tvDesc.setText(goods.getContent());
binding.tvAddress.setText(goods.getAddr());
Glide.with(this)
.load(goods.getImageUrlList().get(0))
.into(binding.ivPic);
}
}
//拿取点进来的商品数据
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
public void getGoods(Good data){
if(data != null){
this.goods = data;
Log.e("Goods",goods.getImageUrlList().get(0).toString());
}else {
Log.e("Goods","获取失败");
}
}
//拿取点进来的用户数据
@Subscribe(threadMode = ThreadMode.POSTING,sticky = true)
public void getLoginUser(ResponseData<User> responseData){
this.user = responseData.getData();
}
@Override
protected void onDestroy() {
//解注eventbus
super.onDestroy();
EventBus.getDefault().unregister(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btn_confirm:
onPurchase();
Log.e("1",goods.getId().toString());
break;
}
}
private void onPurchase() {
userPurchase = new UserPurchase();
userPurchase.setGoodsId(goods.getId());
userPurchase.setPrice(goods.getPrice());
userPurchase.setBuyerId(user.getId());
userPurchase.setSellerId(goods.gettUserId());
tradingModel.goodsTrading(this,userPurchase);
}
@Override
public void onSuccessGoodsTrading(ResponseData<String> responseData) {
Log.e("ConfirmPurchaseActivity",String.valueOf(responseData.getCode()));
if(responseData.getCode() == 200){
ToastUtil.showMsg(this,"购买商品成功");
Intent intent = new Intent(this, HomePageActivity.class);
startActivity(intent);
}
}
@Override
public void onFail(ResponseData<String> responseData) {
}
}

@ -2,18 +2,47 @@ package com.android.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.R;
import com.android.bean.Good;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.bumptech.glide.Glide;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public class GoodsDetailsActivity extends AppCompatActivity {
private Good good;
public class GoodsDetailsActivity extends AppCompatActivity implements View.OnClickListener{
private Good goods;
private User user;
private ImageView ivHeadPortrait;
private TextView tvUsrName;
private TextView tvLocation;
private TextView tvPrice;
private TextView tvDesc;
private ImageView ivPic;
private Button btnComment;
private Button btnCollect;
private Button btnTalk;
private Button btnCart;
private String headPortrait;
private String usrName;
private String location;
private String price;
private String desc;
private String picUrl;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -21,19 +50,74 @@ public class GoodsDetailsActivity extends AppCompatActivity {
setContentView(R.layout.activity_goods_details);
//注册EventBus
EventBus.getDefault().register(this);
initData();
initView();
//点击购物车按钮
purchase();
}
private void purchase() {
btnCart.setOnClickListener(this);
}
private void initData() {
if (goods != null){
usrName = goods.getUsername();
location = goods.getAddr();
price = goods.getPrice().toString();
desc = goods.getContent();
picUrl = goods.getImageUrlList().get(0).toString();
}
}
//拿取数据
private void initView() {
tvUsrName = findViewById(R.id.tv_username);
tvLocation = findViewById(R.id.tv_location);
tvPrice = findViewById(R.id.tv_price);
tvDesc = findViewById(R.id.tv_desc);
ivPic = findViewById(R.id.iv_pic);
btnCart = findViewById(R.id.btn_buy_cart);
btnComment = findViewById(R.id.btn_comment);
btnCollect = findViewById(R.id.btn_collect);
btnTalk = findViewById(R.id.btn_talk);
if (usrName != null)
tvUsrName.setText(usrName);
if (location != null)
tvLocation.setText(location);
if (price != null)
tvPrice.setText(price);
if (desc != null)
tvDesc.setText(desc);
if (picUrl != null){
Glide.with(this)
.load(picUrl)
.into(ivPic);
}
}
//拿取点进来的商品数据
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
public void getGoods(Good data){
if(data != null){
this.good = data;
Log.e("GoodsDetailsActivity",good.getContent());
this.goods = data;
Log.e("Goods",goods.getImageUrlList().get(0).toString());
}else {
Log.e("GoodsDetailsActivity","获取失败");
Log.e("Goods","获取失败");
}
}
//拿取点进来的用户数据
@Subscribe(threadMode = ThreadMode.POSTING,sticky = true)
public void getLoginUser(ResponseData<User> responseData){
this.user = responseData.getData();
}
@ -43,4 +127,14 @@ public class GoodsDetailsActivity extends AppCompatActivity {
EventBus.getDefault().unregister(this);
super.onDestroy();
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btn_buy_cart:
Intent intent = new Intent(this,ConfirmPurchaseActivity.class);
startActivity(intent);
break;
}
}
}

@ -13,7 +13,7 @@ import com.android.R;
import com.android.activity.fragment.HomePageFragment;
import com.android.activity.fragment.MessagePageFragment;
import com.android.activity.fragment.MyPageFragment;
import com.android.activity.fragment.ShopCarPageFragment;
import com.android.activity.fragment.PublishProductFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView;
import com.google.android.material.navigation.NavigationView;
@ -71,7 +71,7 @@ public class HomePageActivity extends AppCompatActivity implements BottomNavigat
break;
case R.id.item_shop:
fragmentTransaction.replace(R.id.fragment_container, new ShopCarPageFragment());
fragmentTransaction.replace(R.id.fragment_container, new PublishProductFragment());
fragmentTransaction.commit();
break;
case R.id.item_home:

@ -24,7 +24,6 @@ import com.android.activity.adapter.StaggerAdapter;
import com.android.bean.Good;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.utils.eventBus.EventMsg;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

@ -24,7 +24,6 @@ import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.model.goods.GoodsListener;
import com.android.model.goods.GoodsModelimpl;
import com.android.utils.eventBus.EventMsg;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

@ -12,10 +12,9 @@ import com.android.R;
/**
* A simple {@link Fragment} subclass.
* Use the {@link ShopCarPageFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ShopCarPageFragment extends Fragment {
public class PublishProductFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
@ -26,7 +25,7 @@ public class ShopCarPageFragment extends Fragment {
private String mParam1;
private String mParam2;
public ShopCarPageFragment() {
public PublishProductFragment() {
// Required empty public constructor
}
@ -39,8 +38,8 @@ public class ShopCarPageFragment extends Fragment {
* @return A new instance of fragment ShopPageFragment.
*/
// TODO: Rename and change types and number of parameters
public static ShopCarPageFragment newInstance(String param1, String param2) {
ShopCarPageFragment fragment = new ShopCarPageFragment();
public static PublishProductFragment newInstance(String param1, String param2) {
PublishProductFragment fragment = new PublishProductFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
@ -61,6 +60,6 @@ public class ShopCarPageFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_shop_page, container, false);
return inflater.inflate(R.layout.fragment_publish_page, container, false);
}
}

@ -0,0 +1,49 @@
package com.android.bean.postBean;
import com.google.gson.annotations.SerializedName;
public class UserPurchase {
@SerializedName("buyerId")
private Long buyerId;
@SerializedName("goodsId")
private Long goodsId;
@SerializedName("price")
private Integer price;
@SerializedName("sellerId")
private Long sellerId;
public UserPurchase() {
}
public Long getBuyerId() {
return buyerId;
}
public void setBuyerId(Long buyerId) {
this.buyerId = buyerId;
}
public Long getGoodsId() {
return goodsId;
}
public void setGoodsId(Long goodsId) {
this.goodsId = goodsId;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public Long getSellerId() {
return sellerId;
}
public void setSellerId(Long sellerId) {
this.sellerId = sellerId;
}
}

@ -1,6 +1,5 @@
package com.android.model.goods;
import com.android.bean.Good;
import com.android.bean.GoodRecords;
import com.android.bean.GoodsType;
import com.android.bean.ResponseData;
@ -8,7 +7,6 @@ import com.android.bean.ResponseData;
import java.util.List;
import java.util.Map;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import retrofit2.http.GET;
import retrofit2.http.Headers;

@ -10,6 +10,7 @@ import com.android.bean.GoodsType;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.model.login.LoginListener;
import com.android.utils.constraint.Constants;
import java.util.List;
import java.util.Map;
@ -39,10 +40,11 @@ public class GoodsModelimpl implements GoodsModel{
@Override
public void getAllGoodsType(GoodsListener goodsListener) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://47.107.52.7:88/member/")
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build();
GoodsHttp_interface httpInterface =
retrofit.create(GoodsHttp_interface.class);
Observable<ResponseData<List<GoodsType>>> observable
@ -77,7 +79,7 @@ public class GoodsModelimpl implements GoodsModel{
@Override
public void getAllGood(GoodsListener goodsListener) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://47.107.52.7:88/member/")
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build();
@ -88,7 +90,7 @@ public class GoodsModelimpl implements GoodsModel{
Observable<ResponseData<GoodRecords>> observable
= httpInterface.sendGetAllGood(6l, map);
= httpInterface.sendGetAllGood(user.getId(), map);
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())

@ -4,6 +4,7 @@ import android.util.Log;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.utils.constraint.Constants;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
@ -27,7 +28,7 @@ public class LoginModelImpl implements LoginModel{
@Override
public void longin(String account,String phoneCode,final LoginListener loginListener) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://47.107.52.7:88/member/")
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build();
@ -73,7 +74,7 @@ public class LoginModelImpl implements LoginModel{
@Override
public void sendVerifyCode(String phoneNumber,final LoginListener loginListener) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://47.107.52.7:88/member/")
.baseUrl(Constants.BASE_URL)
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
@ -116,7 +117,7 @@ public class LoginModelImpl implements LoginModel{
@Override
public void registerUser(String phoneNumber, String code,final LoginListener loginListener) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://47.107.52.7:88/member/")
.baseUrl(Constants.BASE_URL)
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();

@ -0,0 +1,8 @@
package com.android.model.purchase;
import com.android.bean.ResponseData;
public interface GoodsTradeListener {
void onSuccessGoodsTrading(ResponseData<String> responseData);
void onFail(ResponseData<String> responseData);
}

@ -0,0 +1,8 @@
package com.android.model.purchase;
import com.android.bean.postBean.UserPurchase;
public interface GoodsTradingModel {
void goodsTrading(GoodsTradeListener goodsTradeListener,
UserPurchase userPurchase);
}

@ -0,0 +1,70 @@
package com.android.model.purchase;
import android.util.Log;
import com.android.bean.ResponseData;
import com.android.bean.postBean.UserPurchase;
import com.android.utils.constraint.Constants;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class GoodsTradingModelimpl implements GoodsTradingModel{
@Override
public void goodsTrading(GoodsTradeListener goodsTradeListener,
UserPurchase userPurchase) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://47.107.52.7:88/member/")
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build();
Purchase_interface anInterface
= retrofit.create(Purchase_interface.class);
Log.e("getBuyerId",userPurchase.getBuyerId().toString());
Log.e("getGoodsId",userPurchase.getGoodsId().toString());
Log.e("getPrice",userPurchase.getPrice().toString());
Log.e("sellerId",userPurchase.getSellerId().toString());
Observable<ResponseData<String>> observable
= anInterface.sendTrading(userPurchase.getBuyerId(),userPurchase.getGoodsId(),
userPurchase.getPrice(),userPurchase.getSellerId());
observable
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<ResponseData<String>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull ResponseData<String> responseData) {
goodsTradeListener.onSuccessGoodsTrading(responseData);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("GoodsTradingModelimpl","请求错误");
Log.e("GoodsTradingModelimpl",e.toString());
}
@Override
public void onComplete() {
}
});
}
}

@ -0,0 +1,24 @@
package com.android.model.purchase;
import com.android.bean.ResponseData;
import com.android.bean.postBean.UserPurchase;
import io.reactivex.rxjava3.core.Observable;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface Purchase_interface {
@FormUrlEncoded
@POST("tran/trading")
@Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<String>> sendTrading(@Field("buyerId") Long buyerId,
@Field("goodsId") Long goodsId,
@Field("price") Integer price,
@Field("sellerId") Long sellerId);
}

@ -0,0 +1,18 @@
package com.android.utils;
import android.content.Context;
import android.widget.Toast;
public class ToastUtil {
public static Toast mToast;
public static void showMsg(Context context, String msg)
{
if(mToast == null){
mToast = Toast.makeText(context, msg, Toast.LENGTH_LONG);
}else{
mToast.setText(msg);
}
mToast.show();
}
}

@ -1,6 +1,6 @@
package com.android.utils.constraint;
public class LoginConstraint {
public class Constants {
public static final String AppId_VALUE = "appId:b34ac21286ae45938add627b418a4871";
public static final String AppSecret_VALUE = "appId:b34ac21286ae45938add627b418a4871";
public static final String BASE_URL = "http://47.107.52.7:88/member/";

@ -1,41 +0,0 @@
package com.android.utils.eventBus;
import com.android.bean.Good;
import java.util.List;
public class EventMsg<T> {
private String msg;
private int status;
private T data;
public EventMsg(String msg, int status, T data) {
this.msg = msg;
this.status = status;
this.data = data;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.ConfirmPurchase">
<LinearLayout
android:id="@+id/ll_1"
android:layout_width="match_parent"
android:layout_height="150dp">
<ImageView
android:id="@+id/iv_pic"
android:layout_width="150dp"
android:layout_height="match_parent"/>
<LinearLayout
android:padding="20dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_desc"
android:textSize="15sp"
android:text="商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述商品详细描述"
android:layout_width="match_parent"
android:layout_height="75dp"
android:ellipsize="none"/>
<TextView
android:layout_marginTop="15dp"
android:textColor="#ff0000"
android:text="¥50"
android:id="@+id/tv_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_2"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@id/ll_1"
android:layout_marginLeft="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="卖家所在地" />
<TextView
android:id="@+id/tv_address"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:gravity="center_vertical"
android:text="地址" />
</LinearLayout>
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="100dp"-->
<!-- android:layout_below="@id/ll_2"-->
<!-- android:layout_marginLeft="30dp"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="match_parent"-->
<!-- android:gravity="center_vertical"-->
<!-- android:text="运费" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_express_fee"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:layout_marginRight="10dp"-->
<!-- android:text="¥0.00"-->
<!-- android:textColor="#ff0000" />-->
<!-- </RelativeLayout>-->
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:id="@+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:text="佣金:" />
<TextView
android:id="@+id/tv_total_price"
android:textColor="#FF0000"
android:textSize="17sp"
android:layout_toRightOf="@+id/tv_1"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:text="¥100.00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btn_confirm"
android:textSize="20sp"
android:text="确定"
android:textColor="#ffffff"
android:background="#FE4543"
android:layout_alignParentRight="true"
android:layout_width="120dp"
android:layout_height="match_parent"/>
</RelativeLayout>
</RelativeLayout>

@ -1,16 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="15dp"
tools:context=".activity.GoodsDetailsActivity">
<LinearLayout
android:id="@+id/layout_title"
android:layout_width="match_parent"
android:layout_height="50dp">
<ImageView
android:id="@+id/iv_head_portrait"
app:srcCompat="@drawable/head_portrait"
android:layout_width="50dp"
android:layout_height="50dp"/>
<LinearLayout
android:paddingLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:textColor="#000000"
android:id="@+id/tv_username"
android:textSize="15sp"
android:text="1158677160"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="3dp"
android:id="@+id/tv_location"
android:textSize="12sp"
android:text="桂林电子科技大学"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_price"
android:layout_below="@+id/layout_title"
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_marginTop="3dp"
android:text="¥"
android:textColor="#ff4242" />
<TextView
android:id="@+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="88.00"
android:textColor="#ff4242" />
</LinearLayout>
<TextView
android:id="@+id/tv_goods_show"
android:layout_width="wrap_content"
android:id="@+id/tv_desc"
android:layout_below="@+id/layout_price"
android:layout_marginTop="30dp"
android:text="商品描述"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/iv_pic"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_below="@id/tv_desc"
android:layout_marginTop="30dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/logo" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="商品详细页面"
android:gravity="center"
tools:ignore="MissingConstraints" />
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/btn_comment"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:background="#00000000"
android:drawableTop="@drawable/comment"
android:text="评论"
android:textColor="#8a8a8a" />
<Button
android:id="@+id/btn_collect"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/btn_comment"
android:background="#00000000"
android:drawableTop="@drawable/collect"
android:text="收藏"
android:textColor="#8a8a8a" />
<Button
android:id="@+id/btn_talk"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:background="#00000000"
android:drawableTop="@drawable/chat"
android:layout_toLeftOf="@id/btn_buy_cart"
android:text="聊一聊"
android:textColor="#8a8a8a" />
<Button
android:id="@+id/btn_buy_cart"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#00000000"
android:drawableTop="@drawable/cart"
android:text="购买"
android:textColor="#8a8a8a" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.fragment.PublishProductFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<EditText
android:id="@+id/et_desc"
android:gravity="start"
android:hint="商品描述"
android:layout_width="match_parent"
android:layout_height="270dp"/>
<ImageButton
android:scaleType="fitXY"
android:id="@+id/btn_add_image"
android:background="@drawable/addimageiv"
android:layout_width="100dp"
android:layout_height="100dp"/>
<TextView
android:gravity="left|center_vertical"
android:paddingLeft="30dp"
android:drawablePadding="5dp"
android:id="@+id/btn_location"
android:text="货物地址"
android:textColor="#8c8c8c"
android:layout_width="200dp"
android:layout_height="30dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:drawableLeft="@drawable/price"
android:layout_weight="1"
android:drawablePadding="10dp"
android:textSize="18sp"
android:text="价格"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="50dp"/>
<EditText
android:id="@+id/et_price"
android:layout_weight="1"
android:hint="开个价"
android:inputType="numberDecimal"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<Button
android:background="#00000000"
android:drawableTop="@drawable/release_orange"
android:id="@+id/btn_release"
android:text="发布"
android:layout_width="match_parent"
android:layout_height="50dp"/>
</LinearLayout>
</FrameLayout>

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.fragment.ShopCarPageFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="shop" />
</FrameLayout>

@ -4,23 +4,23 @@
<item
android:id="@+id/item_home"
android:enabled="true"
android:icon="@drawable/baseline_home_24"
android:icon="@drawable/home_fill"
android:title="首页"
/>
<item
android:id="@+id/item_message"
android:enabled="true"
android:icon="@drawable/baseline_explore_24"
android:icon="@drawable/message_fill"
android:title="消息"/>
<item
android:id="@+id/item_shop"
android:enabled="true"
android:icon="@drawable/baseline_shopping_cart_24"
android:title="购物车"
android:icon="@drawable/releaseiv"
android:title="发布商品"
/>
<item
android:id="@+id/item_my"
android:enabled="true"
android:icon="@drawable/baseline_account_circle_24"
android:icon="@drawable/my_fill"
android:title="我的"/>
</menu>
Loading…
Cancel
Save