package com.zj365.dc.activity

import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.BaseVmAct
import com.xty.base.vm.BaseVm
import com.xty.common.Const
import com.xty.common.MMkvHelper
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.util.CommonToastUtils
import com.zj365.dc.BuildConfig
import com.zj365.dc.R
import com.zj365.dc.databinding.ActDietManagementBinding

@Route(path = ARouterUrl.DIET_MANAGEMENT)
class DietManagementAct : BaseVmAct<BaseVm>(){

    val binding by lazy{ ActDietManagementBinding.inflate(layoutInflater)}


    override fun liveObserver() {
    }

    override fun initView() {
        super.initView()
        statusBar(binding.title.mView)
        binding.title.mTvTitle.text ="膳食管理"
        binding.title.mIvBack.setOnClickListener {
            finish()
        }

        binding.rxCalorie.setOnClickListener(setOnClickListener)
        binding.rxHealthyDiet.setOnClickListener(setOnClickListener)
        binding.rxMedicineFood.setOnClickListener(setOnClickListener)
        binding.rxFoodDiary.setOnClickListener(setOnClickListener)
        binding.rxMore.setOnClickListener(setOnClickListener)
    }

    var setOnClickListener = View.OnClickListener {
        when(it.id){
            R.id.rx_calorie ->{
                RouteManager.goAct(ARouterUrl.CALORIE_ANALYZE)
            }

            R.id.rx_healthy_diet ->{
                if(MMkvHelper.getLong(Const.USER_ID).toString() == "0"){
                    RouteManager.goAct(ARouterUrl.LOGIN_ACT)
                }else {
                    bundle.clear()
//                bundle.putString("web_site_url","http://testbuilt.zhongjian365.com/ ")
                    bundle.putString(
                        "web_site_url",
                        "${BuildConfig.h5url}pages/index/index?pageId=cookbook"
                    )
                    bundle.putBoolean("isShowTitle",false)
                    RouteManager.goAct(ARouterUrl.H5_ACT, bundle)
                }
              //  var url = "${BuildConfig.}"

            }
            R.id.rx_medicine_food ->{
                if(MMkvHelper.getLong(Const.USER_ID).toString() == "0"){
                    RouteManager.goAct(ARouterUrl.LOGIN_ACT)
                }else {
                    bundle.clear()
                    bundle.putString(
                        "web_site_url",
                        "${BuildConfig.h5url}pages/index/index?pageId=herbal"
                    )
                    bundle.putBoolean("isShowTitle",false)
                    RouteManager.goAct(ARouterUrl.H5_ACT, bundle)
                }

            }
            R.id.rx_food_diary ->{
                if(MMkvHelper.getLong(Const.USER_ID).toString() == "0"){
                    RouteManager.goAct(ARouterUrl.LOGIN_ACT)
                }else {
                    bundle.clear()
                    bundle.putString(
                        "web_site_url",
                        "${BuildConfig.h5url}pages/index/index?pageId=diary"
                    )
                    RouteManager.goAct(ARouterUrl.H5_ACT, bundle)
                }
            }

            R.id.rx_more ->{
                CommonToastUtils.showToast("敬请期待")
            }
        }

    }

    override fun setLayout() = binding.root

}