d56ddd25-87bf-4079-918e-b4d991514d90.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. "use strict";
  2. cc._RF.push(module, 'd56dd0lh79AeZGOtNmRUU2Q', 'YZ_Tool_Baidu');
  3. // common-plugin/Scripts/YZ_Tool_Baidu.ts
  4. "use strict";
  5. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  9. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10. };
  11. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  12. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  13. return new (P || (P = Promise))(function (resolve, reject) {
  14. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  15. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  16. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  17. step((generator = generator.apply(thisArg, _arguments || [])).next());
  18. });
  19. };
  20. var __generator = (this && this.__generator) || function (thisArg, body) {
  21. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  22. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  23. function verb(n) { return function (v) { return step([n, v]); }; }
  24. function step(op) {
  25. if (f) throw new TypeError("Generator is already executing.");
  26. while (_) try {
  27. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  28. if (y = 0, t) op = [op[0] & 2, t.value];
  29. switch (op[0]) {
  30. case 0: case 1: t = op; break;
  31. case 4: _.label++; return { value: op[1], done: false };
  32. case 5: _.label++; y = op[1]; op = [0]; continue;
  33. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  34. default:
  35. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  36. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  37. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  38. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  39. if (t[2]) _.ops.pop();
  40. _.trys.pop(); continue;
  41. }
  42. op = body.call(thisArg, _);
  43. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  44. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  45. }
  46. };
  47. Object.defineProperty(exports, "__esModule", { value: true });
  48. var PlatUtils_1 = require("./PlatUtils");
  49. var Utils_1 = require("./Utils");
  50. var YZ_Constant_1 = require("./YZ_Constant");
  51. var YZ_LocalStorage_1 = require("./YZ_LocalStorage");
  52. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  53. var ST_ServerUrl = "https://apps.youlesp.com/gss?";
  54. var POST_ServerUrl = "https://report.youletd.com/gss?";
  55. // 默认配置
  56. var ST_DefaultServerConfig = "";
  57. var YZ_Tool_Baidu = /** @class */ (function () {
  58. function YZ_Tool_Baidu() {
  59. this._recorder = null;
  60. this._recommendationButton = null;
  61. this._videoPath = null;
  62. this._serverConfig = null;
  63. this._shareCallback = null;
  64. //@ts-ignore
  65. this.swan = window.swan;
  66. this._sysInfo = {};
  67. //设备UID
  68. this._uid = "0";
  69. //服务器返回UID
  70. this._service_uid = "0";
  71. this._loginTime = 0;
  72. this._loginInterval = 30;
  73. this._reportLoginTime = 0;
  74. this._reportLoginInterval = 30;
  75. this.isReport = false;
  76. }
  77. Object.defineProperty(YZ_Tool_Baidu.prototype, "ServerConfig", {
  78. get: function () {
  79. return this._serverConfig;
  80. },
  81. enumerable: false,
  82. configurable: true
  83. });
  84. Object.defineProperty(YZ_Tool_Baidu.prototype, "SysInfo", {
  85. get: function () {
  86. return this._sysInfo;
  87. },
  88. enumerable: false,
  89. configurable: true
  90. });
  91. /**
  92. * 当前版本号
  93. */
  94. YZ_Tool_Baidu.prototype.gameVersion = function () {
  95. return Utils_1.utils.config.baiduconfig.version;
  96. };
  97. Object.defineProperty(YZ_Tool_Baidu.prototype, "uid", {
  98. get: function () {
  99. // if (this._service_uid != "0") return this._uid;
  100. // this._login();
  101. return "0";
  102. },
  103. enumerable: false,
  104. configurable: true
  105. });
  106. Object.defineProperty(YZ_Tool_Baidu.prototype, "serviceId", {
  107. /**
  108. * 服务器返回UID
  109. */
  110. get: function () {
  111. if (this._service_uid != "0")
  112. return this._service_uid;
  113. this.reportLogin();
  114. return "0";
  115. },
  116. enumerable: false,
  117. configurable: true
  118. });
  119. YZ_Tool_Baidu.prototype._login = function () {
  120. return __awaiter(this, void 0, void 0, function () {
  121. var curTime, interval, self;
  122. return __generator(this, function (_a) {
  123. curTime = new Date().getTime();
  124. interval = (curTime - this._loginTime) / 1000;
  125. if (interval > 0 && interval < 30) {
  126. Utils_1.utils.showLog("\u767B\u5F55\u8BF7\u6C42\u95F4\u9694\u5C0F\u4E8E\uFF1A" + this._loginInterval + "\u79D2");
  127. return [2 /*return*/];
  128. }
  129. this._loginTime = curTime;
  130. self = this;
  131. Utils_1.utils.showLog("baidu暂时不获取uid,uid全部为0");
  132. this._uid = "0";
  133. return [2 /*return*/];
  134. });
  135. });
  136. };
  137. /**
  138. * 上报登录接口获取UID
  139. */
  140. YZ_Tool_Baidu.prototype.reportLogin = function () {
  141. var _this = this;
  142. if (this.isReport)
  143. return;
  144. this.isReport = true;
  145. var self = this;
  146. var curTime = new Date().getTime();
  147. var interval = (curTime - self._reportLoginTime) / 1000;
  148. console.log(curTime, curTime - self._reportLoginTime, interval);
  149. if (interval > 0 && interval < 30) {
  150. Utils_1.utils.showLog("\u4E0A\u62A5\u767B\u5F55\u83B7\u53D6UID\u5C0F\u4E8E\uFF1A" + self._reportLoginInterval + "\u79D2");
  151. return;
  152. }
  153. self._reportLoginTime = curTime;
  154. var method = "m=login";
  155. var url = ST_ServerUrl + method + "&device_data=0";
  156. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  157. if (ret) {
  158. if (data) {
  159. var result = JSON.parse(data);
  160. Utils_1.utils.showLog("data=" + data);
  161. Utils_1.utils.showLog("result=" + result);
  162. Utils_1.utils.showLog("result.uid=" + result.uid);
  163. if (result.uid) {
  164. self._service_uid = "" + result.uid;
  165. console.log("self._service_uid:" + self._service_uid);
  166. Utils_1.utils.showLog("服务器请求登录成功! _service_uid=" + self._service_uid);
  167. YZ_LocalStorage_1.default.setItem(YZ_Constant_1.default.ST_SERVICE_UID, self._service_uid);
  168. }
  169. }
  170. }
  171. else {
  172. Utils_1.utils.showLog("获取数据失败1");
  173. }
  174. _this.isReport = false;
  175. });
  176. };
  177. /**
  178. *
  179. * @param data 配置数据
  180. */
  181. YZ_Tool_Baidu.prototype.init = function (data) {
  182. var _this = this;
  183. if (PlatUtils_1.default.IsBaidu) {
  184. if (data) {
  185. var configObj = JSON.parse(data);
  186. if (configObj && configObj.baidu) {
  187. ST_DefaultServerConfig = JSON.stringify(configObj.baidu);
  188. }
  189. }
  190. this._service_uid = YZ_LocalStorage_1.default.getItem(YZ_Constant_1.default.ST_SERVICE_UID);
  191. this._service_uid = this._service_uid ? this._service_uid : "0";
  192. // 获取系统信息
  193. this._sysInfo = this.swan.getSystemInfoSync();
  194. if (this._sysInfo) {
  195. Utils_1.utils.showLog("百度小游戏平台信息: ", JSON.stringify(this._sysInfo));
  196. }
  197. else {
  198. Utils_1.utils.showLog("系统信息获取失败!");
  199. }
  200. this._loadConfig();
  201. if (this.canRecord()) {
  202. this._recorder = this.swan.getVideoRecorderManager();
  203. if (this._recorder) {
  204. this._recorder.onStart(function (res) {
  205. Utils_1.utils.showLog("开始录屏回调: ", res);
  206. Utils_1.utils.isRecording = true;
  207. cc.game.emit("YZ_CommonMessage", { type: "YZ_RecordStart" });
  208. });
  209. this._recorder.onStop(function (res) {
  210. Utils_1.utils.showLog("结束录屏回调: ", res.videoPath);
  211. Utils_1.utils.isRecording = false;
  212. _this._videoPath = res.videoPath;
  213. cc.game.emit("YZ_CommonMessage", { type: "YZ_RecordEnd" });
  214. });
  215. this._recorder.onError(function (err) {
  216. Utils_1.utils.isRecording = false;
  217. if (err) {
  218. Utils_1.utils.showLog("录屏出错 : ", err.errCode, err.errMsg);
  219. cc.game.emit("YZ_CommonMessage", { type: "YZ_RecordEnd" });
  220. }
  221. });
  222. }
  223. }
  224. // 显示左上角的分享菜单
  225. this.swan.showShareMenu();
  226. this.swan.onShareAppMessage(function () {
  227. return _this._getShareInfo();
  228. });
  229. }
  230. };
  231. YZ_Tool_Baidu.prototype._loadConfig = function () {
  232. var _this = this;
  233. if (PlatUtils_1.default.IsBaidu) {
  234. var method = "m=g";
  235. Utils_1.utils.commomHttpRequest(ST_ServerUrl + method, function (ret, data) {
  236. if (ret) {
  237. Utils_1.utils.showLog("百度服务器配置数据获取成功: data = ", data);
  238. if (data) {
  239. var result = JSON.parse(data);
  240. if (result) {
  241. if (!Utils_1.utils.DebugLoacalConfig) {
  242. _this._serverConfig = result;
  243. }
  244. else {
  245. cc.warn("开启了本地数据测试,使用本地配置!");
  246. }
  247. }
  248. else {
  249. Utils_1.utils.showLog("百度服务器配置数据不是合法的JSON数据, 使用本地配置!");
  250. }
  251. }
  252. }
  253. else {
  254. Utils_1.utils.showLog("百度服务器配置数据获取失败, 使用本地配置!");
  255. }
  256. if (!_this._serverConfig) {
  257. _this._serverConfig = JSON.parse(ST_DefaultServerConfig);
  258. }
  259. else {
  260. if (_this._serverConfig.is_local_pos_id
  261. && _this._serverConfig.is_local_pos_id == "false") {
  262. // 使用服务器下发的广告id
  263. Utils_1.utils.showLog("使用服务器下发的广告id");
  264. Utils_1.utils.config.baiduconfig.bannerId = _this._serverConfig.banner_pos_id;
  265. Utils_1.utils.config.baiduconfig.videoId = _this._serverConfig.video_pos_id;
  266. }
  267. else {
  268. Utils_1.utils.showLog("使用本地配置的广告ID");
  269. }
  270. }
  271. Utils_1.utils.emitServerInitEvent();
  272. });
  273. }
  274. };
  275. /**
  276. * 显示推荐游戏按钮
  277. */
  278. YZ_Tool_Baidu.prototype.showRecommendationButton = function (params) {
  279. var _this = this;
  280. var styleParams = params;
  281. if (PlatUtils_1.default.IsBaidu && this.canShowRecommendButton()) {
  282. if (false) {
  283. Utils_1.utils.showLog("按钮存在,直接显示");
  284. this._recommendationButton.show();
  285. this._setRecommendBtnStyle(this._recommendationButton, styleParams);
  286. }
  287. else {
  288. Utils_1.utils.showLog("创建并显示");
  289. this._recommendationButton = this.swan.createRecommendationButton({
  290. type: 'list',
  291. style: {
  292. left: -300,
  293. top: -300
  294. }
  295. });
  296. if (this._recommendationButton) {
  297. // 监听按钮资源加载完成
  298. this._recommendationButton.onLoad(function () {
  299. // 显示按钮
  300. _this._recommendationButton.show();
  301. _this._setRecommendBtnStyle(_this._recommendationButton, styleParams);
  302. });
  303. this._recommendationButton.onError(function (err) {
  304. if (err) {
  305. Utils_1.utils.showLog("交叉推广按钮出错 : ", err.errCode, err.errMsg);
  306. }
  307. });
  308. // 触发资源加载
  309. this._recommendationButton.load();
  310. }
  311. }
  312. return this._recommendationButton;
  313. }
  314. else {
  315. return null;
  316. }
  317. };
  318. YZ_Tool_Baidu.prototype._setRecommendBtnStyle = function (btn, params) {
  319. if (btn) {
  320. var left = 0;
  321. var top = 0;
  322. if (params) {
  323. Utils_1.utils.showLog("params:", params);
  324. if (params.left) {
  325. left = params.left / cc.view.getDesignResolutionSize().width * this._sysInfo.screenWidth;
  326. }
  327. else if (params.right) {
  328. left = this._sysInfo.screenWidth - params.right / cc.view.getDesignResolutionSize().width * this._sysInfo.screenWidth - btn.style.width;
  329. }
  330. if (params.top) {
  331. top = params.top / cc.view.getDesignResolutionSize().height * this._sysInfo.screenHeight;
  332. }
  333. else if (params.bottom) {
  334. top = this._sysInfo.screenHeight - params.bottom / cc.view.getDesignResolutionSize().height * this._sysInfo.screenHeight - btn.style.height;
  335. }
  336. }
  337. Utils_1.utils.showLog("top:" + top + "; left:" + left);
  338. btn.style.top = top;
  339. btn.style.left = left;
  340. }
  341. };
  342. /**
  343. * 隐藏推荐游戏按钮
  344. */
  345. YZ_Tool_Baidu.prototype.hideRecommendationButton = function () {
  346. if (PlatUtils_1.default.IsBaidu && this.canShowRecommendButton()) {
  347. if (this._recommendationButton) {
  348. this._recommendationButton.hide();
  349. }
  350. }
  351. };
  352. /**
  353. * 开始录屏
  354. */
  355. YZ_Tool_Baidu.prototype.recordStart = function () {
  356. if (PlatUtils_1.default.IsBaidu && this.canRecord()) {
  357. Utils_1.utils.showLog("开始录屏");
  358. if (this._recorder) {
  359. this._recorder.start({
  360. duration: 120
  361. });
  362. }
  363. }
  364. };
  365. /**
  366. * 结束录屏
  367. */
  368. YZ_Tool_Baidu.prototype.recordEnd = function () {
  369. if (PlatUtils_1.default.IsBaidu && this.canRecord()) {
  370. Utils_1.utils.showLog("结束录屏");
  371. if (this._recorder) {
  372. this._recorder.stop();
  373. }
  374. }
  375. };
  376. /**
  377. * 分享录屏
  378. */
  379. YZ_Tool_Baidu.prototype.shareVideo = function () {
  380. if (PlatUtils_1.default.IsBaidu) {
  381. if (this._videoPath) {
  382. var self_1 = this;
  383. this.swan.shareVideo({
  384. videoPath: this._videoPath,
  385. success: function () {
  386. Utils_1.utils.showLog('分享成功');
  387. self_1._videoPath = "";
  388. if (self_1._shareCallback) {
  389. self_1._shareCallback(true);
  390. }
  391. },
  392. fail: function (res) {
  393. self_1._videoPath = "";
  394. Utils_1.utils.showLog('分享失败');
  395. if (self_1._shareCallback) {
  396. self_1._shareCallback(false, "分享失败!");
  397. }
  398. }
  399. });
  400. }
  401. }
  402. };
  403. /**
  404. * 分享图片
  405. */
  406. YZ_Tool_Baidu.prototype.shareImage = function () {
  407. if (PlatUtils_1.default.IsBaidu) {
  408. this.swan.shareAppMessage(this._getShareInfo());
  409. }
  410. };
  411. /**
  412. * 分享,有录屏就分享录屏,没有录屏就分享图片
  413. */
  414. YZ_Tool_Baidu.prototype.share = function (callback) {
  415. if (PlatUtils_1.default.IsBaidu) {
  416. this._shareCallback = callback;
  417. if (this._videoPath) {
  418. this.shareVideo();
  419. }
  420. else {
  421. this.shareImage();
  422. }
  423. }
  424. };
  425. YZ_Tool_Baidu.prototype._getShareInfo = function () {
  426. if (PlatUtils_1.default.IsBaidu) {
  427. var shareInfo = Utils_1.utils.getShareInfo();
  428. var self_2 = this;
  429. if (shareInfo) {
  430. return {
  431. title: shareInfo.title,
  432. imageUrl: shareInfo.imageUrl,
  433. success: function (res) {
  434. if (self_2._shareCallback) {
  435. self_2._shareCallback(true);
  436. }
  437. Utils_1.utils.showLog("分享成功!");
  438. },
  439. fail: function (err) {
  440. if (self_2._shareCallback) {
  441. self_2._shareCallback(false, "分享失败!");
  442. }
  443. Utils_1.utils.showLog("分享失败!");
  444. }
  445. };
  446. }
  447. }
  448. return {};
  449. };
  450. /**
  451. * 是否可以录屏
  452. */
  453. YZ_Tool_Baidu.prototype.canRecord = function () {
  454. if (PlatUtils_1.default.IsBaidu) {
  455. if (this._sysInfo) {
  456. return this._compareVersion(this._sysInfo.SDKVersion, "1.4.1") && PlatUtils_1.default.IsAndroid;
  457. }
  458. return false;
  459. }
  460. return false;
  461. };
  462. /**
  463. * 是否可以显示交叉推广按钮
  464. */
  465. YZ_Tool_Baidu.prototype.canShowRecommendButton = function () {
  466. if (PlatUtils_1.default.IsBaidu) {
  467. if (this._sysInfo) {
  468. return this._compareVersion(this._sysInfo.SDKVersion, "1.5.2") && PlatUtils_1.default.IsAndroid;
  469. }
  470. return false;
  471. }
  472. return false;
  473. };
  474. /**
  475. * 是否可以显示添加到我的小程序引导
  476. */
  477. YZ_Tool_Baidu.prototype.canShowFavoriteGuide = function () {
  478. if (PlatUtils_1.default.IsBaidu) {
  479. if (this._sysInfo) {
  480. return this._compareVersion(this._sysInfo.SDKVersion, "1.7.2");
  481. }
  482. return false;
  483. }
  484. return false;
  485. };
  486. YZ_Tool_Baidu.prototype._compareVersion = function (first, second) {
  487. return parseInt(first.split(".").join("")) >= parseInt(second.split(".").join(""));
  488. };
  489. /**
  490. * 跳转到指定的小游戏
  491. * @param pkgName 包名
  492. * @param callback Function(ret) 跳转回调. ret: true | false
  493. */
  494. YZ_Tool_Baidu.prototype.navigateToMiniGame = function (pkgName, callback) {
  495. if (PlatUtils_1.default.IsBaidu) {
  496. var completeCallback_1 = callback;
  497. if (!pkgName) {
  498. Utils_1.utils.showLog("跳转ID为null");
  499. if (completeCallback_1) {
  500. completeCallback_1(false);
  501. }
  502. return;
  503. }
  504. this.swan.navigateToMiniProgram({
  505. appKey: pkgName,
  506. path: "",
  507. extraData: {},
  508. success: function (res) {
  509. Utils_1.utils.showLog("跳转成功!");
  510. if (completeCallback_1) {
  511. completeCallback_1(true);
  512. }
  513. },
  514. fail: function (error) {
  515. Utils_1.utils.showLog("跳转失败!");
  516. if (completeCallback_1) {
  517. completeCallback_1(false);
  518. }
  519. }
  520. });
  521. }
  522. };
  523. /**
  524. * 上报数据
  525. */
  526. YZ_Tool_Baidu.prototype.postData = function (otherGameAppId) {
  527. if (PlatUtils_1.default.IsBaidu) {
  528. var appid = Utils_1.utils.config.baiduconfig.appID;
  529. var uid = "0";
  530. var channel = "baidu";
  531. var method = "m=jump";
  532. var url = POST_ServerUrl + " + " + method + " + &app_id=" + appid + "&uid=" + uid + "&channel=" + channel + "&jump_app_id=" + otherGameAppId;
  533. Utils_1.utils.showLog("上报数据, url=", url);
  534. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  535. if (ret) {
  536. Utils_1.utils.showLog("数据上报成功!");
  537. }
  538. else {
  539. Utils_1.utils.showLog("数据上报失败!");
  540. }
  541. });
  542. }
  543. };
  544. /**
  545. * 获取交叉推广数据
  546. */
  547. YZ_Tool_Baidu.prototype.getRecommondGameList = function () {
  548. if (PlatUtils_1.default.IsBaidu
  549. && Utils_1.utils.Tool_Baidu
  550. && Utils_1.utils.Tool_Baidu.ServerConfig) {
  551. return Utils_1.utils.Tool_Baidu.ServerConfig.jump_list;
  552. }
  553. return null;
  554. };
  555. /**
  556. * 上报关卡数据
  557. * @param level 当前关卡ID
  558. * @param levelName 关卡名称
  559. * @param status 状态
  560. */
  561. YZ_Tool_Baidu.prototype.postLevel = function (level, status, levelName) {
  562. if (PlatUtils_1.default.IsBaidu) {
  563. var method = "m=rlevel";
  564. var url = POST_ServerUrl + method + ("&level_id=" + level + "&level_name=" + encodeURI(levelName) + "&status=" + status);
  565. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  566. if (ret) {
  567. Utils_1.utils.showLog("关卡数据上报成功!");
  568. }
  569. else {
  570. Utils_1.utils.showLog("关卡数据上报失败!");
  571. }
  572. }.bind(this));
  573. }
  574. };
  575. /**
  576. * 上报自定义事件
  577. * @param level 当前关卡ID
  578. * @param levelName 关卡名称
  579. * @param status 状态
  580. */
  581. YZ_Tool_Baidu.prototype.sendEvent = function (eventName) {
  582. if (PlatUtils_1.default.IsBaidu) {
  583. var method = "m=revent";
  584. var url = POST_ServerUrl + method + ("&event=" + encodeURI(eventName));
  585. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  586. if (ret) {
  587. Utils_1.utils.showLog("上报自定义事件成功!");
  588. }
  589. else {
  590. Utils_1.utils.showLog("上报自定义事件失败!");
  591. }
  592. }.bind(this));
  593. }
  594. };
  595. /**
  596. * 弹出提示框
  597. * @param msg 消息
  598. */
  599. YZ_Tool_Baidu.prototype.showToast = function (msg) {
  600. if (PlatUtils_1.default.IsBaidu) {
  601. //@ts-ignore
  602. swan.showToast({
  603. title: msg,
  604. icon: "none",
  605. duration: 2000,
  606. success: function (res) {
  607. console.log("" + res);
  608. },
  609. fail: function (res) {
  610. console.log("showToast\u8C03\u7528\u5931\u8D25");
  611. }
  612. });
  613. }
  614. };
  615. YZ_Tool_Baidu = __decorate([
  616. ccclass
  617. ], YZ_Tool_Baidu);
  618. return YZ_Tool_Baidu;
  619. }());
  620. exports.default = YZ_Tool_Baidu;
  621. cc._RF.pop();