Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3ed8671c61 | ||
![]() |
8b74ffe041 | ||
![]() |
9aaf50d237 | ||
![]() |
b37c0bfff0 | ||
![]() |
c1d5b2bcf7 | ||
![]() |
4a6801185c | ||
![]() |
936267cc85 | ||
![]() |
f5b35506b2 |
@ -10,5 +10,6 @@ key pass: 7654321Kingsome_
|
||||
vivo key alias: vivo
|
||||
oppo key alias: oppo
|
||||
xiaomi key alias: release
|
||||
meizu key alias: meizu
|
||||
|
||||
```
|
||||
|
@ -3,19 +3,29 @@ apply plugin: 'com.android.application'
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId "com.hnjc.wjtx.mi"
|
||||
applicationId "com.hnjc.wjtx.mz"
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0.0"
|
||||
versionCode 4
|
||||
versionName "1.0.4"
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("../key/publish_key")
|
||||
storePassword "7654321Kingsome_"
|
||||
keyAlias "meizu"
|
||||
keyPassword "7654321Kingsome_"
|
||||
v2SigningEnabled false
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
@ -36,7 +46,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.android.volley:volley:1.1.1'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
}
|
||||
|
BIN
app/libs/MzOnlineGameSDK_6.1.3_P.jar
Normal file
BIN
app/libs/MzOnlineGameSDK_6.1.3_P.jar
Normal file
Binary file not shown.
BIN
app/libs/android-support-v4.jar
Normal file
BIN
app/libs/android-support-v4.jar
Normal file
Binary file not shown.
@ -1,57 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hnjc.wjtx">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.hnjc.wjtx.mz">
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:name=".JCApplication"
|
||||
android:allowBackup="false"
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" >
|
||||
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
|
||||
tools:replace="name,label"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<meta-data android:name="android.max_aspect" android:value="2.2" />
|
||||
<activity android:name=".LaunchActivity"
|
||||
<activity
|
||||
android:name=".LaunchActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
|
||||
android:theme="@style/SplashTheme"
|
||||
>
|
||||
android:theme="@style/SplashTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".MainActivity"
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||
|
||||
</activity>
|
||||
|
||||
<!-- <activity android:name=".MainActivity"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
<!-- android:screenOrientation="portrait"-->
|
||||
<!-- android:windowSoftInputMode="adjustPan|stateAlwaysVisible"-->
|
||||
<!-- android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"-->
|
||||
<!-- android:theme="@android:style/Theme.NoTitleBar.Fullscreen">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </activity>-->
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="2.2" />
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.hnjc.wjtx.mz.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
</manifest>
|
@ -1,12 +1,17 @@
|
||||
package com.hnjc.wjtx;
|
||||
package com.hnjc.wjtx.mz;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.meizu.gamesdk.online.core.MzGameCenterPlatform;
|
||||
|
||||
public class JCApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.i("JCApplication", "JCApplication onCreate");
|
||||
String appId = "3345357";
|
||||
String appKey = "8ece854e1f9c4e50844bb14b8e0a29c8";
|
||||
MzGameCenterPlatform.init(this, appId, appKey);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx;
|
||||
package com.hnjc.wjtx.mz;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
@ -12,12 +12,12 @@ import android.util.Log;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hnjc.wjtx.net.DownloadRunnable;
|
||||
import com.hnjc.wjtx.net.TaskInfo;
|
||||
import com.hnjc.wjtx.net.WebApi;
|
||||
import com.hnjc.wjtx.util.AssetsUtil;
|
||||
import com.hnjc.wjtx.util.StringUtil;
|
||||
import com.hnjc.wjtx.util.UnzipRunnable;
|
||||
import com.hnjc.wjtx.mz.net.DownloadRunnable;
|
||||
import com.hnjc.wjtx.mz.net.TaskInfo;
|
||||
import com.hnjc.wjtx.mz.net.WebApi;
|
||||
import com.hnjc.wjtx.mz.util.AssetsUtil;
|
||||
import com.hnjc.wjtx.mz.util.StringUtil;
|
||||
import com.hnjc.wjtx.mz.util.UnzipRunnable;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -143,7 +143,7 @@ public class LaunchActivity extends Activity {
|
||||
*/
|
||||
private void getLocalVersionInfo() {
|
||||
String fileName = gameUrl.replace("index.html", "version.json");
|
||||
String realPath = getFileDirByUrl(fileName);
|
||||
String realPath = preloadPath + "/" + getFileDirByUrl(fileName) + "version.json" ;
|
||||
File versionFile = new File(realPath);
|
||||
if (versionFile.exists()) {
|
||||
JSONObject data = AssetsUtil.readJsonFromFile(this, realPath);
|
||||
@ -211,7 +211,7 @@ public class LaunchActivity extends Activity {
|
||||
}
|
||||
// 更新远程资源
|
||||
private void preloadGame() {
|
||||
String dir = preloadPath + getFileDirByUrl(gameUrl);
|
||||
String dir = preloadPath + "/" + getFileDirByUrl(gameUrl);
|
||||
File dirFile = new File(dir);
|
||||
if (!dirFile.exists()) {
|
||||
dirFile.mkdirs();
|
@ -1,7 +1,6 @@
|
||||
package com.hnjc.wjtx;
|
||||
package com.hnjc.wjtx.mz;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
@ -16,10 +15,18 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hnjc.wjtx.util.AssetsUtil;
|
||||
import com.hnjc.wjtx.util.IdUtil;
|
||||
import com.hnjc.wjtx.util.StorageUtil;
|
||||
import com.hnjc.wjtx.util.StringUtil;
|
||||
import com.hnjc.wjtx.mz.util.AssetsUtil;
|
||||
import com.hnjc.wjtx.mz.util.StorageUtil;
|
||||
import com.hnjc.wjtx.mz.util.StringUtil;
|
||||
import com.meizu.gamesdk.model.callback.MzExitListener;
|
||||
import com.meizu.gamesdk.model.callback.MzLoginListener;
|
||||
import com.meizu.gamesdk.model.callback.MzPayListener;
|
||||
import com.meizu.gamesdk.model.model.LoginResultCode;
|
||||
import com.meizu.gamesdk.model.model.MzAccountInfo;
|
||||
import com.meizu.gamesdk.model.model.MzBuyInfo;
|
||||
import com.meizu.gamesdk.model.model.PayResultCode;
|
||||
import com.meizu.gamesdk.online.core.MzGameBarPlatform;
|
||||
import com.meizu.gamesdk.online.core.MzGameCenterPlatform;
|
||||
|
||||
import org.egret.egretnativeandroid.EgretNativeAndroid;
|
||||
import org.json.JSONException;
|
||||
@ -27,12 +34,14 @@ import org.json.JSONObject;
|
||||
|
||||
//Android项目发布设置详见doc目录下的README_ANDROID.md
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
public class MainActivity extends Activity implements MzLoginListener, MzPayListener {
|
||||
private final String TAG = "MainActivity";
|
||||
private EgretNativeAndroid nativeAndroid;
|
||||
private ImageView launchScreenImageView = null;
|
||||
private FrameLayout rootLayout = null;
|
||||
private Vibrator vibrator;
|
||||
private MzAccountInfo accountInfo;
|
||||
private MzGameBarPlatform mzGameBarPlatform;
|
||||
|
||||
|
||||
@Override
|
||||
@ -69,36 +78,44 @@ public class MainActivity extends Activity {
|
||||
rootLayout = nativeAndroid.getRootFrameLayout();
|
||||
showLoadingView();
|
||||
vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
//初始化,可以指定gamebar第一次显示的位置,在游戏退出时会记住用户操作的最后一次位置,再次启动时使用上一次的位置
|
||||
//第一次显示的位置可以指定四个方向,左上,左下,右上,右下
|
||||
// public static final int GRAVITY_LEFT_TOP = 1;
|
||||
// public static final int GRAVITY_LEFT_BOTTOM = 2;
|
||||
// public static final int GRAVITY_RIGHT_TOP = 3;
|
||||
// public static final int GRAVITY_RIGHT_BOTTOM = 4;
|
||||
mzGameBarPlatform = new MzGameBarPlatform(this, MzGameBarPlatform.GRAVITY_LEFT_TOP);
|
||||
mzGameBarPlatform.onActivityCreate();
|
||||
mzGameBarPlatform.showGameBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
nativeAndroid.pause();
|
||||
mzGameBarPlatform.onActivityPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
nativeAndroid.resume();
|
||||
mzGameBarPlatform.onActivityResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
//声明并初始化弹出对象
|
||||
AlertDialog.Builder builder=new AlertDialog.Builder(this);
|
||||
builder.setTitle("提示:");
|
||||
builder.setMessage("是否退出");
|
||||
//设置确认按钮
|
||||
builder.setNegativeButton("确定", (dialog, which) -> {
|
||||
nativeAndroid.exitGame();
|
||||
finish();//退出程序
|
||||
MzGameCenterPlatform.exitSDK(this, new MzExitListener() {
|
||||
@Override
|
||||
public void callback(int i, String s) {
|
||||
if (i == MzExitListener.CODE_SDK_EXIT) {
|
||||
nativeAndroid.exitGame();
|
||||
finish();//退出程序
|
||||
}
|
||||
}
|
||||
});
|
||||
//设置取消按钮
|
||||
builder.setPositiveButton("取消",null);
|
||||
//显示弹框
|
||||
builder.show();
|
||||
return true;
|
||||
} else {
|
||||
return super.onKeyDown(keyCode, keyEvent);
|
||||
@ -163,18 +180,7 @@ public class MainActivity extends Activity {
|
||||
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
});
|
||||
nativeAndroid.setExternalInterface("getUid", message -> {
|
||||
//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", "");
|
||||
}
|
||||
MzGameCenterPlatform.login(this, this);
|
||||
|
||||
});
|
||||
nativeAndroid.setExternalInterface("@onState", message -> {
|
||||
@ -195,18 +201,25 @@ public class MainActivity extends Activity {
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(message);
|
||||
String cpOrderId = jsonObject.getString("orderId");
|
||||
String productCode = jsonObject.getString("productCode");
|
||||
int count = jsonObject.getInt("count");
|
||||
//TODO: 平台的支付
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put("errcode", 0);
|
||||
obj.put("errmsg", "");
|
||||
nativeAndroid.callExternalInterface("payResult", obj.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.i(TAG, "pay info: " + jsonObject.toString());
|
||||
Bundle buyBundle = new MzBuyInfo()
|
||||
.setBuyCount(jsonObject.getInt("buy_amount"))
|
||||
.setCpUserInfo(jsonObject.getString("user_info"))
|
||||
.setOrderAmount(jsonObject.getString("total_price"))
|
||||
.setOrderId(jsonObject.getString("cp_order_id"))
|
||||
.setPerPrice(jsonObject.getString("product_per_price"))
|
||||
.setProductBody(jsonObject.getString("product_body"))
|
||||
.setProductId(jsonObject.getString("product_id"))
|
||||
.setProductSubject(jsonObject.getString("product_subject"))
|
||||
.setProductUnit(jsonObject.getString("product_unit"))
|
||||
.setSign(jsonObject.getString("sign"))
|
||||
.setSignType(jsonObject.getString("sign_type"))
|
||||
.setCreateTime(jsonObject.getLong("create_time"))
|
||||
.setAppid(jsonObject.getString("app_id"))
|
||||
.setUserUid(jsonObject.getString("uid"))
|
||||
.setPayType(jsonObject.getInt("pay_type"))
|
||||
.toBundle();
|
||||
MzGameCenterPlatform.payOnline(MainActivity.this, buyBundle, MainActivity.this);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
} catch ( Exception e ) {
|
||||
@ -236,6 +249,8 @@ public class MainActivity extends Activity {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
//调一下onActivityDestroy
|
||||
mzGameBarPlatform.onActivityDestroy();
|
||||
}
|
||||
|
||||
private void showLoadingView() {
|
||||
@ -266,4 +281,84 @@ public class MainActivity extends Activity {
|
||||
launchScreenImageView = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录回调
|
||||
* 请处理相关回调事件
|
||||
*
|
||||
* @param code 错误码
|
||||
* @message 错误信息
|
||||
* @MzAccountInfo 账号信息
|
||||
*/
|
||||
@Override
|
||||
public void onLoginResult(int code, final MzAccountInfo accountInfo, final String message) {
|
||||
switch (code) {
|
||||
case LoginResultCode.LOGIN_SUCCESS:
|
||||
this.accountInfo = accountInfo; //保存登录信息,用于查询实名认证信息
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put("openid", accountInfo.getUid());
|
||||
obj.put("token", accountInfo.getSession());
|
||||
// 如果其他登陆过程中的错误, 则传入一个大于0的errorcode
|
||||
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
nativeAndroid.callExternalInterface("loginCancel", "");
|
||||
}
|
||||
break;
|
||||
case LoginResultCode.LOGIN_LOGOUT:
|
||||
nativeAndroid.callExternalInterface("loginOut", "");
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
JSONObject obj1 = new JSONObject();
|
||||
try {
|
||||
obj1.put("errcode", code);
|
||||
// 如果其他登陆过程中的错误, 则传入一个大于0的errorcode
|
||||
nativeAndroid.callExternalInterface("sendUidToJS", message);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
nativeAndroid.callExternalInterface("loginCancel", "");
|
||||
}
|
||||
// runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// showMsg(message);
|
||||
// }
|
||||
// });
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付录回调
|
||||
* 请处理相关回调事件
|
||||
*
|
||||
* @param code 错误码
|
||||
* @message 错误信息
|
||||
* @bundle 支付信息
|
||||
*/
|
||||
@Override
|
||||
public void onPayResult(int code, final Bundle bundle, final String message) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put("errcode", code);
|
||||
obj.put("errmsg", message);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
switch (code) {
|
||||
case PayResultCode.PAY_SUCCESS: //支付成功
|
||||
MzBuyInfo payInfo = MzBuyInfo.fromBundle(bundle);
|
||||
Log.i(TAG, "支付成功: " + payInfo.getOrderId() + " | " + payInfo.getPerPrice());
|
||||
case PayResultCode.PAY_ERROR_CANCEL: //支付取消
|
||||
Log.i(TAG, "支付取消: ");
|
||||
break;
|
||||
default:
|
||||
Log.i(TAG, "支付错误: code: " + code + " | " + message);
|
||||
break;
|
||||
}
|
||||
nativeAndroid.callExternalInterface("payResult", obj.toString());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
import com.android.volley.AuthFailureError;
|
||||
import com.android.volley.NetworkResponse;
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
public class BaseMode {
|
||||
private boolean status;
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
import android.util.Log;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
public class RequestErrorEvent {
|
||||
private int type;
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
public class TaskInfo {
|
||||
private String name;//文件名
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.net;
|
||||
package com.hnjc.wjtx.mz.net;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@ -14,7 +14,7 @@ public class WebApi {
|
||||
|
||||
public void getVersionInfo(BaseInterface iFace) {
|
||||
this.mInterface = iFace;
|
||||
// String versionUrl = "http://10.0.1.3:7021/game/zip/version.json";
|
||||
// String versionUrl = "https://test.kingsome.cn/wjtx/config/version_native.json";
|
||||
String versionUrl = "https://h5games-al.kingsome.cn/wjtx/config/version_native.json";
|
||||
AppRequestUtil.getInstance().getRequest(context, versionUrl, new RequestListener() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.util;
|
||||
package com.hnjc.wjtx.mz.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
@ -12,6 +12,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -187,7 +188,8 @@ public class AssetsUtil {
|
||||
*/
|
||||
public static String readFromFile(Context context, String path) {
|
||||
try {
|
||||
InputStreamReader inputReader = new InputStreamReader(context.openFileInput(path));
|
||||
FileInputStream fileInputStream = new FileInputStream(new File(path));
|
||||
InputStreamReader inputReader = new InputStreamReader(fileInputStream);
|
||||
BufferedReader bufReader = new BufferedReader(inputReader);
|
||||
String line="";
|
||||
StringBuilder result= new StringBuilder();
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.util;
|
||||
package com.hnjc.wjtx.mz.util;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@ -20,7 +20,7 @@ public class IdUtil {
|
||||
while (enumeration.hasMoreElements()) {
|
||||
NetworkInterface netInterface = enumeration.nextElement();
|
||||
if (netInterface.getName().equals("wlan0")) {
|
||||
return com.hnjc.wjtx.util.StringUtil.getMD5(netInterface.getHardwareAddress().toString(), false);
|
||||
return com.hnjc.wjtx.mz.util.StringUtil.getMD5(netInterface.getHardwareAddress().toString(), false);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -59,9 +59,9 @@ public class IdUtil {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
String wifiMac = getWifiMac();
|
||||
String androidId = getAndroidId(resolver);
|
||||
if (com.hnjc.wjtx.util.StringUtil.notBlank(androidId)) {
|
||||
if (com.hnjc.wjtx.mz.util.StringUtil.notBlank(androidId)) {
|
||||
return androidId;
|
||||
} else if (com.hnjc.wjtx.util.StringUtil.notBlank(wifiMac)) {
|
||||
} else if (com.hnjc.wjtx.mz.util.StringUtil.notBlank(wifiMac)) {
|
||||
return wifiMac;
|
||||
} else {
|
||||
return getUniquePsuedoID();
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.util;
|
||||
package com.hnjc.wjtx.mz.util;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.hnjc.wjtx.util;
|
||||
package com.hnjc.wjtx.mz.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.hnjc.wjtx.util;
|
||||
package com.hnjc.wjtx.mz.util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.hnjc.wjtx.net.TaskInfo;
|
||||
import com.hnjc.wjtx.mz.net.TaskInfo;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
Binary file not shown.
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 195 KiB |
@ -3,7 +3,7 @@
|
||||
<string name="load_game">下载游戏资源</string>
|
||||
<string name="start_game">进入游戏</string>
|
||||
<string name="preload_path">preload</string>
|
||||
<string name="game_url">http://local/index.html?channel=7103</string>
|
||||
<string name="game_url">http://local/index.html?channel=7108</string>
|
||||
<string name="local_version">1.0.0</string>
|
||||
<string name="load_back">load_back</string>
|
||||
<string name="launch_version">获取游戏版本</string>
|
||||
|
4
app/src/main/res/xml/file_paths.xml
Normal file
4
app/src/main/res/xml/file_paths.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<external-path name="external_files" path="."/>
|
||||
</paths>
|
BIN
assets/MzGameCenterService_6.1.3.apk
Normal file
BIN
assets/MzGameCenterService_6.1.3.apk
Normal file
Binary file not shown.
BIN
key/publish_key
BIN
key/publish_key
Binary file not shown.
476
platform.js
Normal file
476
platform.js
Normal file
@ -0,0 +1,476 @@
|
||||
function getQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
return r ? decodeURIComponent(r[2]) : '';
|
||||
}
|
||||
|
||||
class GamePlatform {
|
||||
|
||||
constructor() {
|
||||
this.name = 'native';
|
||||
this.version = "1.0.7";
|
||||
this.jcGameId = 1009;
|
||||
this.jcChannelId = getQueryString('channel') ? Number(getQueryString('channel')) : 7103;
|
||||
console.log('jcchannelid: ' + this.jcChannelId);
|
||||
this.isDev = true;
|
||||
this.orderIdUrl = `https://game1009proxy${this.isDev ? '-test':''}.kingsome.cn/webapp/index.php?c=Pay&a=preOrder`;
|
||||
this.checkRegRewardUrl = `https://game1009proxy${this.isDev ? '-test':''}.kingsome.cn/webapp/index.php?c=GoProxy&a=checkRegisterReward`;
|
||||
this.regRewardUrl = `https://game1009proxy${this.isDev ? '-test':''}.kingsome.cn/webapp/index.php?c=GoProxy&a=registerReward`;
|
||||
this.svrListUrl = `https://game1009gate${this.isDev ? '-test':''}.kingsome.cn/wjtxgate/common/login.aspx?pid=${this.jcChannelId}`;
|
||||
this.wssHost = `game1009game${this.isDev ? '-test' : ''}.kingsome.cn`;
|
||||
this.other = new GamePlatformOther();
|
||||
}
|
||||
login() {
|
||||
return new Promise((resolve, reject) => {
|
||||
jc.init({
|
||||
channelid: this.jcChannelId,
|
||||
gameid: this.jcGameId,
|
||||
isoffical: !this.isDev,
|
||||
});
|
||||
console.log('jcfw init finished 2');
|
||||
jc.loginUser({
|
||||
success: function(res) {
|
||||
console.log('登录成功', JSON.stringify(res));
|
||||
wxUserData.open_id = res.openid;
|
||||
wxUserData.nick_name = res.nickname;
|
||||
wxUserData.avatar_url = res.avatar_url;
|
||||
wxUserData.gender = res.sex;
|
||||
platform.code = res.openid;
|
||||
//res.session_key
|
||||
platform.session = res.session_id;
|
||||
resolve(res);
|
||||
},
|
||||
fail: function(neterr, logicerr, errmsg) {
|
||||
console.log('登录错误');
|
||||
console.log(neterr, logicerr, errmsg);
|
||||
reject(errmsg);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getUserInfo() {
|
||||
return new Promise((resolve, reject) => {
|
||||
platform.login().then(res => {
|
||||
console.log("登录成功");
|
||||
resolve();
|
||||
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// obj { data, success, fail }
|
||||
|
||||
_getOrderId(pid, uid, sid, callback) {
|
||||
var url = jc.gg.extcfg['prePayUrl'] || this.orderIdUrl;
|
||||
var reqData = {
|
||||
openid: platform.code,
|
||||
produce: pid,
|
||||
gameid: platform.jcGameId,
|
||||
session: platform.session,
|
||||
uid: uid,
|
||||
server: sid,
|
||||
platform: platform.jcChannelId,
|
||||
role_name: giant.Core.hero.name,
|
||||
role_level: giant.Core.hero.level,
|
||||
server_name: giant.Core.serverVO.name
|
||||
};
|
||||
|
||||
var loginCount = 0;
|
||||
var loginMaxCount = 1;
|
||||
console.log('pre order with url: ' + url);
|
||||
var request = function () {
|
||||
platform.urlRequest({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
data: reqData,
|
||||
success: function (res) {
|
||||
console.log("_getOrderId success", JSON.stringify(res));
|
||||
if (res && res.data) {
|
||||
// session检测失败,需要登录
|
||||
if (res.data.sessionCheck != null) {
|
||||
if (loginCount >= loginMaxCount) {
|
||||
callback && callback(false, "session失效,请重新登录");
|
||||
return;
|
||||
}
|
||||
loginCount++;
|
||||
|
||||
platform.login().then(res => {
|
||||
request();
|
||||
}).catch(err => {
|
||||
callback && callback(false, "session失效,login失败,请重新登录");
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback && callback(true, res.data.prepayId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
callback && callback(false, "接口返回有误,请重试");
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('pay with err: ' + JSON.stringify(err));
|
||||
callback && callback(false, "接口访问失败,请重试");
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
request();
|
||||
}
|
||||
|
||||
pay(obj) {
|
||||
var orderInfo = null;
|
||||
console.warn("pay obj", JSON.stringify(obj));
|
||||
|
||||
var onOrderIdResult = function (isOk, data) {
|
||||
if (isOk) {
|
||||
try {
|
||||
var payData = JSON.parse(data);
|
||||
Object.assign(payData, {count: 1});
|
||||
orderInfo = payData;
|
||||
realPay();
|
||||
} catch (err) {
|
||||
obj.fail && obj.fail({ tipMessage: '解析接口数据失败' });
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
obj.fail && obj.fail({ tipMessage: data });
|
||||
}
|
||||
}
|
||||
|
||||
var realPay = function () {
|
||||
console.log("pay orderInfo", orderInfo);
|
||||
if (!orderInfo) return;
|
||||
jc.plat.pay(orderInfo)
|
||||
.then(data => {
|
||||
if (data.errcode === 0) {
|
||||
console.log("[quick]pay success", JSON.stringify(data));
|
||||
obj.success && obj.success();
|
||||
} else {
|
||||
console.warn("pay fail", JSON.stringify(data));
|
||||
obj.fail && obj.fail({ tipMessage: "充值失败" , err: data.errmsg });
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.warn("pay fail", JSON.stringify(err));
|
||||
obj.fail && obj.fail({ tipMessage: "充值失败" , err: err.errmsg });
|
||||
})
|
||||
}
|
||||
|
||||
platform._getOrderId(obj.data.goodsId, obj.data.uid, obj.data.sid, onOrderIdResult);
|
||||
}
|
||||
concatServerList(res0, res1) {
|
||||
res0.data.lastWorldIds = res1.data.lastWorldIds.concat(res0.data.lastWorldIds);
|
||||
if (res1 && res1.data) {
|
||||
if (res1.data.servers) {
|
||||
for (let data of res1.data.servers) {
|
||||
data.comp = 'jc';
|
||||
res0.data.servers.push(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res1 && res1.data && res1.data.notice) {
|
||||
res0.data.notice = res1.data.notice;
|
||||
}
|
||||
return res0;
|
||||
}
|
||||
requestServerList() {
|
||||
var url = this.svrListUrl;
|
||||
return this.getServerList(url);
|
||||
}
|
||||
|
||||
getServerList(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let data = {
|
||||
openId: wxUserData.open_id
|
||||
}
|
||||
platform.urlRequest({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
data: data,
|
||||
success: function (res) {
|
||||
resolve(res);
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('getServerList fail with url:', url);
|
||||
resolve({data: {
|
||||
lastWorldIds: [],
|
||||
servers: [],
|
||||
}});
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
getWxWebResRoot(configUrl) {
|
||||
return new Promise((resolve, reject) => {
|
||||
platform.urlRequest({
|
||||
url: configUrl,
|
||||
method: "GET",
|
||||
success: function (res) {
|
||||
let newObj = res.data;
|
||||
constantRes.wxWebResRoot = constantRes.root + newObj.version + "/";
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
urlRequest(obj) {
|
||||
var url = obj.url;
|
||||
var method = obj.method.toUpperCase();
|
||||
var data = obj.data;
|
||||
var postDataRaw = obj.postDataRaw === true;
|
||||
var success = obj.success;
|
||||
var fail = obj.fail;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status >= 200 && xhr.status < 400) {
|
||||
var retData = xhr.responseText;
|
||||
try {
|
||||
retData = JSON.parse(retData);
|
||||
success && success({
|
||||
data: retData
|
||||
});
|
||||
} catch (err) {
|
||||
fail && fail();
|
||||
}
|
||||
|
||||
} else if (xhr.status >= 400) {
|
||||
fail && fail();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function (e) {
|
||||
fail && fail();
|
||||
};
|
||||
|
||||
if (method === "POST") {
|
||||
var dataStr = null;
|
||||
if (postDataRaw) {
|
||||
dataStr = data;
|
||||
}
|
||||
else {
|
||||
if (data) {
|
||||
dataStr = "";
|
||||
for (var key in data) {
|
||||
if (dataStr != "") {
|
||||
dataStr += "&";
|
||||
}
|
||||
dataStr += key + "=" + data[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.open(method, url);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send(dataStr);
|
||||
} else {
|
||||
var paramStr = "";
|
||||
if (data) {
|
||||
for (var key in data) {
|
||||
if (paramStr != "") {
|
||||
paramStr += "&";
|
||||
}
|
||||
paramStr += key + "=" + encodeURIComponent(data[key]);
|
||||
}
|
||||
if (paramStr != "") {
|
||||
paramStr = (url.indexOf("?") == -1 ? "?" : "&") + paramStr;
|
||||
}
|
||||
}
|
||||
url += paramStr;
|
||||
url += `&_d=${Date.now()}`
|
||||
console.log(url);
|
||||
xhr.open(method, url);
|
||||
xhr.send();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GamePlatformOther {
|
||||
constructor() {
|
||||
this.localFileName = 'userData_';
|
||||
}
|
||||
checkRegisterReward(uid, sid) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var url = jc.gg.extcfg['checkRegRewardUrl'] || platform.checkRegRewardUrl;
|
||||
console.log('checkRegisterReward req', uid, sid, url);
|
||||
platform.urlRequest({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
data: {
|
||||
uid: uid,
|
||||
server: sid,
|
||||
},
|
||||
success: function (res) {
|
||||
console.log("checkRegisterReward res", res);
|
||||
if (res && res.data) {
|
||||
if (res.data.code == 1) {
|
||||
resolve && resolve(true);
|
||||
}
|
||||
else {
|
||||
resolve && resolve(false, "code = " + res.data.code + ", error = " + res.data.error);
|
||||
}
|
||||
}
|
||||
else {
|
||||
reject && reject("接口返回有误,请重试");
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
reject && reject("接口访问失败,请重试");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getRegisterReward(uid, sid, name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var url = jc.gg.extcfg['RegRewardUrl'] || platform.regRewardUrl;
|
||||
console.log('getRegisterReward req', uid, sid, name, url);
|
||||
|
||||
var count = 0;
|
||||
var maxCount = 20;
|
||||
var interval = 3;
|
||||
|
||||
var doRequest = function () {
|
||||
platform.urlRequest({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
data: {
|
||||
uid: uid,
|
||||
server: sid,
|
||||
name: name
|
||||
},
|
||||
success: function (res) {
|
||||
console.log("getRegisterReward res", res);
|
||||
if (res && res.data) {
|
||||
if (res.data.code == 1) {
|
||||
resolve && resolve(true);
|
||||
}
|
||||
else {
|
||||
count++;
|
||||
if (count <= maxCount) {
|
||||
setTimeout(doRequest, interval * 1000);
|
||||
}
|
||||
else {
|
||||
resolve && resolve(false, "code = " + res.data.code + ", error = " + res.data.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
reject && reject("接口返回有误,请重试");
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
reject && reject("接口访问失败,请重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
doRequest();
|
||||
});
|
||||
}
|
||||
|
||||
reportRoleCreate(isNew) {
|
||||
let data = {
|
||||
isCreateRole: isNew,
|
||||
roleCreateTime: Date.now(),
|
||||
serverId: giant.Core.serverVO.id,
|
||||
serverName: giant.Core.serverVO.name,
|
||||
userRoleId: giant.Core.hero.id,
|
||||
userRoleName: giant.Core.hero.name,
|
||||
userRoleBalance: giant.Core.hero.coin,
|
||||
vipLevel: giant.Core.hero.vipLevel,
|
||||
userRoleLevel: giant.Core.hero.level,
|
||||
partyId: 0,
|
||||
partyName: giant.Core.hero.camp,
|
||||
gameRoleGender: giant.Core.hero.gender,
|
||||
gameRolePower: giant.Core.hero.power,
|
||||
};
|
||||
jc.plat.reportRoleInfo(data)
|
||||
.then(res => {})
|
||||
.catch(err=> {})
|
||||
}
|
||||
|
||||
setLocalStorage(key, value) {
|
||||
let self = this;
|
||||
if (key === 'lastSvr') {
|
||||
giant.Core.externalParams.lastWordId = value;
|
||||
}
|
||||
if (typeof localStorage != "undefined") {
|
||||
localStorage.setItem(self.localFileName + key, value);
|
||||
}
|
||||
else {
|
||||
console.warn("localStorage is null, on set");
|
||||
}
|
||||
}
|
||||
|
||||
getLocalStorage(key) {
|
||||
let self = this;
|
||||
if (key === 'lastSvr' && giant.Core.externalParams.lastWordId) {
|
||||
return giant.Core.externalParams.lastWordId;
|
||||
}
|
||||
if (typeof localStorage != "undefined") {
|
||||
var dataStr = localStorage.getItem(self.localFileName + key);
|
||||
if (key === 'lastSvr') {
|
||||
giant.Core.externalParams.lastWordId = dataStr;
|
||||
}
|
||||
return dataStr;
|
||||
}
|
||||
else {
|
||||
console.warn("localStorage is null, on get");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
getLiuHaiHeight() {
|
||||
|
||||
var ratioScreen = egret.Capabilities.boundingClientHeight / egret.Capabilities.boundingClientWidth;
|
||||
var ratioGameDesign = 1136 / 640;
|
||||
|
||||
console.log("getLiuHaiHeight", ratioScreen, ratioGameDesign);
|
||||
|
||||
// 跟游戏分辨率相比,相等没有刘海
|
||||
if (Math.abs(ratioScreen - ratioGameDesign) < 0.01) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
// 默认刘海值50
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlatUserData {
|
||||
|
||||
constructor() {
|
||||
this.open_id = null;
|
||||
this.nick_name = null;
|
||||
this.avatar_url = null;
|
||||
this.gender = null;
|
||||
}
|
||||
|
||||
getOpenId() {
|
||||
return this.open_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GameConstant {
|
||||
constructor() {
|
||||
this.root = "";
|
||||
this.wxWebResRoot = "";
|
||||
}
|
||||
}
|
||||
|
||||
window.platform = new GamePlatform();
|
||||
window.wxUserData = new PlatUserData();
|
||||
window.constantRes = new GameConstant();
|
Loading…
x
Reference in New Issue
Block a user