50a6e94b-96de-49ff-a88b-aee6d662b014.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. "use strict";
  2. cc._RF.push(module, '50a6elLlt5J/6iLrubWYrAU', 'YZ_Tool_Broswer');
  3. // common-plugin/Scripts/YZ_Tool_Broswer.ts
  4. "use strict";
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. var PlatUtils_1 = require("./PlatUtils");
  7. var Utils_1 = require("./Utils");
  8. var ST_ServerUrl = "http://apps.youlesp.com/aconfig?";
  9. var ST_DefaultServerConfig = "";
  10. var ST_NativeInsertAdClickTimes = "NativeInsertAdClickTimes";
  11. var ST_LastDateTime = "LastDateTime";
  12. var POST_ServerUrl = "https://report.youletd.com/gss?";
  13. var YZ_Tool_Broswer = /** @class */ (function () {
  14. function YZ_Tool_Broswer() {
  15. this._serverConfig = null;
  16. this._nativeInsertAdClickTimes = 0;
  17. this._img_url = "app/editor/static/img/logo-with-text.png";
  18. // 桌面图标是否创建
  19. this._shortcutCreated = false;
  20. }
  21. Object.defineProperty(YZ_Tool_Broswer.prototype, "ServerConfig", {
  22. get: function () {
  23. return this._serverConfig;
  24. },
  25. enumerable: false,
  26. configurable: true
  27. });
  28. Object.defineProperty(YZ_Tool_Broswer.prototype, "NativeInsertAdClickTimes", {
  29. get: function () {
  30. return this._nativeInsertAdClickTimes;
  31. },
  32. enumerable: false,
  33. configurable: true
  34. });
  35. Object.defineProperty(YZ_Tool_Broswer.prototype, "ShortcutCreated", {
  36. get: function () {
  37. return this._shortcutCreated;
  38. },
  39. enumerable: false,
  40. configurable: true
  41. });
  42. Object.defineProperty(YZ_Tool_Broswer.prototype, "img_url", {
  43. get: function () {
  44. return window.location.href + this._img_url;
  45. },
  46. enumerable: false,
  47. configurable: true
  48. });
  49. /**
  50. * 获取交叉推广数据
  51. */
  52. YZ_Tool_Broswer.prototype.getRecommondGameList = function () {
  53. return [
  54. {
  55. "id": "30213731",
  56. "name": "测试一",
  57. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  58. "logo": this.img_url,
  59. "icon": this.img_url
  60. },
  61. {
  62. "id": "30213731",
  63. "name": "测试二",
  64. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  65. "logo": this.img_url,
  66. "icon": this.img_url
  67. },
  68. {
  69. "id": "30213731",
  70. "name": "测试三",
  71. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  72. "logo": this.img_url,
  73. "icon": this.img_url
  74. },
  75. {
  76. "id": "30213731",
  77. "name": "测试四",
  78. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  79. "logo": this.img_url,
  80. "icon": this.img_url
  81. },
  82. {
  83. "id": "30213731",
  84. "name": "测试五",
  85. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  86. "logo": this.img_url,
  87. "icon": this.img_url
  88. },
  89. {
  90. "id": "30213731",
  91. "name": "测试六",
  92. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  93. "logo": this.img_url,
  94. "icon": this.img_url
  95. },
  96. {
  97. "id": "30213731",
  98. "name": "测试七",
  99. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  100. "logo": this.img_url,
  101. "icon": this.img_url
  102. },
  103. {
  104. "id": "30213731",
  105. "name": "测试八",
  106. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  107. "logo": this.img_url,
  108. "icon": this.img_url
  109. },
  110. {
  111. "id": "30213731",
  112. "name": "测试九",
  113. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  114. "logo": this.img_url,
  115. "icon": this.img_url
  116. },
  117. {
  118. "id": "30213731",
  119. "name": "测试10",
  120. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  121. "logo": this.img_url,
  122. "icon": this.img_url
  123. },
  124. {
  125. "id": "30213731",
  126. "name": "测试11",
  127. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  128. "logo": this.img_url,
  129. "icon": this.img_url
  130. },
  131. {
  132. "id": "30213731",
  133. "name": "测试12",
  134. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  135. "logo": this.img_url,
  136. "icon": this.img_url
  137. },
  138. {
  139. "id": "30213731",
  140. "name": "测试13",
  141. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  142. "logo": this.img_url,
  143. "icon": this.img_url
  144. },
  145. {
  146. "id": "30213731",
  147. "name": "测试14",
  148. "appid": "com.yzxx.hcrttt.kyx.nearme.gamecenter",
  149. "logo": this.img_url,
  150. "icon": this.img_url
  151. }
  152. ];
  153. };
  154. /**
  155. *
  156. * @param data 配置数据
  157. */
  158. YZ_Tool_Broswer.prototype.init = function (data) {
  159. if (data) {
  160. var configObj = JSON.parse(data);
  161. if (configObj && configObj.oppo) {
  162. ST_DefaultServerConfig = JSON.stringify(configObj.oppo);
  163. }
  164. }
  165. var self = this;
  166. var xhr = new XMLHttpRequest();
  167. xhr.open('GET', this.img_url);
  168. xhr.send();
  169. xhr.onreadystatechange = function () {
  170. if (xhr.readyState == 4 && xhr.status == 200) {
  171. console.log("测试图片路径正常");
  172. self._loadConfig();
  173. }
  174. if (xhr.readyState == 4 && xhr.status == 404) {
  175. console.log("测试图片路径不存在切换图片路径");
  176. self._img_url = "app/editor/static/preview-templates/splash.png";
  177. self._loadConfig();
  178. }
  179. };
  180. xhr.ontimeout = function () {
  181. console.log("测试图片加载超时切换图片路径");
  182. self._img_url = "app/editor/static/preview-templates/splash.png";
  183. self._loadConfig();
  184. };
  185. xhr.onerror = function (err) {
  186. console.log("测试图片路径异常:" + err + "切换图片路径");
  187. self._img_url = "app/editor/static/preview-templates/splash.png";
  188. self._loadConfig();
  189. };
  190. };
  191. YZ_Tool_Broswer.prototype._loadConfig = function () {
  192. this._serverConfig = JSON.parse(ST_DefaultServerConfig);
  193. this._serverConfig.icon_jump = 5;
  194. this._serverConfig.jump_list = this.getRecommondGameList();
  195. Utils_1.utils.emitServerInitEvent();
  196. };
  197. /**
  198. * 上报自定义事件
  199. * @param level 当前关卡ID
  200. * @param levelName 关卡名称
  201. * @param status 状态
  202. */
  203. YZ_Tool_Broswer.prototype.sendEvent = function (eventName) {
  204. if (PlatUtils_1.default.IsTest) {
  205. // let method = "m=revent";
  206. Utils_1.utils.showLog("上报自定义事件 " + eventName);
  207. // let url: string = POST_ServerUrl + method + `&event=${encodeURI(eventName)}`;
  208. // utils.commomHttpRequest(url, function (ret, data) {
  209. // if (ret) {
  210. // utils.showLog("上报自定义事件成功!");
  211. // } else {
  212. // utils.showLog("上报自定义事件失败!");
  213. // }
  214. // }.bind(this));
  215. }
  216. };
  217. /**
  218. *
  219. * @param level 当前关卡ID
  220. * @param levelName 关卡名称
  221. * @param status 状态
  222. */
  223. YZ_Tool_Broswer.prototype.postLevel = function (level, status, levelName) {
  224. if (PlatUtils_1.default.IsTest) {
  225. // let method = "m=rlevel";
  226. Utils_1.utils.showLog("\u5173\u5361" + level + "," + status);
  227. // let url: string = POST_ServerUrl + method + `&level_id=${level}&level_name=${encodeURI(levelName)}&status=${status}`;
  228. // utils.commomHttpRequest(url, function (ret, data) {
  229. // if (ret) {
  230. // utils.showLog("关卡数据上报成功!");
  231. // } else {
  232. // utils.showLog("关卡数据上报失败!");
  233. // }
  234. // }.bind(this));
  235. }
  236. };
  237. /**
  238. * 实名认证
  239. */
  240. YZ_Tool_Broswer.prototype.realNameAuth = function (code, name, callBack) {
  241. if (!Utils_1.utils._isConfigInit) {
  242. Utils_1.utils.showLog("warn:" + "本地数据未初始化!");
  243. return;
  244. }
  245. var method = "m=realNameAuth";
  246. var completeCallback = callBack;
  247. var xhr = new XMLHttpRequest();
  248. xhr.timeout = 6000; // 单位毫秒
  249. var data = {};
  250. data.kyx = false;
  251. data.app_id = "6103b73b864a9558e6d65af8";
  252. data.channel = "m233";
  253. data.device_uid = 0;
  254. data.uid = "482501611";
  255. data.game_type = 2;
  256. data.device_data = "";
  257. data.game_version = "1.0.0";
  258. data.reqv = "";
  259. data.app_list = "";
  260. data.id_card = code;
  261. data.real_name = name;
  262. var requestData = JSON.stringify(data);
  263. var requestUrl = "https://apps.youlesp.com/gss?" + method + ("&time_stamp=" + (new Date()).getTime() + "&json_data=" + Utils_1.utils.aesEncrypt(requestData));
  264. Utils_1.utils.showLog("服务器地址:" + requestUrl);
  265. xhr.open('GET', requestUrl);
  266. xhr.send();
  267. xhr.onreadystatechange = function () {
  268. Utils_1.utils.showLog("请求状态改变, reaedyState=", xhr.readyState, "; status=", xhr.status);
  269. if (xhr.readyState == 4) {
  270. if (xhr.status == 200) {
  271. if (completeCallback) {
  272. completeCallback(true, Utils_1.utils.aesDecrypt(xhr.responseText));
  273. }
  274. }
  275. else {
  276. if (completeCallback) {
  277. completeCallback(false, "");
  278. }
  279. }
  280. }
  281. if (xhr.status != 200) {
  282. }
  283. };
  284. xhr.ontimeout = function () {
  285. Utils_1.utils.showLog("请求超时!");
  286. if (completeCallback) {
  287. completeCallback(false, "");
  288. }
  289. };
  290. xhr.onerror = function (err) {
  291. if (completeCallback) {
  292. completeCallback(false, "");
  293. }
  294. };
  295. };
  296. return YZ_Tool_Broswer;
  297. }());
  298. exports.default = YZ_Tool_Broswer;
  299. cc._RF.pop();