wpc
2018-11-27 680fbc9e73da3e11988557cf88fd935efd3e0b1e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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));
    }
}