提交 eb675261 作者: 毛细亚

更新小游戏的SDK重新提交

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