Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
73f4ebe5e1 | ||
![]() |
f580b092ea | ||
![]() |
e44feebebd | ||
![]() |
a0485e71f8 | ||
![]() |
7475caaff6 | ||
![]() |
f410b0d9dc | ||
![]() |
3d5fc1cbb7 | ||
![]() |
0ce9a41445 | ||
![]() |
e571551e70 | ||
![]() |
777d2a89e9 | ||
![]() |
4a67dc773a | ||
![]() |
9712ea3692 | ||
![]() |
479d6e5684 | ||
![]() |
6fdaadc790 | ||
![]() |
ab4ebb2110 | ||
![]() |
08d1edd470 | ||
![]() |
373483e52c | ||
![]() |
9c6a55f164 | ||
![]() |
a83dd79e27 | ||
![]() |
10ebc9c462 | ||
![]() |
2134db34af |
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,4 +10,4 @@
|
|||||||
/app/build/
|
/app/build/
|
||||||
/sdk/build/
|
/sdk/build/
|
||||||
/.idea/
|
/.idea/
|
||||||
/assets
|
/assets/game
|
||||||
|
@ -6,4 +6,7 @@ key/publish_key
|
|||||||
key store pass: 7654321Kingsome_
|
key store pass: 7654321Kingsome_
|
||||||
key alias: release
|
key alias: release
|
||||||
key pass: 7654321Kingsome_
|
key pass: 7654321Kingsome_
|
||||||
|
|
||||||
|
vivo 使用vivo的alias
|
||||||
|
oppo 使用oppo
|
||||||
```
|
```
|
||||||
|
@ -3,40 +3,31 @@ apply plugin: 'com.android.application'
|
|||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.hnjc.wjtx.mi"
|
applicationId "com.hnjc.wjtx.vivo"
|
||||||
minSdkVersion 18
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 1
|
versionCode 10
|
||||||
versionName "1.0.0"
|
versionName "1.0.10"
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters 'armeabi-v7a'
|
abiFilters 'armeabi-v7a'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
assets.srcDirs = ['../assets']
|
assets.srcDirs = ['../assets']
|
||||||
aidl.srcDirs = ['aidl']
|
|
||||||
jniLibs.srcDirs = ['libs']//so&jar文件路径
|
jniLibs.srcDirs = ['libs']//so&jar文件路径
|
||||||
}
|
}
|
||||||
debug.setRoot('build-types/debug')
|
|
||||||
release.setRoot('build-types/release')
|
|
||||||
}
|
|
||||||
buildToolsVersion '28.0.3'
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: '*.jar', dir: 'libs')
|
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
||||||
implementation(name: 'egret', ext: 'aar')
|
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
|
||||||
implementation 'com.android.volley:volley:1.1.1'
|
implementation 'com.android.volley:volley:1.1.1'
|
||||||
|
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
BIN
app/libs/armeabi-v7a/libvivo_account_sdk.so
Normal file
BIN
app/libs/armeabi-v7a/libvivo_account_sdk.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libvivo_account_sdk.so
Normal file
BIN
app/libs/armeabi/libvivo_account_sdk.so
Normal file
Binary file not shown.
BIN
app/libs/oaid_sdk_1.0.25.aar
Normal file
BIN
app/libs/oaid_sdk_1.0.25.aar
Normal file
Binary file not shown.
BIN
app/libs/vivounionsdk_v4.6.9.0.jar
Normal file
BIN
app/libs/vivounionsdk_v4.6.9.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
9
app/proguard-rules.pro
vendored
9
app/proguard-rules.pro
vendored
@ -83,9 +83,12 @@
|
|||||||
-dontwarn android.support.**
|
-dontwarn android.support.**
|
||||||
-keep class **.R$styleable{*;}
|
-keep class **.R$styleable{*;}
|
||||||
|
|
||||||
-keep class com.hnjc.wjtx.mi.** { *; }
|
-keep class com.hnjc.wjtx.** { *; }
|
||||||
-dontwarn com.hnjc.wjtx.mi.**
|
-dontwarn com.hnjc.wjtx.**
|
||||||
|
|
||||||
|
|
||||||
-keep class org.egret.** { *; }
|
-keep class org.egret.** { *; }
|
||||||
-dontwarn org.egret.**
|
-dontwarn org.egret.**
|
||||||
|
|
||||||
|
|
||||||
|
-keep class com.bun.miitmdid.core.** {*;}
|
@ -1,24 +1,41 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.hnjc.wjtx">
|
package="com.hnjc.wjtx">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<!--联运SDK跳转游戏中心-->
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="vivo.game.permission.OPEN_JUMP_INTENTS"/>
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<!--联运SDK监听网络状态变化,在支付登录过程中做一些异常处理-->
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||||
|
<!--允许程序访问Wi-Fi网络状态信息-->
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||||
|
<!--允许程序打开网络套接字-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<!--允许程序访问有关GSM网络信息-->
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
|
<!--读取imei 这个要动态获取 否则数据统计会异常-->
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||||
|
<!--联运sdk写入内容到sd卡-->
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
<!--强制安装联运APK时,需要从SDK中读取APK文件-->
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<!--判断游戏是否是在主进程初始化,避免初始化进程错误导致功能不可用-->
|
||||||
|
<uses-permission android:name="android.permission.GET_TASKS"/>
|
||||||
|
<!--获取安装权限-->
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@drawable/icon"
|
||||||
android:name=".JCApplication"
|
android:name=".JCApplication"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" >
|
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" >
|
||||||
|
|
||||||
<meta-data android:name="android.max_aspect" android:value="2.2" />
|
<meta-data android:name="android.max_aspect" android:value="2.2" />
|
||||||
|
|
||||||
<activity android:name=".LaunchActivity"
|
<activity android:name=".LaunchActivity"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
@ -39,19 +56,28 @@
|
|||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- <activity android:name=".MainActivity"-->
|
<meta-data
|
||||||
<!-- android:launchMode="singleTask"-->
|
android:name="vivo_union_sdk"
|
||||||
<!-- android:screenOrientation="portrait"-->
|
android:value="4.6.9.0" />
|
||||||
<!-- 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>-->
|
|
||||||
|
|
||||||
|
<!-- vivo sdk componets start -->
|
||||||
|
<!--vivo sdk的Activity-->
|
||||||
|
<activity android:name="com.vivo.unionsdk.ui.UnionActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
|
||||||
|
android:theme="@android:style/Theme.Dialog"
|
||||||
|
android:exported="false"
|
||||||
|
tools:ignore="AppLinkUrlError">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
<data
|
||||||
|
android:scheme="vivounion"
|
||||||
|
android:host="union.vivo.com"
|
||||||
|
android:path="/openjump"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<!-- vivo sdk componets end -->
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -3,10 +3,100 @@ package com.hnjc.wjtx;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.hnjc.wjtx.vivo.VivoUnionHelper;
|
||||||
|
import com.vivo.unionsdk.open.MissOrderEventHandler;
|
||||||
|
import com.vivo.unionsdk.open.OrderResultInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class JCApplication extends Application {
|
public class JCApplication extends Application {
|
||||||
|
private final String TAG = "JCApplication";
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Log.i("JCApplication", "JCApplication onCreate");
|
Log.i("JCApplication", "JCApplication onCreate");
|
||||||
|
VivoUnionHelper.initSdk(this, false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 掉单注册接口 需要接入掉单补单处理的一定要加
|
||||||
|
* !!!! 一定要加,否则无法通过上架审核 !!!
|
||||||
|
* 作用:商品补发回调
|
||||||
|
* 场景:支付完成后,游戏未正常发放商品,或发放后未成功通知到vivo侧,在异常订单查询后自动触发
|
||||||
|
*/
|
||||||
|
VivoUnionHelper.registerMissOrderEventHandler(this, mMissOrderEventHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户主动触发或调用queryMissOrderResult查询回调会在此做处理
|
||||||
|
*/
|
||||||
|
private MissOrderEventHandler mMissOrderEventHandler = new MissOrderEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void process(List orderResultInfos) {
|
||||||
|
Log.i(TAG, "registerOrderResultEventHandler: orderResultInfos = " + orderResultInfos);
|
||||||
|
/**
|
||||||
|
* 注意这里是查到未核销的订单
|
||||||
|
* 需要调用自己的逻辑完成道具核销后再调用我们的订单完成接口
|
||||||
|
* 切记!!!一定要走自己逻辑发送完道具后再调用完成接口!!!切记!切记!
|
||||||
|
* !!!游戏根据订单号检查、补发商品!!!
|
||||||
|
* 自行完成补发逻辑 一定要完成道具补发后才能调用完成接口 此处一定要注意!!!
|
||||||
|
* 如果不处理直接调用完成则掉单无法解决
|
||||||
|
* 注意!!!注意!!!
|
||||||
|
* 游戏侧用你们自己的订单号cpOrderNumber来校验是否完成发货 发货完成上报我们的订单号transNo
|
||||||
|
*/
|
||||||
|
checkOrder(orderResultInfos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 校验订单是否已经完成发货(游戏自己逻辑)
|
||||||
|
* 未完成的执行发货操作
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
public void checkOrder(final List<OrderResultInfo> list) {
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> orderList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
/**
|
||||||
|
* 校验是否已经完成发货 如果已经完成发货则加入完成列表
|
||||||
|
* 未完成则调用发货流程
|
||||||
|
* 这里修改成自己的校验流程 调用游戏自己的服务器 注意!!!注意!!!
|
||||||
|
*/
|
||||||
|
boolean isSucc = true;
|
||||||
|
if (isSucc) {
|
||||||
|
/**
|
||||||
|
* 校验已发货成功的 加入已完成列表 这里传的是transNo
|
||||||
|
*/
|
||||||
|
orderList.add(list.get(i).getTransNo());
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
* 未完成发货的执行发货流程
|
||||||
|
*/
|
||||||
|
sendProp(list.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* !!!批量订单补发完成后调用完成接口 !!!
|
||||||
|
*/
|
||||||
|
VivoUnionHelper.reportOrderComplete(orderList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用发货逻辑(游戏自己实现)
|
||||||
|
* @param orderResultInfo
|
||||||
|
*/
|
||||||
|
private void sendProp(final OrderResultInfo orderResultInfo) {
|
||||||
|
/**
|
||||||
|
* 执行发货逻辑 发货成功单独通知
|
||||||
|
*/
|
||||||
|
boolean isSucc = true;
|
||||||
|
if (isSucc) {
|
||||||
|
/**
|
||||||
|
* !!!单个订单补发完成后调用完成接口 !!!
|
||||||
|
*/
|
||||||
|
VivoUnionHelper.reportOrderComplete(orderResultInfo.getTransNo(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import android.util.Log;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.hnjc.wjtx.net.BaseInterface;
|
||||||
import com.hnjc.wjtx.net.DownloadRunnable;
|
import com.hnjc.wjtx.net.DownloadRunnable;
|
||||||
import com.hnjc.wjtx.net.TaskInfo;
|
import com.hnjc.wjtx.net.TaskInfo;
|
||||||
import com.hnjc.wjtx.net.WebApi;
|
import com.hnjc.wjtx.net.WebApi;
|
||||||
@ -25,12 +26,12 @@ import org.json.JSONObject;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class LaunchActivity extends Activity {
|
public class LaunchActivity extends Activity {
|
||||||
|
private static final String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
private final String TAG = "LaunchActivity";
|
private final String TAG = "LaunchActivity";
|
||||||
private final String ZERO_VERSION = "0";
|
private final String ZERO_VERSION = "0";
|
||||||
private ProgressBar progressBar = null;
|
private ProgressBar progressBar = null;
|
||||||
private TextView progressLabel = null;
|
private TextView progressLabel = null;
|
||||||
private WebApi webApi;
|
private WebApi webApi;
|
||||||
|
|
||||||
private String zipUrl;
|
private String zipUrl;
|
||||||
private String gameUrl;
|
private String gameUrl;
|
||||||
private String preloadPath;
|
private String preloadPath;
|
||||||
@ -43,13 +44,9 @@ public class LaunchActivity extends Activity {
|
|||||||
private String versionStr;
|
private String versionStr;
|
||||||
private String downloadStr;
|
private String downloadStr;
|
||||||
private String unzipStr;
|
private String unzipStr;
|
||||||
|
|
||||||
private TaskInfo info;//任务信息
|
private TaskInfo info;//任务信息
|
||||||
private DownloadRunnable runnable;//下载任务
|
private DownloadRunnable runnable;//下载任务
|
||||||
private UnzipRunnable unzipRunnable; // 解压任务
|
private UnzipRunnable unzipRunnable; // 解压任务
|
||||||
|
|
||||||
private static final String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
|
||||||
|
|
||||||
private Handler handler = new Handler(new Handler.Callback() {
|
private Handler handler = new Handler(new Handler.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
@ -59,7 +56,7 @@ public class LaunchActivity extends Activity {
|
|||||||
int l = (int) ((float) info.getCompletedLen() / (float) info.getContentLen() * 100);
|
int l = (int) ((float) info.getCompletedLen() / (float) info.getContentLen() * 100);
|
||||||
//设置进度条进度
|
//设置进度条进度
|
||||||
updateProgress(l);
|
updateProgress(l);
|
||||||
if (l>=100) {//当进度>=100时,取消Handler循环
|
if (l >= 100) {//当进度>=100时,取消Handler循环
|
||||||
handler.removeCallbacksAndMessages(null);
|
handler.removeCallbacksAndMessages(null);
|
||||||
if (info.getType() == 0) {
|
if (info.getType() == 0) {
|
||||||
File file = new File(info.getPath() + info.getName());
|
File file = new File(info.getPath() + info.getName());
|
||||||
@ -74,6 +71,12 @@ public class LaunchActivity extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private static String getFileDirByUrl(String urlString) {
|
||||||
|
int lastSlash = urlString.lastIndexOf('/');
|
||||||
|
String server = urlString.substring(0, lastSlash + 1);
|
||||||
|
return server.replaceFirst("://", "/").replace(":", "#0A");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -101,9 +104,11 @@ public class LaunchActivity extends Activity {
|
|||||||
private void updateProgress(int val) {
|
private void updateProgress(int val) {
|
||||||
progressBar.setProgress(val);
|
progressBar.setProgress(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeLoadTxt(String title) {
|
private void changeLoadTxt(String title) {
|
||||||
progressLabel.setText(title);
|
progressLabel.setText(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compareVersions() {
|
private void compareVersions() {
|
||||||
changeLoadTxt(versionStr);
|
changeLoadTxt(versionStr);
|
||||||
updateProgress(10);
|
updateProgress(10);
|
||||||
@ -123,12 +128,13 @@ public class LaunchActivity extends Activity {
|
|||||||
updateProgress(60);
|
updateProgress(60);
|
||||||
getRemoteVersionInfo();
|
getRemoteVersionInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取位于预加载目录version.json中的版本号
|
* 获取位于预加载目录version.json中的版本号
|
||||||
*/
|
*/
|
||||||
private void getLocalVersionInfo() {
|
private void getLocalVersionInfo() {
|
||||||
String fileName = gameUrl.replace("index.html", "version.json");
|
String fileName = gameUrl.replace("index.html", "version.json");
|
||||||
String realPath = getFileDirByUrl(fileName);
|
String realPath = preloadPath + "/" + getFileDirByUrl(fileName) + "version.json" ;
|
||||||
File versionFile = new File(realPath);
|
File versionFile = new File(realPath);
|
||||||
if (versionFile.exists()) {
|
if (versionFile.exists()) {
|
||||||
JSONObject data = AssetsUtil.readJsonFromFile(this, realPath);
|
JSONObject data = AssetsUtil.readJsonFromFile(this, realPath);
|
||||||
@ -139,6 +145,7 @@ public class LaunchActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取位于assets目录version.json中的版本号
|
* 获取位于assets目录version.json中的版本号
|
||||||
*/
|
*/
|
||||||
@ -152,53 +159,58 @@ public class LaunchActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取远程资源的版本号
|
* 获取远程资源的版本号
|
||||||
*/
|
*/
|
||||||
private void getRemoteVersionInfo() {
|
private void getRemoteVersionInfo() {
|
||||||
webApi.getVersionInfo((success, message, err) -> {
|
webApi.getVersionInfo(new BaseInterface() {
|
||||||
if (success) {
|
@Override
|
||||||
try {
|
public void response(boolean success, JSONObject message, String err) {
|
||||||
remoteVersion = message.getString("version");
|
if (success) {
|
||||||
zipUrl = message.getString("path");
|
try {
|
||||||
Log.i(TAG, "base version: " + baseVersion);
|
remoteVersion = message.getString("version");
|
||||||
Log.i(TAG, "local version: " + localVersion);
|
zipUrl = message.getString("path");
|
||||||
Log.i(TAG, "remote version: " + remoteVersion);
|
Log.i(TAG, "base version: " + baseVersion);
|
||||||
Log.i(TAG, "remote resource: " + zipUrl);
|
Log.i(TAG, "local version: " + localVersion);
|
||||||
boolean needUpdate = false;
|
Log.i(TAG, "remote version: " + remoteVersion);
|
||||||
if (StringUtil.compareAppVersion(baseVersion, localVersion) >= 0) {
|
Log.i(TAG, "remote resource: " + zipUrl);
|
||||||
if (StringUtil.compareAppVersion(remoteVersion, baseVersion) > 0) {
|
boolean needUpdate = false;
|
||||||
needUpdate = true;
|
if (StringUtil.compareAppVersion(baseVersion, localVersion) >= 0) {
|
||||||
}
|
if (StringUtil.compareAppVersion(remoteVersion, baseVersion) > 0) {
|
||||||
} else {
|
needUpdate = true;
|
||||||
if (StringUtil.compareAppVersion(remoteVersion, localVersion) > 0) {
|
}
|
||||||
needUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (needUpdate) {
|
|
||||||
if (StringUtil.isBlank(zipUrl)) {
|
|
||||||
Log.e(TAG, "远程版本高于代码包版本和预加载版本, 需要更新, 但未获取到远程资源地址");
|
|
||||||
startMain();
|
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "远程版本高于代码包版本和预加载版本, 需要更新");
|
if (StringUtil.compareAppVersion(remoteVersion, localVersion) > 0) {
|
||||||
updateProgress(100);
|
needUpdate = true;
|
||||||
preloadGame();
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (needUpdate) {
|
||||||
|
if (StringUtil.isBlank(zipUrl)) {
|
||||||
|
Log.e(TAG, "远程版本高于代码包版本和预加载版本, 需要更新, 但未获取到远程资源地址");
|
||||||
|
startMain();
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "远程版本高于代码包版本和预加载版本, 需要更新");
|
||||||
|
updateProgress(100);
|
||||||
|
preloadGame();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
startMain();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
startMain();
|
startMain();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
startMain();
|
startMain();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
startMain();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preloadGame() {
|
private void preloadGame() {
|
||||||
String dir = preloadPath + getFileDirByUrl(gameUrl);
|
String dir = preloadPath + "/" + getFileDirByUrl(gameUrl);
|
||||||
File dirFile = new File(dir);
|
File dirFile = new File(dir);
|
||||||
if (!dirFile.exists()) {
|
if (!dirFile.exists()) {
|
||||||
dirFile.mkdirs();
|
dirFile.mkdirs();
|
||||||
@ -229,12 +241,6 @@ public class LaunchActivity extends Activity {
|
|||||||
handler.sendEmptyMessageDelayed(1, 200);
|
handler.sendEmptyMessageDelayed(1, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getFileDirByUrl(String urlString) {
|
|
||||||
int lastSlash = urlString.lastIndexOf('/');
|
|
||||||
String server = urlString.substring(0, lastSlash + 1);
|
|
||||||
return server.replaceFirst("://", "/").replace(":", "#0A");
|
|
||||||
}
|
|
||||||
private void emptyPreload() {
|
private void emptyPreload() {
|
||||||
File dirFile = new File(preloadPath);
|
File dirFile = new File(preloadPath);
|
||||||
if (dirFile.exists() && dirFile.isDirectory()) {
|
if (dirFile.exists() && dirFile.isDirectory()) {
|
||||||
@ -244,6 +250,7 @@ public class LaunchActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deletePreloadFile(File file) {
|
private void deletePreloadFile(File file) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
File[] files = file.listFiles();
|
File[] files = file.listFiles();
|
||||||
@ -255,20 +262,30 @@ public class LaunchActivity extends Activity {
|
|||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMain() {
|
private void startMain() {
|
||||||
Intent intent = new Intent(LaunchActivity.this, MainActivity.class);
|
Intent intent = new Intent(LaunchActivity.this, MainActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
intent.putExtra("preloadPath", preloadPath);
|
intent.putExtra("preloadPath", preloadPath);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
//在Activity销毁时移除回调和msg,并置空,防止内存泄露
|
//在Activity销毁时移除回调和msg,并置空,防止内存泄露
|
||||||
if(handler != null){
|
if (handler != null) {
|
||||||
handler.removeCallbacksAndMessages(null);
|
handler.removeCallbacksAndMessages(null);
|
||||||
handler = null;
|
handler = null;
|
||||||
}
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
super.finish();
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package com.hnjc.wjtx;
|
package com.hnjc.wjtx;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.VibrationEffect;
|
import android.os.VibrationEffect;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@ -18,20 +21,93 @@ import android.widget.Toast;
|
|||||||
import com.hnjc.wjtx.util.AssetsUtil;
|
import com.hnjc.wjtx.util.AssetsUtil;
|
||||||
import com.hnjc.wjtx.util.StorageUtil;
|
import com.hnjc.wjtx.util.StorageUtil;
|
||||||
import com.hnjc.wjtx.util.StringUtil;
|
import com.hnjc.wjtx.util.StringUtil;
|
||||||
|
import com.hnjc.wjtx.vivo.VivoUnionHelper;
|
||||||
|
import com.vivo.unionsdk.open.OrderResultInfo;
|
||||||
|
import com.vivo.unionsdk.open.VivoAccountCallback;
|
||||||
|
import com.vivo.unionsdk.open.VivoConstants;
|
||||||
|
import com.vivo.unionsdk.open.VivoExitCallback;
|
||||||
|
import com.vivo.unionsdk.open.VivoPayCallback;
|
||||||
|
import com.vivo.unionsdk.open.VivoPayInfo;
|
||||||
|
import com.vivo.unionsdk.open.VivoRoleInfo;
|
||||||
|
import com.vivo.unionsdk.open.VivoUnionSDK;
|
||||||
|
|
||||||
import org.egret.egretnativeandroid.EgretNativeAndroid;
|
import org.egret.egretnativeandroid.EgretNativeAndroid;
|
||||||
|
import org.egret.runtime.launcherInterface.INativePlayer;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
//Android项目发布设置详见doc目录下的README_ANDROID.md
|
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
private final String TAG = "MainActivity";
|
private final String TAG = "MainActivity";
|
||||||
private EgretNativeAndroid nativeAndroid;
|
private EgretNativeAndroid nativeAndroid;
|
||||||
private ImageView launchScreenImageView = null;
|
private ImageView launchScreenImageView = null;
|
||||||
private FrameLayout rootLayout = null;
|
private FrameLayout rootLayout = null;
|
||||||
private Vibrator vibrator;
|
private Vibrator vibrator;
|
||||||
|
//用户uid
|
||||||
|
private String mUid = "";
|
||||||
|
private String mAuthToken = "";
|
||||||
|
//游戏订单号
|
||||||
|
private String cpPayOrderNumber;
|
||||||
|
//订单金额
|
||||||
|
private String cpOrderAmount;
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
private final VivoAccountCallback mAcccountCallback = new VivoAccountCallback() {
|
||||||
|
@Override
|
||||||
|
public void onVivoAccountLogin(String userName, String uid, String authToken) {
|
||||||
|
// 1. 收到登录成功回调后,调用服务端接口校验登录有效性。arg2返回值为authtoken。服务端接口详见文档。校验登录代码略。
|
||||||
|
mUid = uid;
|
||||||
|
mAuthToken = authToken;
|
||||||
|
sendUidToGame(mUid, mAuthToken);
|
||||||
|
//登录成功
|
||||||
|
VivoUnionHelper.queryMissOrderResult(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVivoAccountLogout(int i) {
|
||||||
|
nativeAndroid.callExternalInterface("loginOut", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVivoAccountLoginCancel() {
|
||||||
|
nativeAndroid.callExternalInterface("loginCancel", "");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final VivoPayCallback mVivoPayCallback = new VivoPayCallback() {
|
||||||
|
// 客户端返回的支付结果不可靠,请再查询服务器,以服务器端最终的支付结果为准;
|
||||||
|
@Override
|
||||||
|
public void onVivoPayResult(int code, OrderResultInfo orderResultInfo) {
|
||||||
|
Log.i(TAG, "onVivoPayResult: " + orderResultInfo.getTransNo());
|
||||||
|
Log.i(TAG, "CpOrderNumber: " + cpPayOrderNumber + " i = " + code);
|
||||||
|
String errmsg = "";
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
if (code == VivoConstants.PAYMENT_RESULT_CODE_SUCCESS) {
|
||||||
|
Toast.makeText(MainActivity.this, "支付成功", Toast.LENGTH_SHORT).show();
|
||||||
|
/**
|
||||||
|
* !!!! 一定要加,否则无法通过上架审核 !!!
|
||||||
|
* !!! 商品发放成功以后,通知vivo侧 !!!!
|
||||||
|
* 这里取transNo不要取错了 注意!!!
|
||||||
|
*/
|
||||||
|
VivoUnionHelper.reportOrderComplete(orderResultInfo.getTransNo());
|
||||||
|
Log.i(TAG, "sendCompleteOrderNotification: " + orderResultInfo.getTransNo());
|
||||||
|
|
||||||
|
} else if (code == VivoConstants.PAYMENT_RESULT_CODE_CANCEL) {
|
||||||
|
Toast.makeText(MainActivity.this, "取消支付", Toast.LENGTH_SHORT).show();
|
||||||
|
} else if (code == VivoConstants.PAYMENT_RESULT_CODE_UNKNOWN) {
|
||||||
|
Toast.makeText(MainActivity.this, "未知状态,请查询订单", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(MainActivity.this, "支付失败", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
obj.put("errcode", code);
|
||||||
|
obj.put("errmsg", errmsg);
|
||||||
|
nativeAndroid.callExternalInterface("payResult", obj.toString());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -39,7 +115,7 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
String preloadPath = AssetsUtil.getDiskFileDir(this, this.getString(R.string.preload_path));
|
String preloadPath = AssetsUtil.getDiskFileDir(this, this.getString(R.string.preload_path));
|
||||||
String gameUrl = this.getString(R.string.game_url);
|
String gameUrl = this.getString(R.string.game_url);
|
||||||
|
appId = this.getString(R.string.app_id);
|
||||||
nativeAndroid = new EgretNativeAndroid(this);
|
nativeAndroid = new EgretNativeAndroid(this);
|
||||||
if (!nativeAndroid.checkGlEsVersion()) {
|
if (!nativeAndroid.checkGlEsVersion()) {
|
||||||
Toast.makeText(this, "This device does not support OpenGL ES 2.0.",
|
Toast.makeText(this, "This device does not support OpenGL ES 2.0.",
|
||||||
@ -57,7 +133,7 @@ public class MainActivity extends Activity {
|
|||||||
nativeAndroid.config.preloadPath = preloadPath;
|
nativeAndroid.config.preloadPath = preloadPath;
|
||||||
|
|
||||||
setExternalInterfaces();
|
setExternalInterfaces();
|
||||||
|
|
||||||
if (!nativeAndroid.initialize(gameUrl)) {
|
if (!nativeAndroid.initialize(gameUrl)) {
|
||||||
Toast.makeText(this, "Initialize native failed.",
|
Toast.makeText(this, "Initialize native failed.",
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
@ -67,6 +143,33 @@ public class MainActivity extends Activity {
|
|||||||
rootLayout = nativeAndroid.getRootFrameLayout();
|
rootLayout = nativeAndroid.getRootFrameLayout();
|
||||||
showLoadingView();
|
showLoadingView();
|
||||||
vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
|
vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
|
||||||
|
//注册登录回调
|
||||||
|
VivoUnionSDK.registerAccountCallback(this, mAcccountCallback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态获取访问手机标识符权限
|
||||||
|
* 这个在游戏中移动要加,不然获取不到imei
|
||||||
|
*/
|
||||||
|
if(Build.VERSION.SDK_INT >= 23){
|
||||||
|
int hasPermission = checkSelfPermission(Manifest.permission.READ_PHONE_STATE);
|
||||||
|
if (hasPermission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
//没有权限,向用户请求权限
|
||||||
|
requestPermissions( new String[]{Manifest.permission.READ_PHONE_STATE}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
|
if (requestCode == 0){
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
|
||||||
|
//用户同意,执行操作
|
||||||
|
|
||||||
|
}else{
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,97 +187,201 @@ public class MainActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
|
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
nativeAndroid.exitGame();
|
VivoUnionSDK.exit(this, new VivoExitCallback() {
|
||||||
|
@Override
|
||||||
|
public void onExitCancel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExitConfirm() {
|
||||||
|
nativeAndroid.exitGame();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return super.onKeyDown(keyCode, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, keyEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setExternalInterfaces() {
|
private void setExternalInterfaces() {
|
||||||
nativeAndroid.setExternalInterface("sendToNative", message -> {
|
nativeAndroid.setExternalInterface("sendToNative", new INativePlayer.INativeInterface() {
|
||||||
Log.d(TAG, "Get message: " + message);
|
@Override
|
||||||
nativeAndroid.callExternalInterface("sendToJS", "Get message: " + message);
|
public void callback(String message) {
|
||||||
|
Log.d(TAG, "Get message: " + message);
|
||||||
|
nativeAndroid.callExternalInterface("sendToJS", "Get message: " + message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("removeNativeLoading", message -> {
|
nativeAndroid.setExternalInterface("removeNativeLoading", new INativePlayer.INativeInterface() {
|
||||||
Log.d(TAG, "removeNativeLoading: " + message);
|
@Override
|
||||||
hideLoadingView();
|
public void callback(String message) {
|
||||||
|
Log.d(TAG, "removeNativeLoading: " + message);
|
||||||
|
hideLoadingView();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("setLocalStorage", message -> {
|
nativeAndroid.setExternalInterface("setLocalStorage", new INativePlayer.INativeInterface() {
|
||||||
Log.d(TAG, "setLocalStorage: " + message);
|
@Override
|
||||||
try{
|
public void callback(String message) {
|
||||||
JSONObject jsonObject = new JSONObject(message);
|
Log.d(TAG, "setLocalStorage: " + message);
|
||||||
String key = jsonObject.getString("key");
|
try{
|
||||||
String val = jsonObject.getString("val");
|
JSONObject jsonObject = new JSONObject(message);
|
||||||
|
String key = jsonObject.getString("key");
|
||||||
|
String val = jsonObject.getString("val");
|
||||||
|
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
|
||||||
|
StorageUtil.writeString(sharedPref, key, val);
|
||||||
|
}
|
||||||
|
catch (JSONException e) {
|
||||||
|
Log.e(TAG, " onState message failed to analyze");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
nativeAndroid.setExternalInterface("getLocalStorage", new INativePlayer.INativeInterface() {
|
||||||
|
@Override
|
||||||
|
public void callback(String message) {
|
||||||
|
Log.d(TAG, "getLocalStorage: " + message);
|
||||||
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
|
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
|
||||||
StorageUtil.writeString(sharedPref, key, val);
|
String val = StorageUtil.readString(sharedPref, message);
|
||||||
|
nativeAndroid.callExternalInterface("getLocalStorage", val);
|
||||||
}
|
}
|
||||||
catch (JSONException e) {
|
});
|
||||||
Log.e(TAG, " onState message failed to analyze");
|
|
||||||
|
nativeAndroid.setExternalInterface("removeLocalStorage", new INativePlayer.INativeInterface() {
|
||||||
|
@Override
|
||||||
|
public void callback(String message) {
|
||||||
|
Log.d(TAG, "removeLocalStorage: " + message);
|
||||||
|
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
|
||||||
|
StorageUtil.removeString(sharedPref, message);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
nativeAndroid.setExternalInterface("removeLocalStorage", new INativePlayer.INativeInterface() {
|
||||||
nativeAndroid.setExternalInterface("getLocalStorage", message -> {
|
@Override
|
||||||
Log.d(TAG, "getLocalStorage: " + message);
|
public void callback(String message) {
|
||||||
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
|
Log.d(TAG, "removeLocalStorage: " + message);
|
||||||
String val = StorageUtil.readString(sharedPref, message);
|
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
|
||||||
nativeAndroid.callExternalInterface("getLocalStorage", val);
|
StorageUtil.removeString(sharedPref, message);
|
||||||
});
|
}
|
||||||
nativeAndroid.setExternalInterface("removeLocalStorage", message -> {
|
|
||||||
Log.d(TAG, "removeLocalStorage: " + message);
|
|
||||||
SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
|
|
||||||
StorageUtil.removeString(sharedPref, message);
|
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* 震动须添加权限
|
* 震动须添加权限
|
||||||
* <uses-permission android:name="android.permission.VIBRATE"/>
|
* <uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
* @param type {int} 震动类型 0: 短震动, 1: 长震动
|
* @param type {int} 震动类型 0: 短震动, 1: 长震动
|
||||||
* */
|
* */
|
||||||
nativeAndroid.setExternalInterface("vibrate", message -> {
|
nativeAndroid.setExternalInterface("vibrate", new INativePlayer.INativeInterface() {
|
||||||
Log.d(TAG, "vibrate: " + message);
|
@Override
|
||||||
message = StringUtil.isBlank(message) ? "0" : message;
|
public void callback(String message) {
|
||||||
int type = Integer.getInteger(message);
|
Log.d(TAG, "vibrate: " + message);
|
||||||
long time = type == 0 ? 15 : 500;
|
message = StringUtil.isBlank(message) ? "0" : message;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
int type = Integer.getInteger(message);
|
||||||
vibrator.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
|
long time = type == 0 ? 15 : 500;
|
||||||
} else {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
//deprecated in API 26
|
vibrator.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
|
||||||
vibrator.vibrate(time);
|
} else {
|
||||||
|
//deprecated in API 26
|
||||||
|
vibrator.vibrate(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("showToast", message -> {
|
nativeAndroid.setExternalInterface("showToast", new INativePlayer.INativeInterface() {
|
||||||
Log.d(TAG, "showToast: " + message);
|
@Override
|
||||||
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
|
public void callback(String message) {
|
||||||
});
|
Log.d(TAG, "showToast: " + message);
|
||||||
nativeAndroid.setExternalInterface("getUid", message -> {
|
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
|
||||||
//TODO: 平台的登陆
|
|
||||||
});
|
|
||||||
nativeAndroid.setExternalInterface("@onState", message -> {
|
|
||||||
Log.e(TAG, "Get @onState: " + message);
|
|
||||||
try{
|
|
||||||
JSONObject jsonObject = new JSONObject(message);
|
|
||||||
String state = jsonObject.getString("state");
|
|
||||||
handleStateEvent(state);
|
|
||||||
}
|
}
|
||||||
catch (JSONException e) {
|
});
|
||||||
Log.e(TAG, " onState message failed to analyze");
|
nativeAndroid.setExternalInterface("getUid", new INativePlayer.INativeInterface() {
|
||||||
|
@Override
|
||||||
|
public void callback(String message) {
|
||||||
|
loginVivoAccount();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
nativeAndroid.setExternalInterface("@onState", new INativePlayer.INativeInterface() {
|
||||||
|
@Override
|
||||||
|
public void callback(String message) {
|
||||||
|
Log.e(TAG, "Get @onState: " + message);
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(message);
|
||||||
|
String state = jsonObject.getString("state");
|
||||||
|
handleStateEvent(state);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Log.e(TAG, " onState message failed to analyze");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("@onError", message -> Log.e(TAG, "Get @onError: " + message));
|
nativeAndroid.setExternalInterface("@onError", new INativePlayer.INativeInterface() {
|
||||||
|
@Override
|
||||||
|
public void callback(String message) {
|
||||||
|
Log.e(TAG, "Get @onError: " + message);
|
||||||
|
}
|
||||||
|
});
|
||||||
// 支付
|
// 支付
|
||||||
nativeAndroid.setExternalInterface("pay", message -> {
|
nativeAndroid.setExternalInterface("pay", new INativePlayer.INativeInterface() {
|
||||||
|
@Override
|
||||||
try {
|
public void callback(String message) {
|
||||||
JSONObject jsonObject = new JSONObject(message);
|
Log.i(TAG, "receive pay: " + message);
|
||||||
String cpOrderId = jsonObject.getString("orderId");
|
try {
|
||||||
String productCode = jsonObject.getString("productCode");
|
JSONObject jsonObject = new JSONObject(message);
|
||||||
int count = jsonObject.getInt("count");
|
cpPayOrderNumber = jsonObject.getString("cpOrderNumber");
|
||||||
//TODO: 平台的支付
|
cpOrderAmount = jsonObject.getString("orderAmount");
|
||||||
} catch (JSONException e) {
|
String notifyUrl = jsonObject.getString("notifyUrl");
|
||||||
e.printStackTrace();
|
String productName = jsonObject.getString("productName");
|
||||||
} catch ( Exception e ) {
|
String productDesc = jsonObject.getString("productDesc");
|
||||||
e.printStackTrace();
|
String sign = jsonObject.getString("vivoSignature");
|
||||||
|
String extuid = jsonObject.getString("extuid");
|
||||||
|
//TODO: 平台的支付
|
||||||
|
VivoPayInfo vivoPayInfo = new VivoPayInfo.Builder()
|
||||||
|
.setAppId(appId)
|
||||||
|
.setCpOrderNo(cpPayOrderNumber)
|
||||||
|
.setNotifyUrl(notifyUrl)
|
||||||
|
.setOrderAmount(cpOrderAmount)
|
||||||
|
.setProductName(productName)
|
||||||
|
.setProductDesc(productDesc)
|
||||||
|
.setVivoSignature(sign)
|
||||||
|
.setExtUid(extuid)
|
||||||
|
.build();
|
||||||
|
VivoUnionHelper.payV2(MainActivity.this, vivoPayInfo, mVivoPayCallback);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//let data = {
|
||||||
|
// isCreateRole: isNew,
|
||||||
|
// roleCreateTime: Date.now(),
|
||||||
|
// serverId: 区服ID
|
||||||
|
// serverName: 区服名称
|
||||||
|
// userRoleId: 角色ID
|
||||||
|
// userRoleName: 角色名称
|
||||||
|
// userRoleBalance: giant.Core.hero.coin,
|
||||||
|
// vipLevel: giant.Core.hero.vipLevel,
|
||||||
|
// userRoleLevel: 角色等级
|
||||||
|
// partyId: 0,
|
||||||
|
// partyName: giant.Core.hero.camp,
|
||||||
|
// gameRoleGender: giant.Core.hero.gender,
|
||||||
|
// gameRolePower: giant.Core.hero.power,
|
||||||
|
// };
|
||||||
|
nativeAndroid.setExternalInterface("reportRoleInfo", new INativePlayer.INativeInterface() {
|
||||||
|
@Override
|
||||||
|
public void callback(String message) {
|
||||||
|
Log.i(TAG, "Get reportRoleInfo: " + message);
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(message);
|
||||||
|
String userRoleId = jsonObject.getString("userRoleId");
|
||||||
|
String userRoleLevel = jsonObject.getString("userRoleLevel");
|
||||||
|
String userRoleName = jsonObject.getString("userRoleName");
|
||||||
|
String serverId = jsonObject.getString("serverId");
|
||||||
|
String serverName = jsonObject.getString("serverName");
|
||||||
|
VivoUnionHelper.reportRoleInfo(new VivoRoleInfo(userRoleId, userRoleLevel, userRoleName, serverId, serverName));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e(TAG, "Error reportRoleInfo:" + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -212,4 +419,75 @@ public class MainActivity extends Activity {
|
|||||||
launchScreenImageView = null;
|
launchScreenImageView = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录vivo帐号
|
||||||
|
*/
|
||||||
|
public void loginVivoAccount() {
|
||||||
|
if (!TextUtils.isEmpty(mUid)) {
|
||||||
|
sendUidToGame(mUid, mAuthToken);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接入掉单补单接口一定要掉单注册成功后再调用登录接口
|
||||||
|
*/
|
||||||
|
VivoUnionHelper.login(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录成功后,进行支付
|
||||||
|
*/
|
||||||
|
public void payAfterLogin() {
|
||||||
|
if (TextUtils.isEmpty(mUid)) {
|
||||||
|
Toast.makeText(this, "支付失败,请先登录", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// VivoPayInfo vivoPayInfo = VivoSign.createPayInfo(mUid, getOrderBean());
|
||||||
|
// VivoUnionHelper.payV2(this, vivoPayInfo, mVivoPayCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //直接调起微信或支付宝支付
|
||||||
|
*
|
||||||
|
* @param code 1表示微信,2表示支付宝
|
||||||
|
*/
|
||||||
|
public void payAfterLogin(int code) {
|
||||||
|
if (TextUtils.isEmpty(mUid)) {
|
||||||
|
Toast.makeText(this, "支付失败,请先登录", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// VivoPayInfo vivoPayInfo = VivoSign.createPayInfo(mUid, getOrderBean());
|
||||||
|
// VivoUnionHelper.payNowV2(this, vivoPayInfo, mVivoPayCallback, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未登录时,进行支付
|
||||||
|
*/
|
||||||
|
public void payWithoutLogin() {
|
||||||
|
// VivoPayInfo vivoPayInfo = VivoSign.createPayInfo(mUid, getOrderBean());
|
||||||
|
// VivoUnionHelper.payV2(this, vivoPayInfo, mVivoPayCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未登录时,进行支付,直接调起微信或支付宝支付
|
||||||
|
*
|
||||||
|
* @param code 1表示微信,2表示支付宝
|
||||||
|
*/
|
||||||
|
public void payWithoutLogin(int code) {
|
||||||
|
// VivoPayInfo vivoPayInfo = VivoSign.createPayInfo(mUid, getOrderBean());
|
||||||
|
// VivoUnionHelper.payNowV2(this, vivoPayInfo, mVivoPayCallback, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendUidToGame(String uid, String token) {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
try {
|
||||||
|
obj.put("openid", uid);
|
||||||
|
obj.put("token", token);
|
||||||
|
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import com.android.volley.DefaultRetryPolicy;
|
import com.android.volley.DefaultRetryPolicy;
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
@ -12,11 +13,14 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class AppRequestUtil {
|
public class AppRequestUtil {
|
||||||
private static final AppRequestUtil app_request_util = new AppRequestUtil();
|
private static final AppRequestUtil app_request_util = new AppRequestUtil();
|
||||||
private final Response.ErrorListener errorListener = volleyError -> {
|
private final Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||||
RequestErrorEvent event = new RequestErrorEvent();
|
@Override
|
||||||
event.setType(1);
|
public void onErrorResponse(VolleyError volleyError) {
|
||||||
event.setErrorMessage(volleyError.getMessage());
|
RequestErrorEvent event = new RequestErrorEvent();
|
||||||
EventBus.getDefault().post(event);
|
event.setType(1);
|
||||||
|
event.setErrorMessage(volleyError.getMessage());
|
||||||
|
EventBus.getDefault().post(event);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private AppRequestUtil() {
|
private AppRequestUtil() {
|
||||||
|
@ -14,7 +14,7 @@ public class WebApi {
|
|||||||
|
|
||||||
public void getVersionInfo(BaseInterface iFace) {
|
public void getVersionInfo(BaseInterface iFace) {
|
||||||
this.mInterface = 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";
|
String versionUrl = "https://h5games-al.kingsome.cn/wjtx/config/version_native.json";
|
||||||
AppRequestUtil.getInstance().getRequest(context, versionUrl, new RequestListener() {
|
AppRequestUtil.getInstance().getRequest(context, versionUrl, new RequestListener() {
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -187,12 +188,15 @@ public class AssetsUtil {
|
|||||||
*/
|
*/
|
||||||
public static String readFromFile(Context context, String path) {
|
public static String readFromFile(Context context, String path) {
|
||||||
try {
|
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);
|
BufferedReader bufReader = new BufferedReader(inputReader);
|
||||||
|
|
||||||
String line="";
|
String line="";
|
||||||
StringBuilder result= new StringBuilder();
|
StringBuilder result= new StringBuilder();
|
||||||
while((line = bufReader.readLine()) != null)
|
while((line = bufReader.readLine()) != null)
|
||||||
result.append(line);
|
result.append(line);
|
||||||
|
fileInputStream.close();
|
||||||
inputReader.close();
|
inputReader.close();
|
||||||
bufReader.close();
|
bufReader.close();
|
||||||
return result.toString();
|
return result.toString();
|
||||||
|
117
app/src/main/java/com/hnjc/wjtx/vivo/VivoUnionHelper.java
Normal file
117
app/src/main/java/com/hnjc/wjtx/vivo/VivoUnionHelper.java
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
package com.hnjc.wjtx.vivo;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.vivo.unionsdk.open.MissOrderEventHandler;
|
||||||
|
import com.vivo.unionsdk.open.VivoPayCallback;
|
||||||
|
import com.vivo.unionsdk.open.VivoPayInfo;
|
||||||
|
import com.vivo.unionsdk.open.VivoRoleInfo;
|
||||||
|
import com.vivo.unionsdk.open.VivoUnionSDK;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class VivoUnionHelper {
|
||||||
|
private static final String TAG = "VivoUnionHelper";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化sdk
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param debug
|
||||||
|
*/
|
||||||
|
public static void initSdk(Context context, boolean debug) {
|
||||||
|
VivoUnionSDK.initSdk(context, "104485272", debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单状态
|
||||||
|
*
|
||||||
|
* @param openid 帐号唯一标识,登录后获取
|
||||||
|
*/
|
||||||
|
public static void queryMissOrderResult(String openid) {
|
||||||
|
VivoUnionSDK.queryMissOrderResult(openid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录成功后上报角色信息
|
||||||
|
*
|
||||||
|
* @param vivoRoleInfo 角色信息
|
||||||
|
*/
|
||||||
|
public static void reportRoleInfo(VivoRoleInfo vivoRoleInfo) {
|
||||||
|
VivoUnionSDK.reportRoleInfo(vivoRoleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询是否有调单
|
||||||
|
*
|
||||||
|
* @param missOrderEventHandler
|
||||||
|
*/
|
||||||
|
public static void registerMissOrderEventHandler(final Context context, MissOrderEventHandler missOrderEventHandler) {
|
||||||
|
VivoUnionSDK.registerMissOrderEventHandler(context, missOrderEventHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直接吊起微信与支付宝
|
||||||
|
*
|
||||||
|
* @param activity
|
||||||
|
* @param mVivoPayCallback 支付结果回调
|
||||||
|
* @param code 1表示微信,2表示支付宝
|
||||||
|
*/
|
||||||
|
public static void payNowV2(Activity activity, VivoPayInfo vivoPayInfo, VivoPayCallback mVivoPayCallback, int code) {
|
||||||
|
VivoUnionSDK.payNowV2(activity, vivoPayInfo, mVivoPayCallback, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 吊起支付面板
|
||||||
|
*
|
||||||
|
* @param activity
|
||||||
|
* @param mVivoPayCallback 支付结果回调
|
||||||
|
*/
|
||||||
|
public static void payV2(Activity activity, VivoPayInfo vivoPayInfo, VivoPayCallback mVivoPayCallback) {
|
||||||
|
VivoUnionSDK.payV2(activity, vivoPayInfo, mVivoPayCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录
|
||||||
|
*
|
||||||
|
* @param activity
|
||||||
|
*/
|
||||||
|
public static void login(Activity activity) {
|
||||||
|
VivoUnionSDK.login(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 游戏方发放商品成功主动通知联运
|
||||||
|
*
|
||||||
|
* @param list vivo订单号列表
|
||||||
|
*/
|
||||||
|
public static void reportOrderComplete(List<String> list) {
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VivoUnionSDK.reportOrderComplete(list, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reportOrderComplete(String transNo) {
|
||||||
|
if (TextUtils.isEmpty(transNo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add(transNo);
|
||||||
|
VivoUnionSDK.reportOrderComplete(list, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reportOrderComplete(String transNo, boolean b) {
|
||||||
|
if (TextUtils.isEmpty(transNo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add(transNo);
|
||||||
|
VivoUnionSDK.reportOrderComplete(list, b);
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 195 KiB |
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:opacity="opaque">
|
android:opacity="opaque">
|
||||||
<item android:drawable="@color/color_black"/>
|
<item android:drawable="@color/colorBlack"/>
|
||||||
<item>
|
<item>
|
||||||
<bitmap
|
<bitmap
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
@ -3,5 +3,6 @@
|
|||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#FF4081</color>
|
||||||
|
<color name="colorBlack">#000000</color>
|
||||||
<color name="colorProgressBg">#32000000</color>
|
<color name="colorProgressBg">#32000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
<string name="load_game">下载游戏资源</string>
|
<string name="load_game">下载游戏资源</string>
|
||||||
<string name="start_game">进入游戏</string>
|
<string name="start_game">进入游戏</string>
|
||||||
<string name="preload_path">preload</string>
|
<string name="preload_path">preload</string>
|
||||||
<string name="game_url">http://local/index.html</string>
|
<string name="game_url">http://local/index.html?channel=7104</string>
|
||||||
<string name="local_version">1.0.0</string>
|
<string name="local_version">1.0.0</string>
|
||||||
<string name="load_back">load_back</string>
|
<string name="load_back">load_back</string>
|
||||||
<string name="launch_version">获取游戏版本</string>
|
<string name="launch_version">获取游戏版本</string>
|
||||||
<string name="launch_download">正在更新游戏资源</string>
|
<string name="launch_download">正在更新游戏资源</string>
|
||||||
<string name="launch_unzip">正在解压游戏资源</string>
|
<string name="launch_unzip">正在解压游戏资源</string>
|
||||||
|
<string name="app_id">104485272</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
17
assets/supplierconfig.json
Normal file
17
assets/supplierconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"supplier":{
|
||||||
|
"vivo":{
|
||||||
|
"appid":"104485272"
|
||||||
|
},
|
||||||
|
"xiaomi":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"huawei":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"oppo":{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
258
assets/vivounionsdk/vivounionchecklist.xml
Normal file
258
assets/vivounionsdk/vivounionchecklist.xml
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- activity可正反向检测,service/provider/broadcast只做反向检测 -->
|
||||||
|
<tests xmlns:android="http://schemas.android.com/apk/res/com.vivo.sdkplugin">
|
||||||
|
|
||||||
|
<!-- 正向 -->
|
||||||
|
<!-- 权限 -->
|
||||||
|
<uses-permission android:name="vivo.game.permission.OPEN_JUMP_INTENTS"/>
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.GET_TASKS"/>
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
|
||||||
|
|
||||||
|
<!-- APK/SDK:通用activity -->
|
||||||
|
<activity android:configChanges="orientation|keyboardHidden|navigation|screenSize"
|
||||||
|
android:name="com.vivo.unionsdk.ui.UnionActivity"
|
||||||
|
android:theme="@android:style/Theme.Dialog">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
<data android:host="union.vivo.com"
|
||||||
|
android:path="/openjump"
|
||||||
|
android:scheme="vivounion"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<meta-data android:name="vivo_union_sdk"/>
|
||||||
|
|
||||||
|
<!-- 反向 -->
|
||||||
|
<!-- 测试界面 -->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.TestActivity"/>
|
||||||
|
<!-- aidl service -->
|
||||||
|
<service android:include="false"
|
||||||
|
android:name="com.vivo.plugin.aidl.LoginAccInfoService"/>
|
||||||
|
<!-- 自升级对话框 -->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.upgradelibrary.upmode.VivoUpgradeActivityDialog"/>
|
||||||
|
<!-- 权限检测对话框 -->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.unionsdk.ui.PermissionAlertActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.unionsdk.ui.NonVivoPermissionActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.alipay.sdk.auth.AuthActivity"/>
|
||||||
|
|
||||||
|
<!--SDK含有功能时期声明 start-->
|
||||||
|
<!--微信支付回调-->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="@_pkg_@.wxapi.WXPayEntryActivity"/>
|
||||||
|
<!--QQ钱包支付回调-->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.payment.qqpay.VivoQQPayResultActivity"/>
|
||||||
|
<!--银联支付-->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.unionpay.uppay.PayActivity"/>
|
||||||
|
<!--支付宝支付-->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.alipay.sdk.app.H5PayActivity"/>
|
||||||
|
<!--SDK含有功能时期声明 end-->
|
||||||
|
|
||||||
|
<!-- 老版本声明 start -->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.LoginActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.ChangePassWordActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.BindQuestionActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.BindPhoneActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.GameInfoMoreListActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.AccountPersonalCenterActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.AccountAssistWebViewActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.FindpwdVerifyPhoneNumActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.LoginDialogActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.UserFeedBackActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.SetpwdActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.RegisterEmailActiviy"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.RegisterActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.PhoneRegisterCommitActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.RegisterOneKeyActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.VerifyPhoneNumActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.FindPasswordActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.SetPassWordActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.RegisterProtocolActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.CommitUserIdentifyActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.CommitUserContactActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.StrategyDetailActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.SubAccountActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.SubAccountEditActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.SubAccountEditCommitActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.SubAccountAddCommitActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.activity.VivoUserInfoActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.dealRecord.VivoDealRecordActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.dealRecord.VivoDealRecordDetailActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.PaymentActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.PaymentRechargeActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.SelectMoreChannelActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.TicketActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.PaymentActionActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.CardActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.RechargeChoiceActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.PaySuccActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.JCardActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.DetectPayResultActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.PayContinueActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.RechargeFailActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.PaymentDetailsActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.tenpay.VivoQQPayResultActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbkmobile.iqoo.payment.PaymentActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbkmobile.iqoo.payment.CardActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbkmobile.iqoo.payment.tenpay.VivoQQPayResultActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="@_pkg_@.wxapi.WXSPayEntryActivity"/>
|
||||||
|
|
||||||
|
<service android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.accounts.LocalService"/>
|
||||||
|
<service android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.accounts.LogWatcherService"/>
|
||||||
|
<service android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.service.VivoAccountService"/>
|
||||||
|
<service android:include="false"
|
||||||
|
android:name="com.vivo.assist.AssistService"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.accounts.SendMsgReceiver"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.accounts.ManageAccountReceiver"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.accounts.VivoApkInstallRecevier"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.vivo.sdkplugin.accounts.VivoIThemeChangeRecevier"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.bbkmobile.iqoo.payment.util.ManagePamentReceiver"/>
|
||||||
|
<!-- 老版本声明 end -->
|
||||||
|
|
||||||
|
<!-- 更老版本声明 start -->
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.LoginActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.GameInfoMoreListActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.ChangePassWordActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.BindQuestionActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.BindPhoneActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.AccountPersonalCenterActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.AccountAssistWebViewActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.FindpwdVerifyPhoneNumActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.LoginDialogActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.UserFeedBackActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.SetpwdActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.RegisterEmailActiviy"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.RegisterActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.PhoneRegisterCommitActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.RegisterOneKeyActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.VerifyPhoneNumActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.FindPasswordActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.SetPassWordActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.RegisterProtocolActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.CommitUserIdentifyActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.CommitUserContactActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.StrategyDetailActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.vivo.account.base.activity.SubAccountActivity"/>
|
||||||
|
<activity android:include="false"
|
||||||
|
android:name="com.bbk.payment.weixin.VivoWXPayEntryActivity"/>
|
||||||
|
|
||||||
|
<service android:include="false"
|
||||||
|
android:name="com.vivo.account.base.accounts.LocalService"/>
|
||||||
|
<service android:include="false"
|
||||||
|
android:name="com.vivo.account.base.accounts.LogWatcherService"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.vivo.account.base.accounts.SendMsgReceiver"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.vivo.account.base.accounts.ManageAccountReceiver"/>
|
||||||
|
<receiver android:include="false"
|
||||||
|
android:name="com.vivo.account.base.accounts.VivoApkInstallRecevier"/>
|
||||||
|
<!-- 更老版本声明 end -->
|
||||||
|
<!-- 鉴权sdk start-->
|
||||||
|
<drawable android:include="false"
|
||||||
|
android:name="vivo_game_dialog_bg"/>
|
||||||
|
<drawable android:include="false"
|
||||||
|
android:name="vivo_game_dialog_cancel"/>
|
||||||
|
<drawable android:include="false"
|
||||||
|
android:name="vivo_game_dialog_ok"/>
|
||||||
|
<layout android:include="false"
|
||||||
|
android:name="vivo_game_common_dialog"/>
|
||||||
|
<style android:include="false"
|
||||||
|
android:name="vivo_game_common_dialog"/>
|
||||||
|
<!-- 鉴权sdk end-->
|
||||||
|
|
||||||
|
</tests>
|
14
build.gradle
14
build.gradle
@ -1,17 +1,12 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
|
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.1'
|
classpath 'com.android.tools.build:gradle:3.1.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
@ -20,15 +15,8 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
|
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
flatDir {
|
|
||||||
dirs 'libs'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,4 @@ org.gradle.jvmargs=-Xmx1536m
|
|||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
|
|
||||||
android.injected.testOnly=false
|
android.injected.testOnly=false
|
||||||
android.useAndroidX=true
|
|
||||||
android.enableJetifier=true
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Mon Nov 16 13:55:33 CST 2020
|
#Thu Nov 19 10:36:39 CST 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||||
|
BIN
key/publish_key
BIN
key/publish_key
Binary file not shown.
490
platform.js
Normal file
490
platform.js
Normal file
@ -0,0 +1,490 @@
|
|||||||
|
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 = false;
|
||||||
|
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();
|
||||||
|
if (this.jcChannelId === 8004) {
|
||||||
|
this.quickChannelId = 8004;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
platform.jcChannelId = res.channel;
|
||||||
|
//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
|
||||||
|
};
|
||||||
|
if (platform.quickChannelId) {
|
||||||
|
reqData.poly_sdk_channel = platform.quickChannelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
vipLevel: giant.Core.hero.vipLevel,
|
||||||
|
camp: giant.Core.hero.camp,
|
||||||
|
diamond: giant.Core.hero.diamond,
|
||||||
|
roleCreateTime: giant.Core.hero.ctime,
|
||||||
|
});
|
||||||
|
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 || false,
|
||||||
|
roleCreateTime: giant.Core.hero.ctime,
|
||||||
|
serverId: giant.Core.serverVO.id,
|
||||||
|
serverName: giant.Core.serverVO.name,
|
||||||
|
userRoleId: giant.Core.hero.id,
|
||||||
|
userRoleName: giant.Core.hero.name,
|
||||||
|
userRoleBalance: giant.Core.hero.diamond,
|
||||||
|
vipLevel: giant.Core.hero.vipLevel,
|
||||||
|
userRoleLevel: giant.Core.hero.level,
|
||||||
|
partyId: giant.Core.guildId || 0,
|
||||||
|
partyName: giant.Core.hero.camp,
|
||||||
|
gameRoleGender: giant.Core.hero.gender,
|
||||||
|
gameRolePower: giant.Core.hero.power,
|
||||||
|
job: giant.Core.hero.job,
|
||||||
|
};
|
||||||
|
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