package com.example.smart.util
|
|
import com.example.basecore.util.SPUtils
|
|
object StatusProvider {
|
|
|
/**
|
* 登录状态
|
*/
|
private const val login_status = "app_has_login"
|
fun hasLogin(): Boolean = SPUtils.getBoolean(login_status, false)
|
|
fun loginApp(uid: String, token:String) {
|
SPUtils.putValue(login_status, true)
|
putUid(uid)
|
putToken(token)
|
}
|
|
fun loginOut() {
|
SPUtils.putValue(login_status, false)
|
SPUtils.putValue(userId, "")
|
SPUtils.putValue(token, "")
|
}
|
|
private const val userId = "user_uid"
|
fun getUid(): String = SPUtils.getString(userId, "")
|
|
private fun putUid(uid: String) = SPUtils.putValue(this.userId, uid)
|
|
|
|
private const val token = "user_token"
|
fun getToken(): String = SPUtils.getString(token, "")
|
|
private fun putToken(token: String) = SPUtils.putValue(this.token, token)
|
|
|
/**
|
* 是否已经显示过权限提示弹窗
|
*/
|
private const val permission_guide = "permission_guide"
|
fun isShownPermission(): Boolean {
|
return SPUtils.getBoolean(permission_guide, false)
|
}
|
|
fun setPermissionShown() {
|
SPUtils.putValue(permission_guide, true)
|
}
|
|
}
|