From 4d56e9cf37828d69aa16a3d14b69bb405fbd120f Mon Sep 17 00:00:00 2001 From: "YZ\\249929363" <249929363@qq.com> Date: Wed, 10 Jul 2024 18:23:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Script/module/Config/GameConfig.ts | 5 +- assets/Script/module/Crypto/HttpUtil.ts | 60 +- assets/Script/module/Share.meta | 13 + assets/Script/module/Share/share.ts | 95 + assets/Script/module/Share/share.ts.meta | 10 + assets/Script/module/Tool/GameTool.ts | 27 +- assets/resources/Json/GM_INFO.json | 4 +- build-templates/web-mobile/index.html | 8 +- build-templates/web-mobile/main.js | 6 +- build/Sun_moves.zip | Bin 463645 -> 1876488 bytes .../{config.b4ae4.json => config.8c815.json} | 0 build/Sun_moves/assets/main/index.8c815.js | 1 + build/Sun_moves/assets/main/index.b4ae4.js | 1 - .../assets/resources/config.2d635.json | 1 + .../resources/import/03/03a884c05.9b835.json | 1 + .../resources/import/03/03a988253.ee0d0.json | 1 + ...2c1-f0ea-4671-a0eb-7fd3621032b3.cf6b4.json | 1 + ...0bf-aec8-4b9e-9bc6-fa591a965a82.c6a13.json | 1 + ...dcb-5dba-4b13-960c-9ebe6d17a7db.22ebd.json | 1 + ...479-18ec-4787-b35f-e9a9b3247435.681b4.json | 1 + ...d2b-05af-46c6-bf25-5848b3f2701b.83dfc.json | 1 + ...3aa-e3a6-4d93-8304-afa2c5a8cf9b.9925b.json | 1 + ...660-0583-4fc8-8c2a-4638065fb974.46426.json | 1 + ...be1-5a66-4214-9f7b-9374f9e1c674.d8461.json | 1 + ...e63-4f2f-467d-9c55-0a889d5533a8.34d4f.json | 1 + ...468-0e58-46ac-8ebe-ff0dcd39bad7.76f77.json | 1 + .../Sun_moves/assets/resources/index.2d635.js | 1 + ...101e-d078-4d98-ad65-0861a6427b1b.279b8.png | Bin 0 -> 62149 bytes ...11b2-27cd-4f36-ab70-62a5ccea6074.fc6d4.jpg | Bin 0 -> 14794 bytes ...4a7f-22af-4b3b-baca-b978f07d142f.adf2b.png | Bin 0 -> 10040 bytes ...41ad-9425-44e2-8f55-7740f12b0e0a.b40e5.jpg | Bin 0 -> 20800 bytes ...ec7d-9670-4e5b-8b2a-48a0357215a3.b0011.png | Bin 0 -> 1197616 bytes ...b9d8-9998-46ee-be12-e0231fb5bf69.4e75e.jpg | Bin 0 -> 36245 bytes ...bbd8-ee52-4b10-8fb4-6fddf093bd71.8e53f.png | Bin 0 -> 14171 bytes ...2b60-cba0-416c-a94d-83f4fa65639d.279b8.png | Bin 0 -> 62149 bytes build/Sun_moves/index.html | 12 +- .../{main.90bc5.js => main.e4e65.js} | 10 +- .../{settings.64ad6.js => settings.138c4.js} | 2 +- .../2d69a479-18ec-4787-b35f-e9a9b3247435.json | 4 +- .../43bfc27a-ff6e-45b3-87c7-504d0f781397.js | 29 +- ...3bfc27a-ff6e-45b3-87c7-504d0f781397.js.map | 2 +- .../7290c680-dfdc-4c59-9736-a614cc2a8bcf.js | 130 + ...290c680-dfdc-4c59-9736-a614cc2a8bcf.js.map | 1 + .../771a3d9a-4013-4654-a777-fbaea0c93280.js | 59 +- ...71a3d9a-4013-4654-a777-fbaea0c93280.js.map | 2 +- .../c5692be7-8703-45e4-9f67-23b54d290356.js | 4 +- ...5692be7-8703-45e4-9f67-23b54d290356.js.map | 2 +- library/uuid-to-mtime.json | 240 +- local/layout.editor.json | 2 +- settings/project.json | 2 +- temp/quick-scripts/dst/__file_stats__.json | 2 +- temp/quick-scripts/dst/__qc_bundle__.js | 5406 +++++++++-------- temp/quick-scripts/dst/__qc_index__.js | 1 + temp/quick-scripts/dst/__quick_compile__.js | 2 +- .../assets/Script/module/Config/GameConfig.js | 6 +- .../assets/Script/module/Crypto/HttpUtil.js | 61 +- .../dst/assets/Script/module/Share/share.js | 152 + .../dst/assets/Script/module/Tool/GameTool.js | 31 +- temp/quick-scripts/src/__qc_index__.js | 1 + .../assets/Script/module/Config/GameConfig.js | 4 +- .../Script/module/Config/GameConfig.js.map | 2 +- .../assets/Script/module/Crypto/HttpUtil.js | 59 +- .../Script/module/Crypto/HttpUtil.js.map | 2 +- .../src/assets/Script/module/Share/share.js | 130 + .../assets/Script/module/Share/share.js.map | 1 + .../src/assets/Script/module/Tool/GameTool.js | 29 +- .../assets/Script/module/Tool/GameTool.js.map | 2 +- 67 files changed, 3738 insertions(+), 2898 deletions(-) create mode 100644 assets/Script/module/Share.meta create mode 100644 assets/Script/module/Share/share.ts create mode 100644 assets/Script/module/Share/share.ts.meta rename build/Sun_moves/assets/main/{config.b4ae4.json => config.8c815.json} (100%) create mode 100644 build/Sun_moves/assets/main/index.8c815.js delete mode 100644 build/Sun_moves/assets/main/index.b4ae4.js create mode 100644 build/Sun_moves/assets/resources/config.2d635.json create mode 100644 build/Sun_moves/assets/resources/import/03/03a884c05.9b835.json create mode 100644 build/Sun_moves/assets/resources/import/03/03a988253.ee0d0.json create mode 100644 build/Sun_moves/assets/resources/import/27/2715e2c1-f0ea-4671-a0eb-7fd3621032b3.cf6b4.json create mode 100644 build/Sun_moves/assets/resources/import/2a/2a2550bf-aec8-4b9e-9bc6-fa591a965a82.c6a13.json create mode 100644 build/Sun_moves/assets/resources/import/2c/2cddbdcb-5dba-4b13-960c-9ebe6d17a7db.22ebd.json create mode 100644 build/Sun_moves/assets/resources/import/2d/2d69a479-18ec-4787-b35f-e9a9b3247435.681b4.json create mode 100644 build/Sun_moves/assets/resources/import/5a/5a066d2b-05af-46c6-bf25-5848b3f2701b.83dfc.json create mode 100644 build/Sun_moves/assets/resources/import/c5/c5b773aa-e3a6-4d93-8304-afa2c5a8cf9b.9925b.json create mode 100644 build/Sun_moves/assets/resources/import/d7/d7922660-0583-4fc8-8c2a-4638065fb974.46426.json create mode 100644 build/Sun_moves/assets/resources/import/de/deab9be1-5a66-4214-9f7b-9374f9e1c674.d8461.json create mode 100644 build/Sun_moves/assets/resources/import/e1/e1d57e63-4f2f-467d-9c55-0a889d5533a8.34d4f.json create mode 100644 build/Sun_moves/assets/resources/import/f1/f13b9468-0e58-46ac-8ebe-ff0dcd39bad7.76f77.json create mode 100644 build/Sun_moves/assets/resources/index.2d635.js create mode 100644 build/Sun_moves/assets/resources/native/19/1936101e-d078-4d98-ad65-0861a6427b1b.279b8.png create mode 100644 build/Sun_moves/assets/resources/native/42/424f11b2-27cd-4f36-ab70-62a5ccea6074.fc6d4.jpg create mode 100644 build/Sun_moves/assets/resources/native/53/53054a7f-22af-4b3b-baca-b978f07d142f.adf2b.png create mode 100644 build/Sun_moves/assets/resources/native/7a/7a8b41ad-9425-44e2-8f55-7740f12b0e0a.b40e5.jpg create mode 100644 build/Sun_moves/assets/resources/native/94/9473ec7d-9670-4e5b-8b2a-48a0357215a3.b0011.png create mode 100644 build/Sun_moves/assets/resources/native/b6/b682b9d8-9998-46ee-be12-e0231fb5bf69.4e75e.jpg create mode 100644 build/Sun_moves/assets/resources/native/c5/c52dbbd8-ee52-4b10-8fb4-6fddf093bd71.8e53f.png create mode 100644 build/Sun_moves/assets/resources/native/f1/f1202b60-cba0-416c-a94d-83f4fa65639d.279b8.png rename build/Sun_moves/{main.90bc5.js => main.e4e65.js} (93%) rename build/Sun_moves/src/{settings.64ad6.js => settings.138c4.js} (81%) create mode 100644 library/imports/72/7290c680-dfdc-4c59-9736-a614cc2a8bcf.js create mode 100644 library/imports/72/7290c680-dfdc-4c59-9736-a614cc2a8bcf.js.map create mode 100644 temp/quick-scripts/dst/assets/Script/module/Share/share.js create mode 100644 temp/quick-scripts/src/assets/Script/module/Share/share.js create mode 100644 temp/quick-scripts/src/assets/Script/module/Share/share.js.map diff --git a/assets/Script/module/Config/GameConfig.ts b/assets/Script/module/Config/GameConfig.ts index 759c1b4..4b731af 100644 --- a/assets/Script/module/Config/GameConfig.ts +++ b/assets/Script/module/Config/GameConfig.ts @@ -1,3 +1,4 @@ +import { WeChat } from "../Share/share"; const { ccclass, property } = cc._decorator; @@ -66,7 +67,9 @@ export class GameConfig { } let jsonData: object = res.json!; self.GM_INFO = jsonData["data"]; + WeChat.setShare(location.href); self.Authentication(); + }) cc.resources.load('Json/CLICK_DATA', (err: any, res: cc.JsonAsset) => { if (err) { @@ -99,7 +102,7 @@ export class GameConfig { gameId: '100009', //游戏ID userId: 0, //用户ID guide: true, //是否有引导 - url: "http://api.sparkus.cn",//访问域名 + url: "https://api.sparkus.cn",//访问域名 success: false, //用户游戏成功与否 matchId: null, //用于埋点上传的ID custom: 0 //用于测试跳关卡 diff --git a/assets/Script/module/Crypto/HttpUtil.ts b/assets/Script/module/Crypto/HttpUtil.ts index 9470519..a6d6016 100644 --- a/assets/Script/module/Crypto/HttpUtil.ts +++ b/assets/Script/module/Crypto/HttpUtil.ts @@ -2,14 +2,20 @@ const {ccclass, property} = cc._decorator; import CryptoJS = require('./crypto-js.min.js'); //引用AES源码js -const BASE_URL = "http://api.sparkus.cn"; +const BASE_URL = "https://api.sparkus.cn"; //只负责网络接口 次类只负责和后端交互,不负责处理数据 数据处理在GameTool @ccclass export default class HttpUtil extends cc.Component { + static async getShareInfo(shareUrl: string): Promise { + console.log("设置分享链接:",shareUrl); + const time = Math.floor((new Date().getTime()) / 1000) + const url = HttpUtil.apiSign(`/api/share/cfg?gameId=${config.gameId}&time=${time}&url=${shareUrl}`,{}) + return this.post(url,null,null); + } //排行榜 static async rankData(type,callback,data): Promise { const time = Math.floor((new Date().getTime()) / 1000) - const url = apiSign(`/api/get/rank/data?gameId=${config.gameId}&dataType=${type}&time=${time}`, data) + const url = HttpUtil.apiSign(`/api/get/rank/data?gameId=${config.gameId}&dataType=${type}&time=${time}`, data) this.post(url,data,callback); } @@ -20,7 +26,7 @@ export default class HttpUtil extends cc.Component { //暂时用不到 static async getUserRecord(data,callback): Promise { const time = Math.floor((new Date().getTime()) / 1000) - const url = apiSign(`/api/get/user/data?gameId=${config.gameId}&time=${time}`, data) + const url = HttpUtil.apiSign(`/api/get/user/data?gameId=${config.gameId}&time=${time}`, data) this.post(url,data,callback); } static async post(url, data, callback) { @@ -53,6 +59,31 @@ export default class HttpUtil extends cc.Component { return null; } } + + + /** + * + * @param url {string} 接口地址 + * @param params {object} 需要加密的参数对象 + */ + static apiSign(url: string, params = {}) { + + let convertUrl = url.trim() + if (convertUrl.indexOf('?') === -1) { + convertUrl += '?' + } + + // 传入参数转换拼接字符串 + let postStr = getQueryString(params) + + const signedStr = genSignStr(convertUrl, postStr) + const encryptStr = `sign=${signedStr}` + + let encryptSignStr = fxCry.encryptByDES(encryptStr, config.secretKey) + encryptSignStr = encodeURIComponent(encryptSignStr) + + return `${urlencode(convertUrl)}&_p=${encryptSignStr}` + } } function responseHandler(response: { data: any }) { @@ -195,27 +226,4 @@ function urlencode(url: string): string { return `${baseUrl}?${params.toString()}`; } -/** - * - * @param url {string} 接口地址 - * @param params {object} 需要加密的参数对象 - */ -function apiSign(url: string, params = {}) { - - let convertUrl = url.trim() - if (convertUrl.indexOf('?') === -1) { - convertUrl += '?' - } - - // 传入参数转换拼接字符串 - let postStr = getQueryString(params) - - const signedStr = genSignStr(convertUrl, postStr) - const encryptStr = `sign=${signedStr}` - - let encryptSignStr = fxCry.encryptByDES(encryptStr, config.secretKey) - encryptSignStr = encodeURIComponent(encryptSignStr) - - return `${urlencode(convertUrl)}&_p=${encryptSignStr}` -} diff --git a/assets/Script/module/Share.meta b/assets/Script/module/Share.meta new file mode 100644 index 0000000..73e5bdc --- /dev/null +++ b/assets/Script/module/Share.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "765cf1ea-e992-4789-a609-fbf772888afa", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Script/module/Share/share.ts b/assets/Script/module/Share/share.ts new file mode 100644 index 0000000..952e1d7 --- /dev/null +++ b/assets/Script/module/Share/share.ts @@ -0,0 +1,95 @@ + + +var shareConfig = { + gameId: "100009", + shareLine: "zDLsruVI", + EK:"hui231%1" + }; + +// 定义微信配置数据的接口 +interface IWeChatConfig { + appId: string; + timestamp: number; + nonceStr: string; + signature: string; + jsApiList: []; +} + +// 微信操作类 +export class WeChat { + static setShare(url) { + var urlTemp = this.removeQueryParams(url); + shareConfig.shareLine = urlTemp; + WeChat.getSignature(url); + } + + static getResult(res){ + if(res){ + var data = res.data; + wx.config({ + debug: false, + appId: data.appId, + timestamp: data.timestamp, + nonceStr: data.nonceStr, + signature: data.signature, + jsApiList: ['onMenuShareTimeline','updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage'] + }); + wx.checkJsApi({ + jsApiList: ['updateAppMessageShareData'], // 需要检测的JS接口列表,所有JS接口列表见附录2, + success: function(res) { + setTimeout(() => { + WeChat.changeShare(); + }, 100); + setTimeout(() => { + WeChat.changeShare(); + }, 200); + } + }); + } + } + + static changeShare(){ + wx.ready(() => { + wx.updateAppMessageShareData({ + title: '记忆力认知测评', // 分享标题 + desc: '你的注意力和工作记忆有问题吗?', // 分享描述 + link: shareConfig.shareLine, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: 'https://static.sparkus.cn/public/shootsun.jpg', // 分享图标 + success: function () { + // 设置成功 + console.log("分享好友成功回调"); + } + }); + wx.updateTimelineShareData({ + title: '记忆力认知测评', // 分享标题 + link: shareConfig.shareLine, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 + imgUrl: 'https://static.sparkus.cn/public/shootsun.jpg', // 分享图标 + success: function () { + // 设置成功 + console.log("分享朋友圈成功回调"); + } + }) + }); + } + + static getSignature(url: string): Promise { + return new Promise((resolve) => { + WeChat.getShareInfo((encodeURIComponent(url)),WeChat.getResult); + }); + } + static async getShareInfo(shareUrl: string, callback:Function): Promise { + const time = Math.floor((new Date().getTime()) / 1000) + const url = cc.fx.HttpUtil.apiSign(`/api/share/cfg?gameId=${cc.fx.GameConfig.GM_INFO.gameId}&time=${time}&url=${shareUrl}`,{}) + return cc.fx.HttpUtil.get(url,callback) + } + + + static containsNanana(str) { + return /test/i.test(str); + } + + static removeQueryParams(url) { + return url.replace(/\?.*$/, ''); + } + +} diff --git a/assets/Script/module/Share/share.ts.meta b/assets/Script/module/Share/share.ts.meta new file mode 100644 index 0000000..5137d2b --- /dev/null +++ b/assets/Script/module/Share/share.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "7290c680-dfdc-4c59-9736-a614cc2a8bcf", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Script/module/Tool/GameTool.ts b/assets/Script/module/Tool/GameTool.ts index 515f340..724077f 100644 --- a/assets/Script/module/Tool/GameTool.ts +++ b/assets/Script/module/Tool/GameTool.ts @@ -7,9 +7,10 @@ var GameTool = { //获取userId Authentication(){ let name = "user_" + cc.fx.GameConfig.GM_INFO.gameId; - var data = JSON.parse(localStorage.getItem(name)); + var data = null; + if(localStorage.getItem(name)) data = JSON.parse(localStorage.getItem(name)); if(data == "undifend" || data==null || data == ""){ - let url = "http://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback="+location.href; + let url = "https://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback="+location.href; window.location.href = url; } else{ @@ -23,9 +24,10 @@ var GameTool = { //GAME_DATA 初始化 每次清零 cc.fx.GameConfig.GAME_DATA = []; cc.fx.GameConfig.GAME_DATA.push(cc.fx.GameConfig.CLICK_DATA); + let level = cc.fx.GameConfig.CLICK_DATA.round; cc.fx.GameConfig.CLICK_init(); let data = cc.fx.GameConfig.GAME_DATA; - let matchId = this.getMatchId(); + let matchId = this.getMatchId(level); let postData = { "gameId":cc.fx.GameConfig.GM_INFO.gameId, "userId":cc.fx.GameConfig.GM_INFO.userId, @@ -62,8 +64,9 @@ var GameTool = { cc.fx.HttpUtil.rankData(2,data =>{callback(data)},postData); }, //获取matchId 用于上传每次点击数据里面记录id方便查询 - getMatchId (){ + getMatchId (level){ let matchId = cc.sys.localStorage.getItem("matchId"); + let tempId = matchId; if(matchId == "undifend" || matchId==null){ matchId = this.setMatchId(); } @@ -72,15 +75,20 @@ var GameTool = { matchId = this.setMatchId(); } else{ - let char = parseInt(matchId[10]); - if(this.level == 1){ + let char = parseInt(tempId.substring(10,tempId.length)); + if(level == 1){ char += 1; + matchId = tempId.slice(0, 10) + char + ""; + if(this.containsNanana(matchId)) matchId = this.setMatchId(); + cc.fx.GameConfig.GM_INFO.matchId = matchId; + cc.sys.localStorage.setItem("matchId",matchId); } - matchId = matchId.slice(0, 10) + char + ""; - cc.fx.GameConfig.GM_INFO.matchId = matchId; - cc.sys.localStorage.setItem("matchId",matchId); } } + + if(this.containsNanana(matchId) == true){ + matchId = this.setMatchId(); + } return matchId; }, //检测matchId 如果有缓存以前的nanana数据清除 @@ -104,6 +112,7 @@ var GameTool = { } let data = uuidArray.join('') + 1 + ""; cc.sys.localStorage.setItem("matchNumber",1); + if(this.containsNanana(data)) data = this.setMatchId(); cc.sys.localStorage.setItem("matchId",data); cc.fx.GameConfig.GM_INFO.matchId = data; return data; diff --git a/assets/resources/Json/GM_INFO.json b/assets/resources/Json/GM_INFO.json index 6b1115c..c30f55b 100644 --- a/assets/resources/Json/GM_INFO.json +++ b/assets/resources/Json/GM_INFO.json @@ -4,9 +4,9 @@ "total": 0, "currSeed": 203213, "gameId": "100009", - "userId": 0, + "userId": 200139, "guide": true, - "url": "http://api.sparkus.cn", + "url": "https://api.sparkus.cn", "success": false, "matchId": null, "custom": 0 diff --git a/build-templates/web-mobile/index.html b/build-templates/web-mobile/index.html index bd7eb98..be25e96 100644 --- a/build-templates/web-mobile/index.html +++ b/build-templates/web-mobile/index.html @@ -7,7 +7,6 @@ 后裔逐日 - @@ -141,10 +140,13 @@ - + - + -