修正一些vivo打包过程中的bug
This commit is contained in:
parent
2134db34af
commit
10ebc9c462
@ -3,13 +3,13 @@ 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 18
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0.0"
|
versionName "1.0.0"
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters 'armeabi'
|
abiFilters 'armeabi-v7a'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -36,7 +36,7 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
||||||
implementation(name: 'egret', ext: 'aar')
|
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
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'
|
||||||
}
|
}
|
||||||
|
BIN
app/libs/arm64-v8a/libvivo_account_sdk.so
Normal file
BIN
app/libs/arm64-v8a/libvivo_account_sdk.so
Normal file
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/x86/libvivo_account_sdk.so
Normal file
BIN
app/libs/x86/libvivo_account_sdk.so
Normal file
Binary file not shown.
BIN
app/libs/x86_64/libvivo_account_sdk.so
Normal file
BIN
app/libs/x86_64/libvivo_account_sdk.so
Normal file
Binary file not shown.
4
app/proguard-rules.pro
vendored
4
app/proguard-rules.pro
vendored
@ -83,8 +83,8 @@
|
|||||||
-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.** { *; }
|
||||||
|
@ -16,7 +16,7 @@ public class JCApplication extends Application {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Log.i("JCApplication", "JCApplication onCreate");
|
Log.i("JCApplication", "JCApplication onCreate");
|
||||||
VivoUnionHelper.initSdk(this, false);
|
VivoUnionHelper.initSdk(this, true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 掉单注册接口 需要接入掉单补单处理的一定要加
|
* 掉单注册接口 需要接入掉单补单处理的一定要加
|
||||||
|
@ -25,6 +25,7 @@ import com.hnjc.wjtx.vivo.VivoUnionHelper;
|
|||||||
import com.vivo.unionsdk.open.OrderResultInfo;
|
import com.vivo.unionsdk.open.OrderResultInfo;
|
||||||
import com.vivo.unionsdk.open.VivoAccountCallback;
|
import com.vivo.unionsdk.open.VivoAccountCallback;
|
||||||
import com.vivo.unionsdk.open.VivoConstants;
|
import com.vivo.unionsdk.open.VivoConstants;
|
||||||
|
import com.vivo.unionsdk.open.VivoExitCallback;
|
||||||
import com.vivo.unionsdk.open.VivoPayCallback;
|
import com.vivo.unionsdk.open.VivoPayCallback;
|
||||||
import com.vivo.unionsdk.open.VivoRoleInfo;
|
import com.vivo.unionsdk.open.VivoRoleInfo;
|
||||||
import com.vivo.unionsdk.open.VivoUnionSDK;
|
import com.vivo.unionsdk.open.VivoUnionSDK;
|
||||||
@ -176,7 +177,18 @@ 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) {
|
||||||
|
VivoUnionSDK.exit(this, new VivoExitCallback() {
|
||||||
|
@Override
|
||||||
|
public void onExitCancel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExitConfirm() {
|
||||||
nativeAndroid.exitGame();
|
nativeAndroid.exitGame();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, keyEvent);
|
return super.onKeyDown(keyCode, keyEvent);
|
||||||
|
@ -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"
|
||||||
|
@ -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,7 +3,7 @@
|
|||||||
<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>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
// 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 {
|
||||||
@ -11,7 +10,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.1'
|
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||||
|
|
||||||
// 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
|
||||||
|
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-6.5-all.zip
|
||||||
|
475
platform.js
Normal file
475
platform.js
Normal file
@ -0,0 +1,475 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
orderInfo = {orderId: payData.orderid, productCode: payData.goodid, count: 1};
|
||||||
|
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