package com.yidian.common.http

import com.yidian.common.YacBaseApplication
import com.yidian.common.utils.EncryptUtil.Companion.encryptToSHA
import com.yidian.common.utils.StringUtils
import com.yidian.xarc.xbase.helper.SPHelper

class HttpCommonParamsUtils{
    companion object{
        val spHelper = SPHelper(YacBaseApplication.context, "config")
        //-----------header-------------
        //圈id
        var cycleId by spHelper.SharedPreference("cycleId", "1568648")
        var token by spHelper.SharedPreference("token", "3rpPKwJlwiYaWPxusbeC0Ads5nTN7QMwOxIV6LLQkFg6CPtNdeQhVtK")
        //设备id
        var deviceId:String? = null
        //写死的固定值，确认是否必要
        const val portal = "1564343"
        //当前版本，确认是否必要
        var currentVersion = "210430"
        var packageName = "com.cutt.zhiyue.android"
        var imei:String? = null
        //Md5过的Mac地址
        var mid:String? = null
        var androidId:String? = null
        var serialNumber:String? = null
        var version:String? = null
        var deviceFinger:String? = null
        var targetSdkVersion:Int=0
        var OS:String? = null
        var x_digest:String? = null
        //本地生成很复杂，以后确认是否必要
        var sign:String? = null
        //---------------params-----------
        var salt by spHelper.SharedPreference("salt", "0e2UegQY8uUPuslO")
        var appKey by spHelper.SharedPreference("app_key", "token_8d171bf0ab33deea_jY5knW2dcpFD5mj1")


        fun getParamsMap(): HashMap<String, String>{
            val queryParamsMap = HashMap<String, String>()
            if (StringUtils.isNotBlank(appKey) && StringUtils.isNotBlank(salt)){
                val timeStamp = System.currentTimeMillis()
                queryParamsMap["app_key"] = appKey
                queryParamsMap["timestamp"] = timeStamp.toString()
                queryParamsMap["sign"] = encryptToSHA("$appKey:$salt:$timeStamp")
            }
            return queryParamsMap
        }
    }
}