小程序方法 | MiniOpenApiProxy 方法 | 描述 |
wx.login | login | 登录接口 |
wx.getUserInfo | getUserInfo | 获取用户基本信息 |
wx.getUserProfile | getUserProfile | 获取用户属性信息 |
wx.getPhoneNumber | getPhoneNumber | 获取电话号码 |
wx.requestPayment | requestPayment | 发起支付 |
wx.checkSession | checkSession | 检查登录状态是否过期 |
@ProxyService(proxy = MiniOpenApiProxy.class) public class MiniOpenApiProxyImpl implements MiniOpenApiProxy { private static final String TAG = "MiniOpenApiProxyImpl"; @Override public void login(IMiniAppContext miniAppContext, JSONObject params, AsyncResult result) { QMLog.d(TAG, "login:" + params); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("key", "wx.login"); } catch (JSONException e) { e.printStackTrace(); } result.onReceiveResult(true, jsonObject); } @Override public void checkSession(IMiniAppContext miniAppContext, JSONObject params, AsyncResult result) { QMLog.d(TAG, "checkSession:" + params); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("key", "wx.checkSession"); } catch (JSONException e) { e.printStackTrace(); } result.onReceiveResult(true, jsonObject); } @Override public void getUserInfo(IMiniAppContext miniAppContext, JSONObject params, AsyncResult result) { QMLog.d(TAG, "getUserInfo:" + params); JSONObject jsonObject = new JSONObject(); try { final JSONObject userInfo = new JSONObject(); userInfo.put("nickName", "userInfo测试"); // userInfo.put("avatarUrl", bundle.getString("avatarUrl")); userInfo.put("gender", 0); userInfo.put("country", "CN"); userInfo.put("province", "BeiJing"); userInfo.put("city", "BeiJing"); userInfo.put("language", "en"); jsonObject.put("userInfo", userInfo); } catch (JSONException e) { e.printStackTrace(); } result.onReceiveResult(true, jsonObject); } @Override public void getUserProfile(IMiniAppContext miniAppContext, JSONObject params, AsyncResult result) { QMLog.d(TAG, "getUserProfile:" + params); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("key", "wx.getUserProfile"); } catch (JSONException e) { e.printStackTrace(); } result.onReceiveResult(true, jsonObject); } @Override public void getPhoneNumber(IMiniAppContext miniAppContext, JSONObject params, AsyncResult result) { QMLog.d(TAG, "getPhoneNumber:" + params); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("key", "wx.getPhoneNumber"); } catch (JSONException e) { e.printStackTrace(); } result.onReceiveResult(true, jsonObject); } @Override public void requestPayment(IMiniAppContext miniAppContext, JSONObject params, AsyncResult result) { QMLog.d(TAG, "requestPayment:" + params); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("key", "wx.requestPayment"); } catch (JSONException e) { e.printStackTrace(); } result.onReceiveResult(true, jsonObject); }
本页内容是否解决了您的问题?