提交 eb675261 作者: 毛细亚

更新小游戏的SDK重新提交

上级 510cefc2
module.exports = {
app_id: "wx5bf92e3883dc5a82",
game_id: "122",
/**以下参数,请勿随意修改! */
gameVersion: "1.16852"
gameVersion: "1.18364"
}
\ No newline at end of file
......@@ -2,8 +2,8 @@ var __reflect = (this && this.__reflect) || function (p, c, t) {
p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = this && this.__extends || function __extends(t, e) {
function r() {
this.constructor = t;
function r() {
this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
......
......@@ -38,7 +38,7 @@ function checkFile(filePath){
}
})
}
var file1=downConfig({fileName:'release9.bin',variable:'a'})
var file1=downConfig({fileName:'mxy_release_qyppl.bin',variable:'a'})
......
File mode changed from 100755 to 100644
......@@ -11,6 +11,7 @@ window.js_copyright =
"\n抵制不良游戏,拒绝盗版游戏。注意自我保护,谨防受骗上当。适度游戏益脑,沉迷游戏伤身。合理安排时间,享受健康生活。\n适龄提示:适合16岁以上使用";
window.js_gameVars = {
payType: 2,
banshu: false,
forwardWs: 1,
ssl: true,
......@@ -20,7 +21,7 @@ window.js_gameVars = {
platform: 134,
newCreateRole: 1,
publish: true,
qufu_version: "29",
qufu_version: "30",
bgImg: "img/bg11.jpg",
bgImg0: "img/bugu_bg0.jpg",
......@@ -30,7 +31,9 @@ window.js_gameVars = {
subpackage: true,
client: -1,
qufuType: 3,
clientGameVersion: gameVersion,
cfgZipRootDir: "miniGame/",
cfgZipName: "0config.zip",
zipTargetDir: "temp_config/",
newCfgZip: true, //是否有新的 0cfg.zip文件
......@@ -39,12 +42,14 @@ window.js_gameVars = {
configUrl: "",
resUrl: "https://cdn.sszt.app.9125flying.com/shenqi_20210203/assets/resource/",
qufuCdnServer: "https://cdn.sszt.app.9125flying.com/shenqi_20210203/miniGame/",
cdnServerMTest: `https://cdn.sszt.app.9125flying.com/shenqi_20210203/miniGame/${gameVersion}/`,
resUrl: `assets/resource/`,
cdnServer: `https://cdn.sszt.app.9125flying.com/shenqi_20210203/`,
isWX: true,
debug: false,
MLocalResource: [
"allmanifest.json"
],
};
// 启动微信小游戏本地缓存,如果开发者不需要此功能,只需注释即可
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
This source diff could not be displayed because it is too large. You can view the blob instead.
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -3,7 +3,7 @@
*/
const wxFs = wx.getFileSystemManager();
const WX_ROOT = wx.env.USER_DATA_PATH + "/";
const { gameVersion } = "../config/config.js";
function walkFile(dirname, callback) {
const files = wxFs.readdirSync(dirname);
......@@ -73,6 +73,7 @@ export const fs = {
fs_cache[p] = 0;
}
})
if (removeRoot) {
try {
wxFs.rmdirSync(globalDirname, false);
......@@ -210,7 +211,7 @@ export const path = {
const remoteFiles = path.remoteFiles;
const len = remoteFiles.length;
for(let i = 0; i < len; i++) {
for (let i = 0; i < len; i++) {
const key = remoteFiles[i];
if (p.indexOf(key) >= 0) {
p = p.replace(key, path.localFiles[i]);
......@@ -238,13 +239,13 @@ export const path = {
// 可按照网络资源地址分配本地地址,可修改
// 以下为示例,开发者可根据需要进行修改
remoteFiles: [
`${js_gameVars.qufuCdnServer}qufu_resource1/`, //区服资源
`${js_gameVars.qufuCdnServer}img/`, //区服资源
`${js_gameVars.qufuCdnServer}${gameVersion}/resource/`, //前端资源
`${js_gameVars.qufuCdnServer}${gameVersion}/`
`${js_gameVars.cdnServer}qufu_resource1/`, //区服资源
`${js_gameVars.cdnServer}img/`, //区服资源
`${js_gameVars.cdnServer}resource/`, //前端资源
`${js_gameVars.cdnServer}`
],
localFiles: [
'temp_qufu3/', //区服资源
'temp_qufu4/', //区服资源
'temp_img2/', //区服资源
'temp_local/', //前端资源
'temp_root/'
......
......@@ -97,6 +97,19 @@ function loadImage(imageURL, scale9grid) {
function download(url, target) {
const cdnServer = js_gameVars.cdnServer;
if (url.indexOf(cdnServer) >= 0) {
let ret = url.substr(cdnServer.length);
let versioninfo = null;
if (js_gameVars.allManifast) {
versioninfo = js_gameVars.allManifast[ret];
}
if (versioninfo) {
url = cdnServer + "resource/" + versioninfo.v.substr(0, 2) + "/" + versioninfo.v + "_" + versioninfo.s + ret.substring(ret.lastIndexOf("."));
}
}
return new Promise((resolve, reject) => {
......@@ -133,7 +146,7 @@ function download(url, target) {
* 所以开发者应根据URL进行判断,将特定资源进行本地缓存
*/
function needCache(root, url) {
if (url.indexOf("https") >= 0) {
if (url.indexOf("https") >= 0 || url.indexOf("assets/resource") >= 0) {
//可配置的资源不缓存
return false;
} else {
......
......@@ -68,6 +68,20 @@ class TextProcessor {
function loadText(xhrURL) {
const cdnServer = js_gameVars.cdnServer;
if (xhrURL.indexOf(cdnServer) >= 0) {
let ret = xhrURL.substr(cdnServer.length);
let versioninfo = null;
if (js_gameVars.allManifast) {
versioninfo = js_gameVars.allManifast[ret];
}
if (versioninfo) {
xhrURL = cdnServer + "resource/" + versioninfo.v.substr(0, 2) + "/" + versioninfo.v + "_" + versioninfo.s + ret.substring(ret.lastIndexOf("."));
}
}
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
......@@ -97,14 +111,12 @@ function loadText(xhrURL) {
* 所以开发者应根据URL进行判断,将特定资源进行本地缓存
*/
function needCache(root, url) {
if (url.indexOf("https") >= 0) {
if (url.indexOf("https") >= 0 || url.indexOf("assets/resource") >= 0) {
//可配置的资源不缓存
return false;
} else {
if (url.indexOf("resource/") >= 0 || root === "resource/") {
if(url.indexOf("defaultmobile") === -1) {
return true;
}
} else if (root.indexOf("qufu_resource") >= 0 || url.indexOf("qufu_resource") >= 0) {
return true;
} else if (url.indexOf("img/") >= 0) {
......
差异被折叠。 点击展开。
File mode changed from 100755 to 100644
......@@ -2,7 +2,7 @@ import zwsdk from '../libs/sdk.js'
class WxgamePlatform {
checkDownLoadCfgZip() {
let self = this;
const {fs} = require("../library/file-util.js");
const { fs } = require("../library/file-util.js");
const randomNum = Math.floor(Math.random() * js_gameVars.cfgTotalCount);
const cfgJSONfileName = `${js_gameVars.zipTargetDir}${randomNum}config.json`;
......@@ -36,6 +36,7 @@ class WxgamePlatform {
downloadTask;
downloadSCallBack;
downloadSCallBackObj;
downloadCfgZipFailFlag = false;
downLoadCfgZip(sCallBack, sCallBackObj) {
let self = this;
......@@ -49,9 +50,9 @@ class WxgamePlatform {
const WX_ROOT = wx.env.USER_DATA_PATH + "/";
const zipTargetPath = `${WX_ROOT}${js_gameVars.zipTargetDir}`;
const filePath = `${zipTargetPath}${js_gameVars.cfgZipName}`;
const url = `${js_gameVars.cdnServer}cfg0/${js_gameVars.cfgZipName}${js_gameVars.resver}`;
const url = `${js_gameVars.cdnServer}/${js_gameVars.cfgZipRootDir}${js_gameVars.clientGameVersion}/${js_gameVars.cfgZipName}${js_gameVars.resver}`;
const {fs} = require("../library/file-util.js");
const { fs } = require("../library/file-util.js");
const WXFS = wx.getFileSystemManager();
if (!fs.existsSync(js_gameVars.zipTargetDir)) {
WXFS.mkdirSync(zipTargetPath)
......@@ -60,34 +61,55 @@ class WxgamePlatform {
console.log('压缩文件的目录存在');
}
// self.abortLoadTask();
if (self.downloadTask) {
console.warn("downloadTasking !");
return;
}
self.downloadTask = wx.downloadFile({
url,
filePath,
success(res) {
self.downloadTask = null;
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
console.log("download cfgZip success");
let now = egret.getTimer();
console.log("耗时:" + (Math.ceil(now - self.ttt) / 1000));
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
js_gameVars.loadedCfgZip = true;
self.downloadTask = null;
if (self.downloadSCallBack) {
if (self.downloadSCallBackObj) {
self.downloadSCallBack.call(self.downloadSCallBackObj);
self.downloadCfgZipFailFlag = false;
} else {
self.downloadSCallBack();
}
self.downloadSCallBack = null;
self.downloadSCallBackObj = null;
}
console.warn("download cfgZip success but statusCode is " + res.statusCode);
}
self.doDownloadCfgZipCB();
},
fail(err) {
console.warn("download cfgZip fail");
console.log(err);
self.downloadCfgZipFailFlag = true;
self.downloadTask = null;
self.doDownloadCfgZipCB();
}
})
}
// abortLoadTask() {
// if (this.downloadTask) {
// this.downloadTask.abort();
// this.downloadTask = null;
// }
// }
doDownloadCfgZipCB() {
let self = this;
if (self.downloadSCallBack) {
console.log("doDownloadCfgZipCB");
if (self.downloadSCallBackObj) {
self.downloadSCallBack.call(self.downloadSCallBackObj);
} else {
......@@ -97,17 +119,6 @@ class WxgamePlatform {
self.downloadSCallBack = null;
self.downloadSCallBackObj = null;
}
console.warn("download cfgZip fail");
console.log(err);
}
})
}
abortLoadTask() {
if (this.downloadTask) {
this.downloadTask.abort();
}
}
/*********************************************************************************** */
......@@ -156,15 +167,10 @@ class WxgamePlatform {
const isIOS = js_gameVars.isIOS = egret.Capabilities.os === "iOS";
const mSystemInfo = js_gameVars.mSystemInfo = wx.getSystemInfoSync();
let adaptationBang = 0;
const safeAreaData = mSystemInfo.safeArea;
if (safeAreaData.height > safeAreaData.width) {
adaptationBang = safeAreaData.top;
} else {
adaptationBang = safeAreaData.left;
}
js_gameVars.adaptationBang = adaptationBang;
js_gameVars.adaptationBang = safeAreaData.top ? safeAreaData.top : safeAreaData.left;
console.log("js_gameVars.adaptationBang: " + js_gameVars.adaptationBang);
console.log(mSystemInfo)
if (isIOS) {
const IOSGoodMobileModels = [
......@@ -231,6 +237,7 @@ class WxgamePlatform {
console.log("banshu: " + js_gameVars.banshu);
self.getPaySwitch();
qufu.tryStartQFLogic();
}
},
fail(res) {
......@@ -242,6 +249,21 @@ class WxgamePlatform {
})
}
removeOldQufuRes(temp_dir) {
const { fs } = require("../library/file-util.js");
try {
if (fs.existsSync(temp_dir)) {
fs.remove(temp_dir, true);
console.log(`存在 ${temp_dir} 老的缓存文件,并清理`);
} else {
console.log(`不存在 ${temp_dir} 老的缓存文件`);
}
} catch (e) {
console.error(`removeOldQufuRes ${temp_dir} fail!!!`);
console.log(e)
}
}
SDKInit() {
const {app_id, game_id} = require("../config/config.js");
window.ZWSDK = new zwsdk({
......@@ -251,6 +273,7 @@ class WxgamePlatform {
}
SDKLogin() {
let self = this;
const { query } = wx.getEnterOptionsSync();
ZWSDK.login({
state: query.state || '',
......@@ -262,9 +285,11 @@ class WxgamePlatform {
js_gameVars.username = `${player_id}`;
js_gameVars.token = user_token;
qufu.startQFLogic();
qufu.startQFLogic = null;
this.startTime = egret.getTimer();
self.removeOldQufuRes("https"); //最开始缓存设置造成local没有缓存起来
self.removeOldQufuRes("temp_qufu3");
qufu.tryStartQFLogic();
self.startTime = egret.getTimer();
} else {
wx.showModal({
title: "异常",
......@@ -279,27 +304,8 @@ class WxgamePlatform {
SDKGetShareInfo() {
ZWSDK
.getShareInfo({
path: ''
})
.then((res) => {
// console.log("shareInfo")
// console.log(res)
const {status_code, data} = res;
if (1 === status_code) {
const {share_id, title, path, image, qr_code, state} = data.data;
wx.onShareAppMessage(function (res) {
ZWSDK.reportShare({ share_id }).then(res => {
})
return {
title: title,
imageUrl: image,
query: `state=${state}`
}
})
wx.showShareMenu()
}
path: '',
shareAppMessage:false
})
}
......@@ -431,9 +437,14 @@ class WxgamePlatform {
reload(title) {
title = title ? title : "已断开连接";
var content = '点击右上方 [重新进入小程序] 按钮';
if(this.downloadCfgZipFailFlag) {
content = "当前网络设置不给力,请切换其他网络设置,[重新进入小程序]"
}
wx.showModal({
title,
content: '点击右上方 [重新进入小程序] 按钮',
content,
confirmText: '我知道了',
confirmColor: "#000000",
showCancel: false
......
......@@ -38,7 +38,7 @@
"useCompilerPlugins": false
},
"compileType": "game",
"libVersion": "2.21.0",
"libVersion": "game",
"appid": "wx5bf92e3883dc5a82",
"projectname": "SQ-ZhangWang",
"simulatorType": "wechat",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
File mode changed from 100755 to 100644
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论