package com.sheep.jiuyan.samllsheep.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

/**
 * Created by kemllor on 2017/12/21.
 */

public class SpUtils {

    public static boolean isLogin(Context context) {
        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        String wxOpenId = user.getString("wx_openId", "");
        return !TextUtils.isEmpty(wxOpenId);
    }

    public static String getOpenId(Context context) {
        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        return user.getString("wx_openId", "");
    }

    public static void login(Context context, String openId) {
        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putString("wx_openId", openId);
        editor.apply();
    }


    public static void setImagePath(Context context, String vaule) {
        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putString("imagepath", vaule);
        editor.apply();
    }


    public static String getImagePath(Context context) {
        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        return user.getString("imagepath", "");
    }





    public static void saveAppToken(Context context, String vaule) {
        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putString("apptoken", vaule);
        editor.apply();
    }


    public static String getAppToken(Context context) {
        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
        return user.getString("apptoken", "");

    }
    public static void saveWithdral(Context context, String vaule) {
        SharedPreferences user = context.getSharedPreferences("withdral", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putString("withdral_price", vaule);
        editor.apply();
    }


    public static String getWithdral(Context context) {
        SharedPreferences user = context.getSharedPreferences("withdral", Context.MODE_PRIVATE);
        return user.getString("withdral_price", "");
    }
    public static void savePhone(Context context, String vaule) {
        SharedPreferences user = context.getSharedPreferences("phone", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putString("phone", vaule);
        editor.apply();
    }


    public static String getPhone(Context context) {
        SharedPreferences user = context.getSharedPreferences("phone", Context.MODE_PRIVATE);
        return user.getString("phone", "");
    }
    public static void saveWeixin(Context context, String vaule) {
        SharedPreferences user = context.getSharedPreferences("weixin_name", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putString("weixin_name", vaule);
        editor.apply();
    }


    public static String getWeixin(Context context) {
        SharedPreferences user = context.getSharedPreferences("weixin_name", Context.MODE_PRIVATE);
        return user.getString("weixin_name", "");
    }

    /**
     * 点击事件 记录
     * @param context
     * @param vaule
     */
    public static void saveClick(Context context, boolean vaule) {
        SharedPreferences user = context.getSharedPreferences("btn_download_click", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putBoolean("click", vaule);
        editor.apply();
    }


    public static boolean getClick(Context context) {
        SharedPreferences user = context.getSharedPreferences("btn_download_click", Context.MODE_PRIVATE);
        return user.getBoolean("click", false);
    }

    /**
     * 点击事件 记录,是否在提示
     * @param context
     * @param vaule
     */
    public static void saveDownNotice(Context context, boolean vaule) {
        SharedPreferences user = context.getSharedPreferences("btn_download_notice", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = user.edit();
        editor.putBoolean("notice_down", vaule);
        editor.apply();
    }


    public static boolean getDownNotice(Context context) {
        SharedPreferences user = context.getSharedPreferences("btn_download_notice", Context.MODE_PRIVATE);
        return user.getBoolean("notice_down", false);
    }





}
