a73e9c30-34d5-42ca-b6bc-b19f443e2442.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. "use strict";
  2. cc._RF.push(module, 'a73e9wwNNVCyra8sZ9EPiRC', 'YZ_Tool_QQ');
  3. // common-plugin/Scripts/YZ_Tool_QQ.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_QQ = /** @class */ (function () {
  58. function YZ_Tool_QQ() {
  59. /**
  60. * 服务器配置信息
  61. */
  62. this._serverConfig = null;
  63. this._sysInfo = {};
  64. // 桌面图标是否创建
  65. this._shortcutCreated = false;
  66. this._shareCallback = null;
  67. this._isShare = false;
  68. //设备UID
  69. this._uid = "0";
  70. //服务器返回UID
  71. this._service_uid = "0";
  72. this._loginTime = 0;
  73. this._loginInterval = 30;
  74. this._reportLoginTime = 0;
  75. this._reportLoginInterval = 30;
  76. this.isReport = false;
  77. }
  78. Object.defineProperty(YZ_Tool_QQ.prototype, "ServerConfig", {
  79. get: function () {
  80. return this._serverConfig;
  81. },
  82. enumerable: false,
  83. configurable: true
  84. });
  85. Object.defineProperty(YZ_Tool_QQ.prototype, "SysInfo", {
  86. get: function () {
  87. return this._sysInfo;
  88. },
  89. enumerable: false,
  90. configurable: true
  91. });
  92. Object.defineProperty(YZ_Tool_QQ.prototype, "ShortcutCreated", {
  93. get: function () {
  94. return this._shortcutCreated;
  95. },
  96. enumerable: false,
  97. configurable: true
  98. });
  99. /**
  100. * 当前版本号
  101. */
  102. YZ_Tool_QQ.prototype.gameVersion = function () {
  103. return Utils_1.utils.config.qqconfig.version;
  104. };
  105. Object.defineProperty(YZ_Tool_QQ.prototype, "uid", {
  106. get: function () {
  107. // if (this._service_uid != "0") return this._uid;
  108. // this._login();
  109. return "0";
  110. },
  111. enumerable: false,
  112. configurable: true
  113. });
  114. Object.defineProperty(YZ_Tool_QQ.prototype, "serviceId", {
  115. /**
  116. * 服务器返回UID
  117. */
  118. get: function () {
  119. if (this._service_uid != "0")
  120. return this._service_uid;
  121. this.reportLogin();
  122. return "0";
  123. },
  124. enumerable: false,
  125. configurable: true
  126. });
  127. YZ_Tool_QQ.prototype._login = function () {
  128. return __awaiter(this, void 0, void 0, function () {
  129. var curTime, interval, self;
  130. return __generator(this, function (_a) {
  131. curTime = new Date().getTime();
  132. interval = (curTime - this._loginTime) / 1000;
  133. if (interval > 0 && interval < 30) {
  134. Utils_1.utils.showLog("\u767B\u5F55\u8BF7\u6C42\u95F4\u9694\u5C0F\u4E8E\uFF1A" + this._loginInterval + "\u79D2");
  135. return [2 /*return*/];
  136. }
  137. this._loginTime = curTime;
  138. self = this;
  139. Utils_1.utils.showLog("qq暂时不获取uid,uid全部为0");
  140. this._uid = "0";
  141. return [2 /*return*/];
  142. });
  143. });
  144. };
  145. /**
  146. * 上报登录接口获取UID
  147. */
  148. YZ_Tool_QQ.prototype.reportLogin = function () {
  149. var _this = this;
  150. if (this.isReport)
  151. return;
  152. this.isReport = true;
  153. var self = this;
  154. var curTime = new Date().getTime();
  155. var interval = (curTime - self._reportLoginTime) / 1000;
  156. // utils.showLog(interval, " <<<<<<,interval", " _reportLoginTime >>>", self._reportLoginTime);
  157. // console.log(curTime, curTime - self._reportLoginTime, interval)
  158. if (interval > 0 && interval < 30) {
  159. Utils_1.utils.showLog("\u4E0A\u62A5\u767B\u5F55\u83B7\u53D6UID\u5C0F\u4E8E\uFF1A" + self._reportLoginInterval + "\u79D2");
  160. return;
  161. }
  162. self._reportLoginTime = curTime;
  163. var method = "m=login";
  164. var url = ST_ServerUrl + method + "&device_data=0";
  165. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  166. if (ret) {
  167. if (data) {
  168. var result = JSON.parse(data);
  169. Utils_1.utils.showLog("data=" + data);
  170. Utils_1.utils.showLog("result=" + result);
  171. Utils_1.utils.showLog("result.uid=" + result.uid);
  172. if (result.uid) {
  173. self._service_uid = "" + result.uid;
  174. console.log("self._service_uid:" + self._service_uid);
  175. Utils_1.utils.showLog("服务器请求登录成功! _service_uid=" + self._service_uid);
  176. YZ_LocalStorage_1.default.setItem(YZ_Constant_1.default.ST_SERVICE_UID, self._service_uid);
  177. }
  178. }
  179. }
  180. else {
  181. Utils_1.utils.showLog("获取数据失败1");
  182. }
  183. _this.isReport = false;
  184. });
  185. };
  186. /**
  187. *
  188. * @param data 配置数据
  189. */
  190. YZ_Tool_QQ.prototype.init = function (data) {
  191. var _this = this;
  192. if (PlatUtils_1.default.IsQQ) {
  193. if (data) {
  194. var configObj = JSON.parse(data);
  195. if (configObj && configObj.qq) {
  196. ST_DefaultServerConfig = JSON.stringify(configObj.qq);
  197. }
  198. }
  199. this._service_uid = YZ_LocalStorage_1.default.getItem(YZ_Constant_1.default.ST_SERVICE_UID);
  200. this._service_uid = this._service_uid ? this._service_uid : "0";
  201. try {
  202. //@ts-ignore
  203. this._sysInfo = qq.getSystemInfoSync();
  204. Utils_1.utils.showLog("QQ 小游戏平台信息: ", JSON.stringify(this.SysInfo));
  205. }
  206. catch (e) {
  207. Utils_1.utils.showLog("QQ 小游戏平台数据获取失败!");
  208. }
  209. this._loadConfig();
  210. // 开启右上角转发
  211. //@ts-ignore
  212. qq.showShareMenu();
  213. //@ts-ignore
  214. qq.onShareAppMessage(this._getShareInfo.bind(this));
  215. //@ts-ignore
  216. qq.onShow(function (res) {
  217. Utils_1.utils.showLog("OnShow: ", res);
  218. if (_this._isShare) {
  219. _this._isShare = false;
  220. if (_this._shareCallback) {
  221. _this._shareCallback(true, "分享成功!");
  222. }
  223. }
  224. });
  225. Utils_1.utils.registerServerInitEvent(function () {
  226. if (_this.canCreateShortcut()) {
  227. if (Utils_1.utils.ServerConfig && Utils_1.utils.ServerConfig.start_auto_create_short_cut_time) {
  228. Utils_1.utils.SendEvent("组件初始化成功,弹出自动创建桌面!");
  229. Utils_1.utils.showLog("\u7EC4\u4EF6\u521D\u59CB\u5316\u6210\u529F\uFF0C" + Utils_1.utils.ServerConfig.start_auto_create_short_cut_time + "\u79D2\u540E\u5F39\u51FA\u81EA\u52A8\u521B\u5EFA\u684C\u9762\uFF01");
  230. setTimeout(function () {
  231. _this.createShortcut(function (res) {
  232. if (res) {
  233. Utils_1.utils.showLog("自动创建桌面成功!");
  234. }
  235. else {
  236. Utils_1.utils.showLog("自动创建桌面失败!");
  237. }
  238. });
  239. }, Utils_1.utils.ServerConfig.start_auto_create_short_cut_time * 1000);
  240. }
  241. }
  242. if (Utils_1.utils.ServerConfig && Utils_1.utils.ServerConfig.auto_add_favorites && Utils_1.utils.ServerConfig.auto_add_favorites == "true") {
  243. Utils_1.utils.showLog('自动添加到搜藏');
  244. _this.addFavorites();
  245. }
  246. Utils_1.utils.showLog('组件初始化完成,验证是否登陆!', Utils_1.utils.ServerConfig.add_recent_color_sign);
  247. if (Utils_1.utils.ServerConfig && Utils_1.utils.ServerConfig.add_recent_color_sign) {
  248. if (Utils_1.utils.ServerConfig.add_recent_color_sign == 1) {
  249. _this.addColorSign();
  250. }
  251. else {
  252. //@ts-ignore
  253. qq.checkSession({
  254. success: function () {
  255. Utils_1.utils.showLog("session_key 未过期,并且在本生命周期一直有效");
  256. _this.addRecentColorSign();
  257. // session_key 未过期,并且在本生命周期一直有效
  258. },
  259. fail: function () {
  260. // session_key 已经失效,需要重新执行登录流程
  261. //@ts-ignore
  262. qq.login({
  263. success: function (res) {
  264. if (res.code) {
  265. Utils_1.utils.showLog('登录成功!');
  266. _this.addRecentColorSign();
  267. }
  268. else {
  269. Utils_1.utils.showLog('登录失败!' + res.errMsg);
  270. }
  271. }
  272. });
  273. }
  274. });
  275. }
  276. }
  277. }, this);
  278. }
  279. };
  280. /**
  281. * 添加到彩签
  282. */
  283. YZ_Tool_QQ.prototype.addRecentColorSign = function () {
  284. Utils_1.utils.showLog("调用添加彩签>>>>>>>");
  285. //@ts-ignore
  286. qq.addRecentColorSign({
  287. query: 'a=1&b=2',
  288. success: function (res) {
  289. Utils_1.utils.showLog('addRecentColorSign success: ', res);
  290. },
  291. fail: function (err) {
  292. Utils_1.utils.showLog('addRecentColorSign fail: ', err);
  293. },
  294. complete: function (res) {
  295. Utils_1.utils.showLog('addRecentColorSign complete: ', res);
  296. }
  297. });
  298. };
  299. YZ_Tool_QQ.prototype._loadConfig = function () {
  300. var _this = this;
  301. if (PlatUtils_1.default.IsQQ) {
  302. var method = "m=g";
  303. Utils_1.utils.commomHttpRequest(ST_ServerUrl + method, function (ret, data) {
  304. if (ret) {
  305. Utils_1.utils.showLog("QQ服务器配置数据获取成功: data = ", data);
  306. if (data) {
  307. var result = JSON.parse(data);
  308. if (result) {
  309. if (!Utils_1.utils.DebugLoacalConfig) {
  310. _this._serverConfig = result;
  311. }
  312. else {
  313. cc.warn("开启了本地数据测试,使用本地配置!");
  314. }
  315. }
  316. else {
  317. Utils_1.utils.showLog("QQ服务器配置数据不是合法的JSON数据, 使用本地配置!");
  318. }
  319. }
  320. }
  321. else {
  322. Utils_1.utils.showLog("QQ服务器配置数据获取失败, 使用本地配置!");
  323. }
  324. if (!_this._serverConfig) {
  325. _this._serverConfig = JSON.parse(ST_DefaultServerConfig);
  326. }
  327. else {
  328. if (_this._serverConfig.shares) {
  329. if (_this._serverConfig.shares.sy_title) {
  330. Utils_1.utils.config.otherconfig.shareTitle = _this._serverConfig.shares.sy_title;
  331. }
  332. if (_this._serverConfig.shares.sy_img) {
  333. Utils_1.utils.config.otherconfig.shareImgUrl = _this._serverConfig.shares.sy_img;
  334. }
  335. }
  336. if (_this._serverConfig.is_local_pos_id
  337. && _this._serverConfig.is_local_pos_id == "false") {
  338. // 使用服务器下发的广告id
  339. Utils_1.utils.showLog("使用服务器下发的广告id");
  340. Utils_1.utils.config.qqconfig.bannerId = _this._serverConfig.banner_pos_id;
  341. Utils_1.utils.config.qqconfig.insertId = _this._serverConfig.intersititia_pos_id;
  342. Utils_1.utils.config.qqconfig.videoId = _this._serverConfig.video_pos_id;
  343. Utils_1.utils.config.qqconfig.boxId = _this._serverConfig.box_pos_id;
  344. Utils_1.utils.config.qqconfig.bannerBoxId = _this._serverConfig.banner_box_pos_id;
  345. }
  346. else {
  347. Utils_1.utils.showLog("使用本地配置的广告ID");
  348. }
  349. }
  350. Utils_1.utils.emitServerInitEvent();
  351. });
  352. }
  353. };
  354. YZ_Tool_QQ.prototype.getSystemInfo = function () {
  355. if (PlatUtils_1.default.IsQQ) {
  356. return this._sysInfo;
  357. }
  358. };
  359. YZ_Tool_QQ.prototype.share = function (callback) {
  360. if (callback === void 0) { callback = null; }
  361. if (PlatUtils_1.default.IsQQ) {
  362. this._shareCallback = callback;
  363. this._isShare = true;
  364. //@ts-ignore
  365. qq.shareAppMessage(this._getShareInfo());
  366. }
  367. };
  368. /**
  369. * 上报数据
  370. */
  371. YZ_Tool_QQ.prototype.postData = function (otherGameAppId) {
  372. if (PlatUtils_1.default.IsQQ) {
  373. var appid = Utils_1.utils.config.qqconfig.appID;
  374. var uid = "0";
  375. var channel = "qq";
  376. var url = "https://apps.youlesp.com/gs?m=jump&app_id=" + appid + "&uid=" + uid + "&channel=" + channel + "&jump_app_id=" + otherGameAppId;
  377. Utils_1.utils.showLog("上报数据, url=", url);
  378. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  379. if (ret) {
  380. Utils_1.utils.showLog("数据上报成功!");
  381. }
  382. else {
  383. Utils_1.utils.showLog("数据上报失败!");
  384. }
  385. });
  386. }
  387. };
  388. YZ_Tool_QQ.prototype._getShareInfo = function () {
  389. if (PlatUtils_1.default.IsQQ) {
  390. return {
  391. title: Utils_1.utils.config.otherconfig.shareTitle,
  392. imageUrl: Utils_1.utils.config.otherconfig.shareImgUrl
  393. };
  394. }
  395. return {};
  396. };
  397. YZ_Tool_QQ.prototype.isOverMinVersion = function (minVersion) {
  398. var curVersion = this._sysInfo.SDKVersion;
  399. return this._compareVersion(curVersion, minVersion) >= 0;
  400. };
  401. YZ_Tool_QQ.prototype._compareVersion = function (v1, v2) {
  402. if (!v1 || !v2)
  403. return -1;
  404. v1 = v1.split('.');
  405. v2 = v2.split('.');
  406. var len = Math.max(v1.length, v2.length);
  407. while (v1.length < len) {
  408. v1.push('0');
  409. }
  410. while (v2.length < len) {
  411. v2.push('0');
  412. }
  413. for (var i = 0; i < len; i++) {
  414. var num1 = parseInt(v1[i]);
  415. var num2 = parseInt(v2[i]);
  416. if (num1 > num2) {
  417. return 1;
  418. }
  419. else if (num1 < num2) {
  420. return -1;
  421. }
  422. }
  423. return 0;
  424. };
  425. /**
  426. * 上报关卡数据
  427. * @param level 当前关卡ID
  428. * @param levelName 关卡名称
  429. * @param status 状态
  430. */
  431. YZ_Tool_QQ.prototype.postLevel = function (level, status, levelName) {
  432. if (PlatUtils_1.default.IsQQ) {
  433. if (status == YZ_Constant_1.LevelStatus.GameWin) {
  434. if (this.ServerConfig.rankey) {
  435. //排行帮提交数据
  436. var postKey = this.ServerConfig.rankey ? this.ServerConfig.rankey : "ranklevel";
  437. var postValue = level;
  438. //@ts-ignore
  439. qq.setUserCloudStorage({
  440. KVDataList: [
  441. { key: postKey, value: postValue }
  442. ],
  443. success: function (res) {
  444. Utils_1.utils.showLog('关卡记录成功');
  445. },
  446. fail: function (res) {
  447. Utils_1.utils.showLog('关卡记录失败');
  448. },
  449. complete: function (res) {
  450. Utils_1.utils.showLog('关卡记录调用完成');
  451. },
  452. });
  453. }
  454. var interval = this.ServerConfig.subscribe_interval;
  455. if (interval) {
  456. try {
  457. if (parseInt(level) % interval == 0) {
  458. // 长期订阅
  459. //@ts-ignore
  460. qq.subscribeAppMsg({
  461. subscribe: true,
  462. success: function (res) {
  463. Utils_1.utils.showLog("----添加订阅消息----成功", res);
  464. },
  465. fail: function (res) {
  466. Utils_1.utils.showLog("----添加订阅消息----失败", res);
  467. }
  468. });
  469. }
  470. }
  471. catch (error) {
  472. Utils_1.utils.showLog("----添加订阅消息----异常");
  473. }
  474. }
  475. }
  476. var method = "m=rlevel";
  477. var url = POST_ServerUrl + method + ("&level_id=" + level + "&level_name=" + encodeURI(levelName) + "&status=" + status);
  478. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  479. if (ret) {
  480. Utils_1.utils.showLog("关卡数据上报成功!");
  481. }
  482. else {
  483. Utils_1.utils.showLog("关卡数据上报失败!");
  484. }
  485. }.bind(this));
  486. }
  487. };
  488. /**
  489. * 上报自定义事件
  490. * @param level 当前关卡ID
  491. * @param levelName 关卡名称
  492. * @param status 状态
  493. */
  494. YZ_Tool_QQ.prototype.sendEvent = function (eventName) {
  495. if (PlatUtils_1.default.IsQQ) {
  496. var method = "m=revent";
  497. var url = POST_ServerUrl + method + ("&event=" + encodeURI(eventName));
  498. Utils_1.utils.commomHttpRequest(url, function (ret, data) {
  499. if (ret) {
  500. Utils_1.utils.showLog("上报自定义事件成功!");
  501. }
  502. else {
  503. Utils_1.utils.showLog("上报自定义事件失败!");
  504. }
  505. }.bind(this));
  506. }
  507. };
  508. /**
  509. * 弹出提示框
  510. * @param msg 消息
  511. */
  512. YZ_Tool_QQ.prototype.showToast = function (msg) {
  513. if (PlatUtils_1.default.IsQQ) {
  514. //@ts-ignore
  515. qq.showToast({
  516. title: msg,
  517. icon: "none",
  518. duration: 2000
  519. });
  520. }
  521. };
  522. /**
  523. * 是否可以创建桌面图标, 当前平台是否支持创建快捷方式
  524. */
  525. YZ_Tool_QQ.prototype.canCreateShortcut = function () {
  526. console.log("canCreateShortcut ", this.isOverMinVersion("1.7.1"));
  527. if (PlatUtils_1.default.IsQQ && PlatUtils_1.default.IsAndroid) {
  528. return this.isOverMinVersion("1.7.1");
  529. }
  530. return false;
  531. };
  532. /**
  533. * 创建桌面图标
  534. */
  535. YZ_Tool_QQ.prototype.createShortcut = function (callback) {
  536. var _this = this;
  537. var callbackFunc = callback;
  538. if (PlatUtils_1.default.IsQQ && this.canCreateShortcut()) {
  539. //@ts-ignore
  540. qq.saveAppToDesktop({
  541. success: function () {
  542. Utils_1.utils.showLog('桌面图标创建成功!');
  543. _this._shortcutCreated = true;
  544. if (callbackFunc) {
  545. callbackFunc(true);
  546. }
  547. },
  548. fail: function (err) {
  549. Utils_1.utils.showLog('qq创建桌面失败err' + err);
  550. if (callbackFunc) {
  551. callbackFunc(false);
  552. }
  553. },
  554. complete: function () {
  555. }
  556. });
  557. }
  558. else {
  559. Utils_1.utils.showLog("当前平台版本不支持创建桌面");
  560. if (callbackFunc) {
  561. callbackFunc(false);
  562. }
  563. }
  564. };
  565. /**
  566. * 添加收藏
  567. * **/
  568. YZ_Tool_QQ.prototype.addFavorites = function () {
  569. Utils_1.utils.showLog('addFavorites >>>>');
  570. var fav = YZ_LocalStorage_1.default.getItem("qq_favorites");
  571. if ("1" == fav) {
  572. Utils_1.utils.showLog('had addToFavorites');
  573. return;
  574. }
  575. var title = "好游戏哦";
  576. var img = "";
  577. if (Utils_1.utils.config.otherconfig) {
  578. if (Utils_1.utils.config.otherconfig.shareTitle) {
  579. title = Utils_1.utils.config.otherconfig.shareTitle;
  580. }
  581. if (Utils_1.utils.config.otherconfig.shareImgUrl) {
  582. img = Utils_1.utils.config.otherconfig.shareImgUrl;
  583. }
  584. }
  585. //@ts-ignore
  586. qq.addToFavorites({
  587. title: title,
  588. imageUrl: img,
  589. query: 'a=1&b=2',
  590. success: function (res) {
  591. Utils_1.utils.showLog('addToFavorites success', res);
  592. YZ_LocalStorage_1.default.setItem("qq_favorites", "1");
  593. },
  594. fail: function (err) {
  595. Utils_1.utils.showLog('addToFavorites fail', err);
  596. },
  597. complete: function (res) {
  598. Utils_1.utils.showLog('addToFavorites info', res);
  599. }
  600. });
  601. };
  602. /**
  603. * 添加普通彩签
  604. */
  605. YZ_Tool_QQ.prototype.addColorSign = function () {
  606. //@ts-ignore
  607. qq.addColorSign({
  608. success: function (res) {
  609. Utils_1.utils.showLog('addColorSign success', res);
  610. },
  611. fail: function (err) {
  612. Utils_1.utils.showLog('addColorSign fail', err);
  613. },
  614. complete: function (res) {
  615. Utils_1.utils.showLog('addColorSign info', res);
  616. }
  617. });
  618. };
  619. /**
  620. * 退出游戏
  621. */
  622. YZ_Tool_QQ.prototype.GameExit = function () {
  623. if (PlatUtils_1.default.IsQQ) {
  624. Utils_1.utils.showLog("tool qq GameExit");
  625. try {
  626. //@ts-ignore
  627. qq.exitMiniProgram();
  628. }
  629. catch (error) {
  630. cc.log(error);
  631. }
  632. }
  633. };
  634. YZ_Tool_QQ = __decorate([
  635. ccclass
  636. ], YZ_Tool_QQ);
  637. return YZ_Tool_QQ;
  638. }());
  639. exports.default = YZ_Tool_QQ;
  640. cc._RF.pop();