package com.haicaojie.android.ui.mine.weex.usermodule;
|
|
import android.content.Context;
|
import android.content.Intent;
|
import android.content.SharedPreferences;
|
|
import com.haicaojie.android.ui.mine.LoginSelectActivity;
|
import com.taobao.weex.annotation.JSMethod;
|
import com.taobao.weex.common.WXModule;
|
|
import org.json.JSONObject;
|
|
/**
|
* Created by weikou2015 on 2018/6/14.
|
*/
|
|
public class UserModule extends WXModule {
|
|
@JSMethod
|
public String getUserInfo() {
|
SharedPreferences sp = mWXSDKInstance.getContext().getSharedPreferences("user", Context.MODE_PRIVATE);
|
String uid = sp.getString("uid", "0");
|
boolean isLogin = sp.getBoolean("isLogin", false);
|
JSONObject object = new JSONObject();
|
try {
|
object.put("code", isLogin ? 0 + "" : 1 + "");
|
JSONObject object1 = new JSONObject();
|
object1.put("uid", uid);
|
object.put("data", object1);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
return object.toString();
|
}
|
|
@JSMethod
|
public void login() {
|
mWXSDKInstance.getContext().startActivity(new Intent(mWXSDKInstance.getContext(), LoginSelectActivity.class));
|
}
|
}
|