增加登陆和支付回调的示例代码
This commit is contained in:
parent
36e83cdd26
commit
e29648f328
@ -17,6 +17,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.hnjc.wjtx.util.AssetsUtil;
|
import com.hnjc.wjtx.util.AssetsUtil;
|
||||||
|
import com.hnjc.wjtx.util.IdUtil;
|
||||||
import com.hnjc.wjtx.util.StorageUtil;
|
import com.hnjc.wjtx.util.StorageUtil;
|
||||||
import com.hnjc.wjtx.util.StringUtil;
|
import com.hnjc.wjtx.util.StringUtil;
|
||||||
|
|
||||||
@ -163,6 +164,18 @@ public class MainActivity extends Activity {
|
|||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("getUid", message -> {
|
nativeAndroid.setExternalInterface("getUid", message -> {
|
||||||
//TODO: 平台的登陆
|
//TODO: 平台的登陆
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
try {
|
||||||
|
obj.put("openid", IdUtil.getUid(this));
|
||||||
|
obj.put("token", "");
|
||||||
|
// 如果其他登陆过程中的错误, 则传入一个大于0的errorcode
|
||||||
|
obj.put("errorcode", 1);
|
||||||
|
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
nativeAndroid.callExternalInterface("loginCancel", "");
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("@onState", message -> {
|
nativeAndroid.setExternalInterface("@onState", message -> {
|
||||||
Log.e(TAG, "Get @onState: " + message);
|
Log.e(TAG, "Get @onState: " + message);
|
||||||
@ -186,6 +199,14 @@ public class MainActivity extends Activity {
|
|||||||
String productCode = jsonObject.getString("productCode");
|
String productCode = jsonObject.getString("productCode");
|
||||||
int count = jsonObject.getInt("count");
|
int count = jsonObject.getInt("count");
|
||||||
//TODO: 平台的支付
|
//TODO: 平台的支付
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
try {
|
||||||
|
obj.put("errcode", 0);
|
||||||
|
obj.put("errmsg", "");
|
||||||
|
nativeAndroid.callExternalInterface("payResult", obj.toString());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user