Commit 9080d187 authored by yangxuenan's avatar yangxuenan Committed by 杨秀秀

功能完善

parent c329aeb3
package com.xx.hbhconsumer.adapter; package com.xx.hbhconsumer.adapter;
import android.content.Context; import android.content.Context;
import android.view.View;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.xx.hbhconsumer.R; import com.xx.hbhconsumer.R;
import com.xx.hbhconsumer.data.http.respons.CollectionBean; import com.xx.hbhconsumer.data.http.respons.CollectionBean;
import com.xx.hbhconsumer.data.http.respons.OrderBean;
import com.xx.hbhconsumer.databinding.ItemCollectionGoodsBinding; import com.xx.hbhconsumer.databinding.ItemCollectionGoodsBinding;
import com.xx.hbhconsumer.databinding.ItemNewProductsGoodsBinding; import com.xx.hbhconsumer.ui.mycollection.MyCollectionViewModel;
import com.xx.hbhconsumer.utils.RetrofitClient; import com.xx.hbhconsumer.utils.RetrofitClient;
import com.xx.xxviewlibrary.base.xxBaseRecyclerViewAdapter; import com.xx.xxviewlibrary.base.xxBaseRecyclerViewAdapter;
...@@ -16,9 +16,12 @@ import me.goldze.mvvmhabit.utils.StringUtils; ...@@ -16,9 +16,12 @@ import me.goldze.mvvmhabit.utils.StringUtils;
public class CollectionGoodsAdapter extends xxBaseRecyclerViewAdapter<ItemCollectionGoodsBinding, CollectionBean> { public class CollectionGoodsAdapter extends xxBaseRecyclerViewAdapter<ItemCollectionGoodsBinding, CollectionBean> {
public CollectionGoodsAdapter(Context context) { private MyCollectionViewModel myCollectionViewModel;
public CollectionGoodsAdapter(Context context, MyCollectionViewModel myCollectionViewModel) {
super(context); super(context);
mContext = context; mContext = context;
this.myCollectionViewModel = myCollectionViewModel;
} }
@Override @Override
...@@ -36,6 +39,30 @@ public class CollectionGoodsAdapter extends xxBaseRecyclerViewAdapter<ItemCollec ...@@ -36,6 +39,30 @@ public class CollectionGoodsAdapter extends xxBaseRecyclerViewAdapter<ItemCollec
dataBind.tvGoodsName.setText(data.getCommodityName()); dataBind.tvGoodsName.setText(data.getCommodityName());
if (data.getEditState()) {
dataBind.radioSelectedGroup.setVisibility(View.VISIBLE);
} else {
dataBind.radioSelectedGroup.setVisibility(View.GONE);
}
if (data.getChecked()) {
dataBind.rbCheckState.setChecked(true);
} else {
dataBind.radioSelectedGroup.clearCheck();
}
dataBind.rbCheckState.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (data.getChecked()) {
data.setChecked(false);
dataBind.radioSelectedGroup.clearCheck();
} else {
data.setChecked(true);
}
myCollectionViewModel.checkItem();
}
});
String price = data.getCommodityPrice(); String price = data.getCommodityPrice();
if (!StringUtils.isEmpty(price) && price.contains(".")) { if (!StringUtils.isEmpty(price) && price.contains(".")) {
dataBind.tvPriceInteger.setText(price.split("\\.")[0]); dataBind.tvPriceInteger.setText(price.split("\\.")[0]);
......
package com.xx.hbhconsumer.adapter; package com.xx.hbhconsumer.adapter;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.recyclerview.widget.GridLayoutManager;
import com.xx.hbhconsumer.R; import com.xx.hbhconsumer.R;
import com.xx.hbhconsumer.data.http.respons.CategoryBean; import com.xx.hbhconsumer.data.http.respons.CategoryBean;
import com.xx.hbhconsumer.databinding.ItemSecondCategoryBinding; import com.xx.hbhconsumer.databinding.ItemSecondCategoryBinding;
import com.xx.hbhconsumer.ui.shop.ShopSearchActivity;
import com.xx.xxviewlibrary.base.xxBaseRecyclerViewAdapter; import com.xx.xxviewlibrary.base.xxBaseRecyclerViewAdapter;
public class SecondCategoryAdapter extends xxBaseRecyclerViewAdapter<ItemSecondCategoryBinding, CategoryBean> { public class SecondCategoryAdapter extends xxBaseRecyclerViewAdapter<ItemSecondCategoryBinding, CategoryBean> {
......
...@@ -27,8 +27,8 @@ public class ThirdCategoryAdapter extends xxBaseRecyclerViewAdapter<ItemThirdCat ...@@ -27,8 +27,8 @@ public class ThirdCategoryAdapter extends xxBaseRecyclerViewAdapter<ItemThirdCat
protected void covert(ItemThirdCategoryBinding dataBind, CategoryBean data, int position) { protected void covert(ItemThirdCategoryBinding dataBind, CategoryBean data, int position) {
// 将接口调出来的布局遍历上去 // 将接口调出来的布局遍历上去
dataBind.setCategoryBean(data); dataBind.setCategoryBean(data);
dataBind.tvCategoryName.setText(data.getCategoryName());
Glide.with(mContext).load(RetrofitClient.baseImgUrl + data.getCategoryImg()) Glide.with(mContext).load(RetrofitClient.baseImgUrl + data.getCategoryImgFile().getFilePath())
.into(dataBind.ivCategoryImage); .into(dataBind.ivCategoryImage);
} }
} }
...@@ -381,4 +381,11 @@ interface ApiService { ...@@ -381,4 +381,11 @@ interface ApiService {
@POST("app/user/closure-with-reason") @POST("app/user/closure-with-reason")
fun logoff(@Body requestBody: RequestBody): Observable<BaseResponse<Boolean>> fun logoff(@Body requestBody: RequestBody): Observable<BaseResponse<Boolean>>
/**
* 查询活动列表信息
*/
@Headers("Content-type:application/json")
@GET("app/system-info/get-version")
fun getVersion(): Observable<BaseResponse<String>>
} }
\ No newline at end of file
...@@ -2,9 +2,6 @@ package com.xx.hbhconsumer.data.http.requst; ...@@ -2,9 +2,6 @@ package com.xx.hbhconsumer.data.http.requst;
import com.xx.hbhconsumer.data.http.BaseRespons; import com.xx.hbhconsumer.data.http.BaseRespons;
import com.xx.hbhconsumer.data.http.respons.CollectionBean; import com.xx.hbhconsumer.data.http.respons.CollectionBean;
import com.xx.hbhconsumer.data.http.respons.ShopBean;
import java.util.List;
import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.Observable;
import me.goldze.mvvmhabit.http.BasePageResponse; import me.goldze.mvvmhabit.http.BasePageResponse;
...@@ -18,4 +15,11 @@ public class CollectionRequest extends BaseRespons { ...@@ -18,4 +15,11 @@ public class CollectionRequest extends BaseRespons {
public Observable<BasePageResponse<CollectionBean>> memberCollectionList() { public Observable<BasePageResponse<CollectionBean>> memberCollectionList() {
return getApiService().memberCollectionList(); return getApiService().memberCollectionList();
} }
/**
* 低价好物商品列表
*/
public Observable<BaseResponse<Integer>> cancelCollection(String businessIds) {
return getApiService().cancelCollection(businessIds);
}
} }
...@@ -15,9 +15,9 @@ import okhttp3.RequestBody; ...@@ -15,9 +15,9 @@ import okhttp3.RequestBody;
public class GoodsRequest extends BaseRespons { public class GoodsRequest extends BaseRespons {
public Observable<BaseResponse<String>> memberCollection(String merchantCommodityId) { public Observable<BaseResponse<String>> memberCollection(String merchantCommodityId, String flag) {
ApiParams<MemberCollectionRequestBody> apiParams = new ApiParams<>(); ApiParams<MemberCollectionRequestBody> apiParams = new ApiParams<>();
MemberCollectionRequestBody requestBody = new MemberCollectionRequestBody(merchantCommodityId); MemberCollectionRequestBody requestBody = new MemberCollectionRequestBody(flag, merchantCommodityId);
RequestBody body = apiParams.setParams(requestBody); RequestBody body = apiParams.setParams(requestBody);
return getApiService().memberCollection(body); return getApiService().memberCollection(body);
} }
...@@ -49,9 +49,11 @@ public class GoodsRequest extends BaseRespons { ...@@ -49,9 +49,11 @@ public class GoodsRequest extends BaseRespons {
} }
class MemberCollectionRequestBody { class MemberCollectionRequestBody {
String flag;
String merchantCommodityId; String merchantCommodityId;
public MemberCollectionRequestBody(String merchantCommodityId) { public MemberCollectionRequestBody(String flag, String merchantCommodityId) {
this.flag = flag;
this.merchantCommodityId = merchantCommodityId; this.merchantCommodityId = merchantCommodityId;
} }
} }
......
package com.xx.hbhconsumer.data.http.requst;
import com.xx.hbhconsumer.data.http.BaseRespons;
import io.reactivex.rxjava3.core.Observable;
import me.goldze.mvvmhabit.http.BaseResponse;
public class SettingsRequest extends BaseRespons {
public Observable<BaseResponse<String>> getVersion() {
return getApiService().getVersion();
}
}
package com.xx.hbhconsumer.data.http.respons package com.xx.hbhconsumer.data.http.respons
import com.github.gzuliyujiang.wheelview.contract.TextProvider data class CategoryBean(
val categoryCoding: String,
class CategoryBean( val categoryId: String,
var delFlag: String, val categoryImg: String,
var categoryId: String, val categoryImgFile: CategoryImgFile,
var pid: String, val categoryLevel: Int,
var superCategory: String, val categoryName: String,
var categoryCoding: String, val children: List<CategoryBean>,
var categoryName: String, val delFlag: String,
var categoryImg: String, val pid: String,
var categoryLevel: Int, val remark: String,
var status: String, val status: String,
var children: MutableList<CategoryBean>, val superCategory: String,
var checked: Boolean var checked: Boolean
) : TextProvider{ )
override fun provideText(): String {
return categoryName; data class CategoryImgFile(
} val businessId: String,
} val filePath: String,
\ No newline at end of file val newFileName: String,
val originalFileName: String,
val url: String
)
\ No newline at end of file
...@@ -17,6 +17,8 @@ class CollectionBean( ...@@ -17,6 +17,8 @@ class CollectionBean(
var remark: String, var remark: String,
var updateBy: String, var updateBy: String,
var updateTime: String, var updateTime: String,
var checked: Boolean,
var editState: Boolean
) { ) {
} }
...@@ -7,6 +7,14 @@ import me.goldze.mvvmhabit.utils.SPUtils ...@@ -7,6 +7,14 @@ import me.goldze.mvvmhabit.utils.SPUtils
object LocalData { object LocalData {
/**
* 存储用户信息
*/
@JvmStatic
fun delAllData() {
SPUtils.getInstance().clear()
}
/** /**
* 存储用户信息 * 存储用户信息
*/ */
......
...@@ -85,7 +85,7 @@ public class GoodsDetailViewModel extends BaseViewModel<GoodsRequest> { ...@@ -85,7 +85,7 @@ public class GoodsDetailViewModel extends BaseViewModel<GoodsRequest> {
} }
private void memberCollection() { private void memberCollection() {
model.memberCollection(goodsId) model.memberCollection(goodsId, "0")
.compose(RxUtils.schedulersTransformer()) //线程调度 .compose(RxUtils.schedulersTransformer()) //线程调度
.doOnSubscribe(GoodsDetailViewModel.this) .doOnSubscribe(GoodsDetailViewModel.this)
.doOnSubscribe(new Consumer<Disposable>() { .doOnSubscribe(new Consumer<Disposable>() {
...@@ -103,24 +103,20 @@ public class GoodsDetailViewModel extends BaseViewModel<GoodsRequest> { ...@@ -103,24 +103,20 @@ public class GoodsDetailViewModel extends BaseViewModel<GoodsRequest> {
public void onError(String Error) { public void onError(String Error) {
dismissDialog(); dismissDialog();
} }
}); });
} }
private void cancelCollection() { private void cancelCollection() {
model.cancelCollection(goodsId) model.memberCollection(goodsId, "1")
.compose(RxUtils.schedulersTransformer()) //线程调度 .compose(RxUtils.schedulersTransformer()) //线程调度
.doOnSubscribe(GoodsDetailViewModel.this) .doOnSubscribe(GoodsDetailViewModel.this)
.doOnSubscribe(new Consumer<Disposable>() { .doOnSubscribe(new Consumer<Disposable>() {
@Override @Override
public void accept(Disposable disposable) throws Exception { public void accept(Disposable disposable) throws Exception {
} }
}).subscribe(new ApiDisposableObserver<Integer>() { }).subscribe(new ApiDisposableObserver<String>() {
@Override @Override
public void onSuccess(Integer resultBean) { public void onSuccess(String resultBean) {
ToastUtils.showShort("取消收藏成功!"); ToastUtils.showShort("取消收藏成功!");
collectionState.postValue("0"); collectionState.postValue("0");
} }
...@@ -130,9 +126,6 @@ public class GoodsDetailViewModel extends BaseViewModel<GoodsRequest> { ...@@ -130,9 +126,6 @@ public class GoodsDetailViewModel extends BaseViewModel<GoodsRequest> {
dismissDialog(); dismissDialog();
} }
}); });
} }
......
...@@ -7,6 +7,7 @@ import android.app.Application; ...@@ -7,6 +7,7 @@ import android.app.Application;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.xx.hbhconsumer.data.http.requst.LogoffRequest; import com.xx.hbhconsumer.data.http.requst.LogoffRequest;
import com.xx.hbhconsumer.data.local.LocalData;
import com.xx.hbhconsumer.ui.login.LoginActivity; import com.xx.hbhconsumer.ui.login.LoginActivity;
import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.disposables.Disposable;
...@@ -49,6 +50,7 @@ public class LogoffSecondStepViewModel extends BaseViewModel<LogoffRequest> { ...@@ -49,6 +50,7 @@ public class LogoffSecondStepViewModel extends BaseViewModel<LogoffRequest> {
@Override @Override
public void onSuccess(Boolean resultBean) { public void onSuccess(Boolean resultBean) {
ToastUtils.showShort("注销成功"); ToastUtils.showShort("注销成功");
LocalData.delAllData();
startActivity(LoginActivity.class); startActivity(LoginActivity.class);
finish(); finish();
} }
......
...@@ -36,7 +36,7 @@ public class MyCollectionActivity extends BaseActivity<ActivityMyCollectionBindi ...@@ -36,7 +36,7 @@ public class MyCollectionActivity extends BaseActivity<ActivityMyCollectionBindi
GridLayoutManager manager = new GridLayoutManager(MyCollectionActivity.this,2); GridLayoutManager manager = new GridLayoutManager(MyCollectionActivity.this,2);
binding.rvGoodsList.setLayoutManager(manager); binding.rvGoodsList.setLayoutManager(manager);
//获取适配器上下文 //获取适配器上下文
CollectionGoodsAdapter collectionGoodsAdapter = new CollectionGoodsAdapter(MyCollectionActivity.this); CollectionGoodsAdapter collectionGoodsAdapter = new CollectionGoodsAdapter(MyCollectionActivity.this, viewModel);
//把adapterset进去 //把adapterset进去
binding.rvGoodsList.setAdapter(collectionGoodsAdapter); binding.rvGoodsList.setAdapter(collectionGoodsAdapter);
collectionGoodsAdapter.setOnItemClick(new xxBaseRecyclerViewAdapter.OnItemClick<CollectionBean>() { collectionGoodsAdapter.setOnItemClick(new xxBaseRecyclerViewAdapter.OnItemClick<CollectionBean>() {
...@@ -49,12 +49,25 @@ public class MyCollectionActivity extends BaseActivity<ActivityMyCollectionBindi ...@@ -49,12 +49,25 @@ public class MyCollectionActivity extends BaseActivity<ActivityMyCollectionBindi
viewModel.collectionList.observe(this, new Observer<List<CollectionBean>>() { viewModel.collectionList.observe(this, new Observer<List<CollectionBean>>() {
@Override @Override
public void onChanged(List<CollectionBean> collectionBeanList) { public void onChanged(List<CollectionBean> collectionBeanList) {
if (collectionBeanList.isEmpty()) {
binding.rvGoodsList.setVisibility(View.GONE);
binding.rlNoData.setVisibility(View.VISIBLE);
} else {
binding.rvGoodsList.setVisibility(View.VISIBLE);
binding.rlNoData.setVisibility(View.GONE);
}
collectionGoodsAdapter.mList = collectionBeanList; collectionGoodsAdapter.mList = collectionBeanList;
collectionGoodsAdapter.notifyDataSetChanged(); collectionGoodsAdapter.notifyDataSetChanged();
} }
}); });
viewModel.checkCount.observe(this, new Observer<Integer>() {
@Override
public void onChanged(Integer checkCount) {
binding.tvCheckCount.setText(checkCount.toString());
}
});
viewModel.editFlag.observe(this, new Observer<Boolean>() { viewModel.editFlag.observe(this, new Observer<Boolean>() {
@Override @Override
public void onChanged(Boolean editFlag) { public void onChanged(Boolean editFlag) {
......
...@@ -28,11 +28,14 @@ import me.goldze.mvvmhabit.binding.command.BindingCommand; ...@@ -28,11 +28,14 @@ import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.http.ApiDisposableObserver; import me.goldze.mvvmhabit.http.ApiDisposableObserver;
import me.goldze.mvvmhabit.http.ApiDisposablePageObserver; import me.goldze.mvvmhabit.http.ApiDisposablePageObserver;
import me.goldze.mvvmhabit.utils.RxUtils; import me.goldze.mvvmhabit.utils.RxUtils;
import me.goldze.mvvmhabit.utils.StringUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;
public class MyCollectionViewModel extends BaseViewModel<CollectionRequest> { public class MyCollectionViewModel extends BaseViewModel<CollectionRequest> {
public MutableLiveData<List<CollectionBean>> collectionList = new MutableLiveData<>(new ArrayList<>()); public MutableLiveData<List<CollectionBean>> collectionList = new MutableLiveData<>(new ArrayList<>());
public MutableLiveData<Boolean> editFlag = new MutableLiveData<>(false); public MutableLiveData<Boolean> editFlag = new MutableLiveData<>(false);
public MutableLiveData<Integer> checkCount = new MutableLiveData<>(0);
public MyCollectionViewModel(@NonNull Application application) { public MyCollectionViewModel(@NonNull Application application) {
super(application); super(application);
...@@ -97,7 +100,19 @@ public class MyCollectionViewModel extends BaseViewModel<CollectionRequest> { ...@@ -97,7 +100,19 @@ public class MyCollectionViewModel extends BaseViewModel<CollectionRequest> {
public BindingCommand manager = new BindingCommand(new BindingAction() { public BindingCommand manager = new BindingCommand(new BindingAction() {
@Override @Override
public void call() { public void call() {
if (collectionList.getValue().isEmpty()) {
ToastUtils.showShort("无收藏可管理");
return;
}
editFlag.postValue(true); editFlag.postValue(true);
List<CollectionBean> newList = new ArrayList<>();
for (CollectionBean collectionBean : collectionList.getValue()) {
collectionBean.setEditState(true);
newList.add(collectionBean);
}
collectionList.postValue(newList);
} }
}); });
...@@ -106,7 +121,51 @@ public class MyCollectionViewModel extends BaseViewModel<CollectionRequest> { ...@@ -106,7 +121,51 @@ public class MyCollectionViewModel extends BaseViewModel<CollectionRequest> {
@Override @Override
public void call() { public void call() {
editFlag.postValue(false); editFlag.postValue(false);
String businessIds = "";
for (CollectionBean collectionBean : collectionList.getValue()) {
if (collectionBean.getChecked()) {
businessIds += collectionBean.getBusinessId() + ",";
}
}
if (StringUtils.isEmpty(businessIds)) {
ToastUtils.showShort("请选择要取消收藏的商品");
return;
}
model.cancelCollection(businessIds)
.compose(RxUtils.schedulersTransformer()) //线程调度
// .compose(RxUtils.exceptionTransformer()) // 网络错误的异常转换, 这里可以换成自己的ExceptionHandle
.doOnSubscribe(MyCollectionViewModel.this)
.doOnSubscribe (new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
}
}).subscribe(new ApiDisposableObserver<Integer>() {
@Override
public void onSuccess(Integer resultBean) {
loadData();
editFlag.postValue(false);
ToastUtils.showShort("取消收藏成功");
}
@Override
public void onError(String Error) {
dismissDialog();
}
});
} }
}); });
public void checkItem() {
int count = 0;
for (CollectionBean collectionBean : collectionList.getValue()) {
if (collectionBean.getChecked()) {
count++;
}
}
checkCount.postValue(count);
}
} }
...@@ -36,40 +36,6 @@ public class ForgetPwdViewModel extends BaseViewModel<ForgetPwdRequest> { ...@@ -36,40 +36,6 @@ public class ForgetPwdViewModel extends BaseViewModel<ForgetPwdRequest> {
super(application, model); super(application, model);
} }
// 获取验证码
public BindingCommand getCode = new BindingCommand(new BindingAction() {
@Override
public void call() {
if (TextUtils.isEmpty(phone.get().toString())) {
ToastUtils.showShort("请输入手机号!");
return;
}
model.getCode(phone.get().toString())
.compose(RxUtils.schedulersTransformer()) //线程调度
.doOnSubscribe(ForgetPwdViewModel.this)
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
showDialog("正在获取验证码");
}
}).subscribe(new ApiDisposableObserver<String>() {
@Override
public void onSuccess(String resultBean) {
ToastUtils.showShort("已经发送成功");
dismissDialog();
}
@Override
public void onError(String Error) {
dismissDialog();
}
});
}
});
// 触发确认按钮 // 触发确认按钮
public BindingCommand confirm = new BindingCommand(new BindingAction() { public BindingCommand confirm = new BindingCommand(new BindingAction() {
@Override @Override
...@@ -100,6 +66,7 @@ public class ForgetPwdViewModel extends BaseViewModel<ForgetPwdRequest> { ...@@ -100,6 +66,7 @@ public class ForgetPwdViewModel extends BaseViewModel<ForgetPwdRequest> {
//是指token //是指token
Interceptor_TOKEN = "Bearer " + resultBean; Interceptor_TOKEN = "Bearer " + resultBean;
startActivity(LoginActivity.class); startActivity(LoginActivity.class);
finish();
} }
@Override @Override
......
...@@ -9,7 +9,7 @@ import com.xx.hbhconsumer.databinding.DialogLogoutBinding ...@@ -9,7 +9,7 @@ import com.xx.hbhconsumer.databinding.DialogLogoutBinding
import com.xx.xxviewlibrary.base.xxBaseDialog import com.xx.xxviewlibrary.base.xxBaseDialog
import me.jessyan.autosize.utils.AutoSizeUtils import me.jessyan.autosize.utils.AutoSizeUtils
class LogoutDialog(context:Context, var data: Int): xxBaseDialog<DialogLogoutBinding>(context) { class LogoutDialog(context:Context, var viewModel: SettingsViewModel): xxBaseDialog<DialogLogoutBinding>(context) {
override fun InitView(): DialogSet { override fun InitView(): DialogSet {
return DialogSet( return DialogSet(
R.layout.dialog_logout,true, R.layout.dialog_logout,true,
...@@ -26,7 +26,8 @@ class LogoutDialog(context:Context, var data: Int): xxBaseDialog<DialogLogoutBin ...@@ -26,7 +26,8 @@ class LogoutDialog(context:Context, var data: Int): xxBaseDialog<DialogLogoutBin
} }
binding.tvConfirm.setOnClickListener { binding.tvConfirm.setOnClickListener {
DialogClickListener.dialogClickBack(0, null); dismiss()
viewModel.goLogin()
} }
} }
......
...@@ -4,6 +4,7 @@ import android.os.Bundle ...@@ -4,6 +4,7 @@ import android.os.Bundle
import com.xx.hbhconsumer.BR import com.xx.hbhconsumer.BR
import com.xx.hbhconsumer.R import com.xx.hbhconsumer.R
import com.xx.hbhconsumer.data.http.requst.LoginRequest import com.xx.hbhconsumer.data.http.requst.LoginRequest
import com.xx.hbhconsumer.data.http.requst.SettingsRequest
import com.xx.hbhconsumer.databinding.ActivityLoginBinding import com.xx.hbhconsumer.databinding.ActivityLoginBinding
import com.xx.hbhconsumer.databinding.ActivitySettingsBinding import com.xx.hbhconsumer.databinding.ActivitySettingsBinding
import me.goldze.mvvmhabit.base.BaseActivity import me.goldze.mvvmhabit.base.BaseActivity
...@@ -32,7 +33,7 @@ class SettingsActivity() : BaseActivity<ActivitySettingsBinding, SettingsViewMod ...@@ -32,7 +33,7 @@ class SettingsActivity() : BaseActivity<ActivitySettingsBinding, SettingsViewMod
} }
override fun initViewModel(): SettingsViewModel { override fun initViewModel(): SettingsViewModel {
val lm: LoginRequest = LoginRequest() val lm = SettingsRequest()
return SettingsViewModel(application, lm) return SettingsViewModel(application, lm)
} }
......
package com.xx.hbhconsumer.ui.settings; package com.xx.hbhconsumer.ui.settings;
import static me.goldze.mvvmhabit.utils.Utils.Interceptor_TOKEN;
import android.app.Application; import android.app.Application;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import com.xx.hbhconsumer.data.http.requst.LoginRequest; import com.xx.hbhconsumer.data.http.requst.SettingsRequest;
import com.xx.hbhconsumer.data.http.respons.UserInfoBean;
import com.xx.hbhconsumer.data.local.LocalData; import com.xx.hbhconsumer.data.local.LocalData;
import com.xx.hbhconsumer.ui.login.LoginActivity; import com.xx.hbhconsumer.ui.login.LoginActivity;
import com.xx.hbhconsumer.ui.logoff.LogoffFirstStepActivity; import com.xx.hbhconsumer.ui.logoff.LogoffFirstStepActivity;
import com.xx.hbhconsumer.ui.logoff.LogoffSecondStepActivity; import com.xx.hbhconsumer.ui.phone.PhoneActivity;
import com.xx.hbhconsumer.ui.main.MainActivity; import com.xx.hbhconsumer.ui.pwd.PwdActivity;
import com.xx.hbhconsumer.ui.pwd.ForgetPwdActivity; import com.xx.hbhconsumer.ui.useragreement.UserAgreementActivity;
import com.xx.xxviewlibrary.base.xxBaseDialog; import com.xx.xxviewlibrary.base.xxBaseDialog;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import me.goldze.mvvmhabit.base.BaseViewModel; import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction; import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand; import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.http.ApiDisposableObserver;
import me.goldze.mvvmhabit.utils.RxUtils;
import me.goldze.mvvmhabit.utils.ToastUtils;
public class SettingsViewModel extends BaseViewModel<LoginRequest> { public class SettingsViewModel extends BaseViewModel<SettingsRequest> {
//用户名的绑定
public ObservableField<String> userName = new ObservableField<>("");
//密码的绑定
public ObservableField<String> password = new ObservableField<>("");
public SettingsViewModel(@NonNull Application application, LoginRequest model) { public SettingsViewModel(@NonNull Application application, SettingsRequest model) {
super(application, model); super(application, model);
} }
//跳转开店页面 public void goLogin() {
public BindingCommand goMerchantEnter = new BindingCommand(new BindingAction() { LocalData.delAllData();
startActivity(LoginActivity.class);
finish();
}
public BindingCommand goPrivacyClause = new BindingCommand(new BindingAction() {
@Override @Override
public void call() { public void call() {
Bundle bundle=new Bundle(); Bundle bundle = new Bundle();
// bundle.putInt("pageStep", R.id.registerMaterialFragment); bundle.putString("basicName", " 隐私协议");
// startActivity(MerchantEnterActivity.class,bundle); startActivity(UserAgreementActivity.class);
} }
}); });
//跳转首页 //跳转开店页面
public BindingCommand goHome = new BindingCommand(new BindingAction() { public BindingCommand goPhone = new BindingCommand(new BindingAction() {
@Override @Override
public void call() { public void call() {
startActivity(MainActivity.class); startActivity(PhoneActivity.class);
} }
}); });
//跳转忘记密码 //跳转首页
public BindingCommand forgetPwd = new BindingCommand(new BindingAction() { public BindingCommand goPwd = new BindingCommand(new BindingAction() {
@Override @Override
public void call() { public void call() {
startActivity(ForgetPwdActivity.class); startActivity(PwdActivity.class);
} }
}); });
...@@ -82,97 +73,11 @@ public class SettingsViewModel extends BaseViewModel<LoginRequest> { ...@@ -82,97 +73,11 @@ public class SettingsViewModel extends BaseViewModel<LoginRequest> {
} }
private void showSignDialog(View view) { private void showSignDialog(View view) {
LogoutDialog dialog=new LogoutDialog(view.getContext(), 1); LogoutDialog dialog = new LogoutDialog(view.getContext(), this);
dialog.setDialogClickListener((xxBaseDialog.onDialogClickListener<LogoutDialog>) (code, data) -> startActivity(LoginActivity.class)); dialog.setDialogClickListener((xxBaseDialog.onDialogClickListener<LogoutDialog>) (code, data) -> startActivity(LoginActivity.class));
dialog.show(); dialog.show();
} }
//登陆
public BindingCommand login = new BindingCommand(new BindingAction() {
@Override
public void call() {
startActivity(MainActivity.class);
if (TextUtils.isEmpty(userName.get().toString())) {
ToastUtils.showShort("请输入账号!");
}else if (TextUtils.isEmpty(password.get().toString())) {
ToastUtils.showShort("请输入密码!");
}else {
model.Login(/*userName.get().toString(), password.get().toString()*/"13922222222","123456")
.compose(RxUtils.schedulersTransformer()) //线程调度
// .compose(RxUtils.exceptionTransformer()) // 网络错误的异常转换, 这里可以换成自己的ExceptionHandle
.doOnSubscribe(SettingsViewModel.this)
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
showDialog("正在请求...");
}
}).subscribe(new ApiDisposableObserver<String>() {
@Override
public void onSuccess(String resultBean) {
//是指token
Interceptor_TOKEN = "Bearer " + resultBean;
getuserInfo();
// startActivity(HomeActivity.class);
}
@Override
public void onError(String Error) {
dismissDialog();
}
});
}
}
});
public void getuserInfo()
{
model.getUserInfo()
.compose(RxUtils.schedulersTransformer()) //线程调度
// .compose(RxUtils.exceptionTransformer()) // 网络错误的异常转换, 这里可以换成自己的ExceptionHandle
.doOnSubscribe(SettingsViewModel.this)
.doOnSubscribe (new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
}
}).subscribe(new ApiDisposableObserver<UserInfoBean>() {
@Override
public void onSuccess(UserInfoBean resultBean) {
//将用户信息存储到本地
LocalData.saveUser(resultBean.getUser());
dismissDialog();
/* if (resultBean.getMerchant()==null)
{
Bundle bundle=new Bundle();
bundle.putInt("pageStep", R.id.registerMaterialFragment);
startActivity(MerchantEnterActivity.class,bundle);
}else if (resultBean.getMerchant().getAuditStatus().equals("0")){
Bundle bundle=new Bundle();
bundle.putInt("pageStep", R.id.merchantWaitFragment);
startActivity(MerchantEnterActivity.class,bundle);
}else {
LocalData.saveMerchant(resultBean.getMerchant());
startActivity(HomeActivity.class);
}*/
LocalData.saveMerchant(resultBean.getMerchant());
// startActivity(AddProductActivity.class);
}
@Override
public void onError(String Error) {
dismissDialog();
}
});
}
} }
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 选中状态 -->
<item
android:state_enabled="true"
android:state_checked="true"
android:drawable="@mipmap/shangpin_icon_xuanzhong" />
<!-- 未被选中状态 -->
<item
android:state_enabled="true"
android:state_checked="false"
android:drawable="@mipmap/shangpin_icon_weixuanzhong" />
</selector>
\ No newline at end of file
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
android:layout_marginLeft="17dp" android:layout_marginLeft="17dp"
style="@style/CommEdit" style="@style/CommEdit"
android:hint="请输入账号" android:hint="请输入账号"
android:inputType="phone"
android:text="@={loginViewModel.userName}" android:text="@={loginViewModel.userName}"
android:background="@null"/> android:background="@null"/>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<com.xx.xxviewlibrary.witget.XxBar <com.xx.xxviewlibrary.witget.XxBar
android:id="@+id/bar" android:id="@+id/bar"
on_click="@{myCollectionViewModel.clickFinish}" on_click="@{myCollectionViewModel.clickFinish}"
bar_title="@{@string/navigation_sea}" bar_title="商品"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp"/> android:layout_height="55dp"/>
...@@ -44,6 +44,21 @@ ...@@ -44,6 +44,21 @@
android:textColor="#FF5971A4" android:textColor="#FF5971A4"
binding:onClickCommand="@{myCollectionViewModel.confirm}"/> binding:onClickCommand="@{myCollectionViewModel.confirm}"/>
<RelativeLayout
android:id="@+id/rl_no_data"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="92dp"
android:layout_below="@id/bar">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@mipmap/zhanwei_img_wushuju"/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_goods_list" android:id="@+id/rv_goods_list"
android:layout_below="@id/bar" android:layout_below="@id/bar"
...@@ -78,6 +93,7 @@ ...@@ -78,6 +93,7 @@
android:textColor="#FF333333"/> android:textColor="#FF333333"/>
<TextView <TextView
android:id="@+id/tv_check_count"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="3" android:text="3"
...@@ -103,7 +119,8 @@ ...@@ -103,7 +119,8 @@
android:id="@+id/btn_aap_save" android:id="@+id/btn_aap_save"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold"
binding:onClickCommand="@{myCollectionViewModel.confirm}"/>
</LinearLayout> </LinearLayout>
......
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
android:layout_height="72dp" android:layout_height="72dp"
android:paddingLeft="17dp" android:paddingLeft="17dp"
android:paddingRight="14dp" android:paddingRight="14dp"
android:background="@color/white"> android:background="@color/white"
binding:onClickCommand="@{settingsViewModel.goPwd}">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -77,7 +78,8 @@ ...@@ -77,7 +78,8 @@
android:layout_height="72dp" android:layout_height="72dp"
android:paddingLeft="17dp" android:paddingLeft="17dp"
android:paddingRight="14dp" android:paddingRight="14dp"
android:background="@color/white"> android:background="@color/white"
binding:onClickCommand="@{settingsViewModel.goPhone}">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -133,7 +135,8 @@ ...@@ -133,7 +135,8 @@
android:layout_below="@id/ll_part1" android:layout_below="@id/ll_part1"
android:layout_marginTop="17dp" android:layout_marginTop="17dp"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/white"> android:background="@color/white"
binding:onClickCommand="@{settingsViewModel.goPrivacyClause}">
<RelativeLayout <RelativeLayout
android:id="@+id/rl_privacy_agreement" android:id="@+id/rl_privacy_agreement"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -148,7 +151,7 @@ ...@@ -148,7 +151,7 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:textSize="16sp" android:textSize="16sp"
android:textColor="#FF222222" android:textColor="#FF222222"
android:text="修改密码"/> android:text="隐私协议"/>
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -21,6 +21,21 @@ ...@@ -21,6 +21,21 @@
android:layout_height="165dp" android:layout_height="165dp"
android:src="@mipmap/home_img_rexiaoqu"/> android:src="@mipmap/home_img_rexiaoqu"/>
<RadioGroup
android:id="@+id/radio_selected_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true">
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/rb_check_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:button="@drawable/radio_button_check_selector"/>
</RadioGroup>
<TextView <TextView
android:id="@+id/tv_goods_name" android:id="@+id/tv_goods_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
<RelativeLayout <RelativeLayout
android:id="@+id/rl_shop_info" android:id="@+id/rl_shop_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:layout_height="64dp" android:layout_height="64dp"
android:layout_marginBottom="17dp"> android:layout_marginBottom="17dp">
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="31dp" android:layout_marginTop="31dp"
android:textStyle="bold" android:textStyle="bold"
android:text="@={categoryBean.categoryName}"
android:textSize="16sp" android:textSize="16sp"
android:textColor="#FF333333"/> android:textColor="#FF333333"/>
......
...@@ -15,7 +15,5 @@ ...@@ -15,7 +15,5 @@
android:paddingRight="17dp" android:paddingRight="17dp"
android:background="@drawable/bg_grey_radius_20" android:background="@drawable/bg_grey_radius_20"
android:textSize="14sp" android:textSize="14sp"
android:textColor="#FF333333" android:textColor="#FF333333" />
android:text="@={categoryBean.categoryName}"
/>
</layout> </layout>
\ No newline at end of file
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
android:src="@mipmap/third_category"/> android:src="@mipmap/third_category"/>
<TextView <TextView
android:id="@+id/tv_category_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_below="@id/iv_category_image" android:layout_below="@id/iv_category_image"
android:layout_marginTop="13dp" android:layout_marginTop="13dp"
android:text="@={categoryBean.categoryName}"
android:textSize="13sp" android:textSize="13sp"
android:textColor="#FF333333"/> android:textColor="#FF333333"/>
......
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