package com.tjzhxx.union;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tjzhxx.union.activity.PolicyListActivity;
import com.tjzhxx.union.public_store.ConstDefine;
import com.tjzhxx.union.system.BaseFragment;
import com.tjzhxx.union.system.WebviewActivity;

import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.annotations.Nullable;

/**
 * 描述:
 *
 * @author yanghuaxiong
 * @create 2021/9/1 11:44 AM
 */
public class UnionFragment extends BaseFragment {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        setHasOptionsMenu(true);
        View view = inflater.inflate(R.layout.fragment_union, container, false);
        ButterKnife.bind(this, view);
        return view;
    }


    @OnClick({R.id.union01, R.id.union02, R.id.union03, R.id.union04, R.id.union05, R.id.union06, R.id.union07, R.id.union08, R.id.union09, R.id.union10, R.id.union11, R.id.union12})
    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()) {
            case R.id.union01:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/salvation?type=1");
                intent.putExtra("title", "职工现场救助");
                startActivity(intent);
                break;
            case R.id.union02:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/salvation?type=2");
                intent.putExtra("title", "住院慰问资料填写");
                startActivity(intent);
                break;
            case R.id.union03:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/salvation?type=3");
                intent.putExtra("title", "大病救助资料填写");
                startActivity(intent);
                break;
            case R.id.union04:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/salvation?type=4");
                intent.putExtra("title", "五种重疾资料填写");
                startActivity(intent);
                break;
            case R.id.union05:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/salvation?type=6");
                intent.putExtra("title", "家庭财产损失资料填写");
                startActivity(intent);
                break;
            case R.id.union06:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/salvation?type=5");
                intent.putExtra("title", "意外事故资料填写");
                startActivity(intent);
                break;
            case R.id.union07:
                if (ConstDefine.userInfo == null){
                    showSnackBar("请先登录");
                    return;
                }
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/sportList?type=jnpx");
                intent.putExtra("title", "技能培训");
                intent.putExtra("UserInfo",ConstDefine.userInfo);
                startActivity(intent);
                break;
            case R.id.union08:
                if (ConstDefine.userInfo == null){
                    showSnackBar("请先登录");
                    return;
                }
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/trainonlinelist");
                intent.putExtra("title", "线上培训");
                startActivity(intent);
                break;
            case R.id.union09:
                if (ConstDefine.userInfo == null){
                    showSnackBar("请先登录");
                    return;
                }
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/sportList?type=ldjs");
                intent.putExtra("title", "技能大赛");
                intent.putExtra("UserInfo",ConstDefine.userInfo);
                startActivity(intent);
                break;
            case R.id.union10:
                if (ConstDefine.userInfo == null){
                    showSnackBar("请先登录");
                    return;
                }
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/sportList?type=wthd");
                intent.putExtra("title", "文体活动");
                intent.putExtra("UserInfo",ConstDefine.userInfo);
                startActivity(intent);
                break;
            case R.id.union11:
                intent.setClass(getActivity(), PolicyListActivity.class);
                startActivity(intent);
                break;
            case R.id.union12:
                if (ConstDefine.userInfo == null){
                    showSnackBar("请先登录");
                    return;
                }
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra("url", ConstDefine.HttpAdressH5+"/index.html#/legalAid");
                intent.putExtra("title", "法律援助");
                intent.putExtra("UserInfo",ConstDefine.userInfo);
                startActivity(intent);
                break;
        }
    }
}
