package com.wd.workoffice.ui.activity.user;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.PermissionBean;
import com.wd.workoffice.bean.UserInfoBean;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.util.UserKeeper;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import flexible.xd.android_base.network.rtfhttp.Transformer;
import io.reactivex.disposables.Disposable;

/**
 * 我的 - 信息
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class UserInfoActivity extends WorkToolBarActivity {
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    @BindView(R.id.tv_no)
    TextView tvNo;
    @BindView(R.id.tv_dep)
    TextView tvDep;

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        if (!TextUtils.isEmpty(UserKeeper.getInstance().getLoginInfo())) {
            String userInfo = UserKeeper.getInstance().getUserInfo();
            if (!TextUtils.isEmpty(userInfo)) {
                UserInfoBean userInfoBean = JSON.parseObject(userInfo, UserInfoBean.class);
                tvName.setText(userInfoBean.getUserName());
                tvPhone.setText(userInfoBean.getPhone());
                tvNo.setText(userInfoBean.getErpId());
                tvDep.setText(userInfoBean.getOfDept().getName());
            }
        } else {
            tvName.setText(UserKeeper.getInstance().getMesNickName());
            tvPhone.setText(UserKeeper.getInstance().getMesMobile());
            tvNo.setText(UserKeeper.getInstance().getMesUserCode());
            tvDep.setText(UserKeeper.getInstance().getMesDep());
        }
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initEvent() {
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_user_info;
    }

}
