doum
4 天以前 cb6aca0642ac8dd5de877ade168066d85acb589c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.doumee.keyCabinet.ui.face;
 
import android.app.Application;
 
import androidx.annotation.NonNull;
import androidx.hilt.lifecycle.ViewModelInject;
 
import com.doumee.keyCabinet.MApplication;
import com.doumee.keyCabinet.bean.CabinetFaceBean;
import com.doumee.keyCabinet.bean.FaceUserBean;
import com.doumee.keyCabinet.http.Apis;
import com.doumee.keyCabinet.http.param.BaseResponse;
import com.doumee.keyCabinet.http.param.DevLoginParam;
import com.doumee.keyCabinet.http.param.GetMemberIdByCodeParam;
import com.doumee.keyCabinet.ui.main.MainActivity;
import com.doumee.keyCabinet.utils.LMobileInfo;
import com.doumee.keyCabinet.utils.ParamsUtil;
import com.doumee.lib_coremodel.base.BaseModel;
import com.doumee.lib_coremodel.base.DataViewModel;
import com.doumee.lib_coremodel.http.rxJava.SimpleObserver;
import com.doumee.lib_coremodel.http.utils.RxUtils;
 
import java.util.ArrayList;
import java.util.List;
 
public class FaceVM extends DataViewModel {
    @ViewModelInject
    public FaceVM(@NonNull Application application, BaseModel model) {
        super(application, model);
    }
 
    @Override
    protected void clickByTypeCommand(int type) {
        doAction(type);
    }
 
    /**
     *
     * @param code  ic卡
     * @param type //0:管理员,1:司机
     */
    public void getMemberIdByCode(String code,String type){
        GetMemberIdByCodeParam param = new GetMemberIdByCodeParam(code);
        showLoading(true);
        getRetrofitService(Apis.class).getMemberIdByCode(ParamsUtil.encodeRequestBody(param))
                .compose(RxUtils.schedulersTransformer())
                .subscribe(new SimpleObserver<BaseResponse<Integer>>(rxJavaGcManager) {
                    @Override
                    public void onNext(@NonNull BaseResponse<Integer> response) {
                        if(200==response.getCode()){
                            //查询数据
                            if(response.getData()!=null){
                                if("0".equals(type)){
                                    MApplication.getLoginBean().setAutoMemberId(response.getData());
                                    doAction();
                                }else {
                                    MApplication.getLoginBean().setAutoMemberId(response.getData());
                                    MApplication.getLoginBean().setAuthType(1);
                                    doAction();
                                }
                            }
                        }else {
                            toast(response.getMessage());
                        }
                    }
 
                    @Override
                    public void onError(@NonNull Throwable e) {
                        toast(e.getMessage());
                    }
 
                    @Override
                    public void onComplete() {
                        hideLoading();
                    }
                });
    }
}