YZ_Tool_Douyin.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. import PlatUtils from "./PlatUtils";
  2. import { utils } from "./Utils";
  3. import YZ_Constant, { LevelStatus } from "./YZ_Constant";
  4. import YZ_LocalStorage from "./YZ_LocalStorage";
  5. const { ccclass, property } = cc._decorator;
  6. const ST_ServerUrl: string = "https://apps.youlesp.com/gss?";
  7. const POST_ServerUrl: string = "https://report.youletd.com/gss?";
  8. // 默认配置
  9. let ST_DefaultServerConfig: string = "";
  10. @ccclass
  11. export default class YZ_Tool_Douyin {
  12. _recorder: any = null;
  13. _videoPath: string = null;
  14. _shareCallback: Function = null;
  15. recorderStarTime: number = 0; //开始录屏时间
  16. isAutoShare: boolean = true; //是否自动分享
  17. isClickEnd: boolean = false;
  18. isNewsArticleLite: boolean = false; //是否头条极速版
  19. //@ts-ignore
  20. tt = window.tt;
  21. /**
  22. * 服务器配置信息
  23. */
  24. _serverConfig: any = null;
  25. public get ServerConfig() {
  26. return this._serverConfig;
  27. }
  28. /**
  29. * 当前版本号
  30. */
  31. public gameVersion(): string {
  32. return utils.config.douyinconfig.version;
  33. }
  34. //设备UID
  35. _uid: string = "0";
  36. public get uid() {
  37. // if (this._service_uid != "0") return this._uid;
  38. // this._login();
  39. return "0";
  40. }
  41. //服务器返回UID
  42. _service_uid: string = "0";
  43. /**
  44. * 服务器返回UID
  45. */
  46. public get serviceId() {
  47. if (this._service_uid != "0") return this._service_uid;
  48. this.reportLogin();
  49. return "0";
  50. }
  51. _loginTime: number = 0;
  52. _loginInterval: number = 30;
  53. async _login() {
  54. let curTime: number = new Date().getTime();
  55. let interval: number = (curTime - this._loginTime) / 1000;
  56. if (interval > 0 && interval < 30) {
  57. utils.showLog(`登录请求间隔小于:${this._loginInterval}秒`);
  58. return;
  59. }
  60. this._loginTime = curTime;
  61. let self = this;
  62. utils.showLog("douying暂时不获取uid,uid全部为0");
  63. this._uid = "0";
  64. // this.reportLogin();
  65. }
  66. login() {
  67. utils.showLog("douying login");
  68. //@ts-ignore
  69. tt.login({
  70. withRealNameAuthenticationInfo: true,
  71. success: (_res) => {
  72. utils.showLog("登录成功");
  73. // 调用 getUserInfo 前, 请确保登录成功
  74. //实名认证需要用户点击触发
  75. //@ts-ignore
  76. // 获取用户信息
  77. tt.getUserInfo({
  78. // withCredentials: true,
  79. withRealNameAuthenticationInfo: true,
  80. success: (res) => {
  81. utils.showLog(`getUserInfo 调用成功`, res.userInfo);
  82. if (res.userInfo) {
  83. if (res.userInfo.realNameAuthenticationStatus && res.userInfo.realNameAuthenticationStatus == "uncertified") {
  84. utils.showLog(`getUserInfo 用户未进行实名制!`);
  85. this.realNameAuth();
  86. } else if (res.userInfo.realNameAuthenticationStatus && res.userInfo.realNameAuthenticationStatus == "certified") {
  87. utils.showLog(`getUserInfo 用户已实名制!`);
  88. cc.game.emit(YZ_Constant.ST_LOGIN_SUCCESS);
  89. } else {
  90. cc.game.emit(YZ_Constant.ST_LOGIN_FAIL);
  91. }
  92. }
  93. },
  94. fail(res) {
  95. utils.showLog(`getUserInfo 调用失败`, res.errMsg);
  96. }
  97. })
  98. },
  99. fail: () => {
  100. cc.game.emit(YZ_Constant.ST_LOGIN_FAIL);
  101. this.showToast("登录失败!");
  102. }
  103. });
  104. }
  105. realNameAuth() {
  106. utils.showLog("douying realNameAuth");
  107. //@ts-ignore
  108. tt.authenticateRealName({
  109. success: (_res) => {
  110. utils.showLog("用户实名认证成功");
  111. cc.game.emit(YZ_Constant.ST_LOGIN_SUCCESS);
  112. },
  113. fail: (res) => {
  114. this.showToast("实名制认证失败,请稍后重试!");
  115. cc.game.emit(YZ_Constant.ST_LOGIN_FAIL);
  116. utils.showLog("用户实名认证失败", res.errMsg);
  117. },
  118. });
  119. }
  120. _reportLoginTime: number = 0;
  121. _reportLoginInterval: number = 30;
  122. isReport: boolean = false;
  123. _jumpIds: string = "";
  124. /**
  125. * 上报登录接口获取UID
  126. */
  127. reportLogin() {
  128. if (this.isReport) return;
  129. this.isReport = true;
  130. let self = this;
  131. let curTime: number = new Date().getTime();
  132. let interval: number = (curTime - self._reportLoginTime) / 1000;
  133. if (interval > 0 && interval < 30) {
  134. utils.showLog(`上报登录获取UID小于:${self._reportLoginInterval}秒`);
  135. return;
  136. }
  137. self._reportLoginTime = curTime;
  138. let method = "m=login";
  139. let url: string = ST_ServerUrl + method + `&device_data=0`;
  140. utils.commomHttpRequest(url, (ret, data) => {
  141. if (ret) {
  142. if (data) {
  143. let result = JSON.parse(data);
  144. utils.showLog("data=" + data);
  145. utils.showLog("result=" + result);
  146. utils.showLog("result.uid=" + result.uid);
  147. if (result.uid) {
  148. self._service_uid = "" + result.uid;
  149. utils.showLog("服务器请求登录成功! _service_uid=" + self._service_uid);
  150. YZ_LocalStorage.setItem(YZ_Constant.ST_SERVICE_UID, self._service_uid);
  151. }
  152. }
  153. } else {
  154. utils.showLog("获取数据失败1");
  155. }
  156. this.isReport = false;
  157. })
  158. }
  159. _sysInfo: any = null;
  160. //是否是点完暂停按钮后自动分享得录屏
  161. is_auto_share_video: boolean = false;
  162. /**
  163. * 自动分享次数
  164. */
  165. recored_share_count: number = 0;
  166. appLaunchOptions: any[] = [];
  167. /**
  168. *
  169. * @param data 配置数据.
  170. */
  171. public init(data: string) {
  172. if (PlatUtils.IsDouyin) {
  173. if (data) {
  174. let configObj: any = JSON.parse(data);
  175. if (configObj && configObj.toutiao) {
  176. utils.showLog("本地配置数据:" + JSON.stringify(configObj.toutiao));
  177. ST_DefaultServerConfig = JSON.stringify(configObj.toutiao);
  178. }
  179. }
  180. this._service_uid = YZ_LocalStorage.getItem(YZ_Constant.ST_SERVICE_UID);
  181. this._service_uid = this._service_uid ? this._service_uid : "0";
  182. this._sysInfo = this.tt.getSystemInfoSync();
  183. utils.showLog("抖音平台信息:" + JSON.stringify(this._sysInfo));
  184. if (this._sysInfo && this._sysInfo.appName && this._sysInfo.appName == "news_article_lite") {
  185. this.isNewsArticleLite = true;
  186. }
  187. // // 拉取服务器配置
  188. // this.loadJumpIds().then(() => {
  189. // console.log("本地跳转ID加载成功!");
  190. // this._loadConfig();
  191. // }).catch((erro) => {
  192. // console.error("本地跳转ID加载失败:", erro);
  193. this._loadConfig();
  194. // })
  195. let self = this;
  196. this._recorder = this.tt.getGameRecorderManager();
  197. if (this._recorder) {
  198. this._recorder.onStart((res) => {
  199. self._videoPath = "";
  200. this.isClickEnd = false;
  201. this.is_auto_share_video = false;
  202. utils.isRecording = true;
  203. console.log("录屏开始>>>");
  204. utils.showLog('录屏开始');
  205. this.recorderStarTime = new Date().getTime();
  206. cc.game.emit("YZ_CommonMessage", { type: "YZ_RecordStart" });
  207. });
  208. this._recorder.onStop((res) => {
  209. utils.showLog("录屏结束 :" + res.videoPath);
  210. utils.isRecording = false;
  211. cc.game.emit("YZ_CommonMessage", { type: "YZ_RecordEnd" });
  212. let curTime: number = new Date().getTime();
  213. let interval: number = (curTime - this.recorderStarTime) / 1000;
  214. if (interval > 3) {
  215. self._videoPath = res.videoPath;
  216. utils.showLog("录屏时间大于3秒", interval);
  217. if (this.isAutoShare) {
  218. if (this.isClickEnd) {
  219. this.shareVideo();
  220. this._shareCallback = null;
  221. this.is_auto_share_video = true;
  222. } else if (utils.checkResultShow(1)) {
  223. utils.showLog("满足自动分享条件,弹出分享窗口!");
  224. if (utils.rewardCloseFunc == null) {
  225. utils.rewardValue = 0;
  226. utils.showShareRecordPanel();
  227. }
  228. } else if (interval > 100) {
  229. if (utils.rewardCloseFunc == null) {
  230. utils.rewardValue = 0;
  231. utils.showShareRecordPanel();
  232. }
  233. }
  234. } else {
  235. this.isAutoShare = true;
  236. }
  237. } else {
  238. //@ts-ignore
  239. if (this.isClickEnd) {
  240. this.tt.showToast({
  241. title: "录屏时间小于3秒!",
  242. icon: "fail",
  243. duration: 2000,
  244. success(res) {
  245. console.log(`${res}`);
  246. },
  247. fail(res) {
  248. console.log(`showToast调用失败`);
  249. }
  250. });
  251. }
  252. self._videoPath = "";
  253. utils.showLog("录屏时间小于3秒,录录屏地址置空!");
  254. }
  255. });
  256. }
  257. // 开启右上角分享按钮
  258. //@ts-ignore
  259. this.tt.showShareMenu({
  260. withShareTicket: false
  261. });
  262. //@ts-ignore
  263. this.tt.onShareAppMessage((res) => {
  264. return self._getShareInfo();
  265. });
  266. utils.registerServerInitEvent(() => {
  267. if (this.ServerConfig.add_favorite) {
  268. setTimeout(() => {
  269. utils.showLog("延迟调用添加搜藏!!");
  270. this.showFavoriteGuide();
  271. }, this.ServerConfig.add_favorite * 1000);
  272. }
  273. }, this);
  274. }
  275. }
  276. /**
  277. * 添加搜藏
  278. */
  279. showFavoriteGuide() {
  280. if (this.tt.showFavoriteGuide) {
  281. this.tt.showFavoriteGuide({
  282. type: "bar",
  283. content: "一键添加到我的小程序",
  284. position: this.ServerConfig.favorite_type ? this.ServerConfig.favorite_type : "bottom",
  285. success(res: any) {
  286. utils.showLog("引导组件展示成功");
  287. },
  288. fail(res: any) {
  289. utils.showLog("引导组件展示失败:ero=" + JSON.stringify(res));
  290. },
  291. });
  292. } else {
  293. utils.showLog("当前头条版本不支持添加收藏!");
  294. }
  295. }
  296. loadJumpIds() {
  297. return new Promise((resolve, reject) => {
  298. cc.loader.load("game.json", (err, res) => {
  299. if (!err) {
  300. res.ttNavigateToMiniGameAppIdList.forEach(element => {
  301. this._jumpIds += element + ",";
  302. });
  303. this._jumpIds.substring(0, this._jumpIds.lastIndexOf(","));
  304. //@ts-ignore
  305. resolve();
  306. }
  307. reject(err);
  308. });
  309. });
  310. }
  311. _loadConfig() {
  312. if (PlatUtils.IsDouyin) {
  313. let method: string = "m=g";
  314. utils.commomHttpRequest(ST_ServerUrl + method + `&jump_id=${this._jumpIds}`, (ret, data) => {
  315. if (ret && data) {
  316. utils.showLog("抖音服务器配置数据获取成功: data = " + data);
  317. let result = JSON.parse(data);
  318. if (!utils.DebugLoacalConfig) {
  319. this._serverConfig = result;
  320. } else {
  321. utils.showLog("调试模式,使用本地配置!");
  322. }
  323. } else {
  324. utils.showLog("抖音服务器配置数据获取失败, 使用本地配置!");
  325. }
  326. if (!this.ServerConfig) {
  327. this._serverConfig = JSON.parse(ST_DefaultServerConfig);
  328. } else {
  329. if (this.ServerConfig.is_local_pos_id == "false") {
  330. utils.showLog("使用服务器下发的广告ID");
  331. utils.config.douyinconfig.bannerId = this.ServerConfig.banner_pos_id;
  332. utils.config.douyinconfig.insertId = this.ServerConfig.intersititia_pos_id;
  333. utils.config.douyinconfig.videoId = this.ServerConfig.video_pos_id;
  334. }
  335. if (this._serverConfig.shares && this._serverConfig.shares.sy_title) {
  336. utils.config.otherconfig.shareTitle = this._serverConfig.shares.sy_title;
  337. }
  338. if (this._serverConfig.shares && this._serverConfig.shares.sy_img) {
  339. utils.config.otherconfig.shareImgUrl = this._serverConfig.shares.sy_img;
  340. }
  341. }
  342. utils.emitServerInitEvent();
  343. });
  344. }
  345. }
  346. /**
  347. * 开始录屏
  348. */
  349. public recordStart() {
  350. if (PlatUtils.IsDouyin) {
  351. if (this._recorder) {
  352. this._recorder.start({
  353. duration: this.ServerConfig.record_duration ? this.ServerConfig.record_duration : 120
  354. });
  355. }
  356. }
  357. }
  358. /**
  359. * 结束录屏
  360. */
  361. public recordEnd() {
  362. if (PlatUtils.IsDouyin) {
  363. this._recorder.stop();
  364. }
  365. }
  366. /**
  367. * 分享,有录屏就分享录屏,没有录屏就分享图片
  368. */
  369. public share(callback?: Function) {
  370. if (PlatUtils.IsDouyin) {
  371. this._shareCallback = callback;
  372. if (this._videoPath && !utils.isRecording) {
  373. this.shareVideo();
  374. } else {
  375. this.shareImage();
  376. }
  377. }
  378. }
  379. /**
  380. * 分享录屏
  381. */
  382. public shareVideo() {
  383. if (PlatUtils.IsDouyin) {
  384. if (this._videoPath) {
  385. let self = this;
  386. //@ts-ignore
  387. this.tt.shareAppMessage({
  388. channel: 'video',
  389. extra: {
  390. videoPath: self._videoPath // 可用录屏得到的视频地址
  391. },
  392. success() {
  393. cc.log('视频分享成功!');
  394. if (self._shareCallback) {
  395. self._shareCallback(true);
  396. }
  397. },
  398. fail(e) {
  399. cc.log('视频分享失败!', JSON.stringify(e));
  400. self._videoPath = "";
  401. let msg: string = "分享失败!";
  402. if (e && e.errMsg) {
  403. msg = e.errMsg;
  404. if (msg.indexOf("fail") != -1) {
  405. console.log(self._sysInfo);
  406. if (self._sysInfo.appName == "XiGua") {
  407. msg = "分享失败!";
  408. } else {
  409. // 视频太短
  410. msg = "分享失败,录屏时间太短!";
  411. }
  412. } else {
  413. msg = "分享失败!";
  414. }
  415. }
  416. if (self._shareCallback) {
  417. self._shareCallback(false, msg);
  418. }
  419. if (self.is_auto_share_video) {
  420. self.is_auto_share_video = false;
  421. self.tt.showToast({
  422. title: msg,
  423. icon: "fail",
  424. duration: 2000,
  425. success(res) {
  426. console.log(`${res}`);
  427. },
  428. fail(res) {
  429. console.log(`showToast调用失败`);
  430. }
  431. });
  432. }
  433. }
  434. });
  435. }
  436. }
  437. }
  438. /**
  439. * 分享图片
  440. */
  441. public shareImage() {
  442. if (PlatUtils.IsDouyin) {
  443. let shareInfo = utils.getShareInfo();
  444. utils.showLog(`分享图片:title:${shareInfo.title}; imageUrl:${shareInfo.imageUrl}`);
  445. if (shareInfo) {
  446. let self = this;
  447. //@ts-ignore
  448. this.tt.shareAppMessage({
  449. title: shareInfo.title,
  450. imageUrl: shareInfo.imageUrl,
  451. success() {
  452. utils.showLog('图片分享成功!');
  453. if (self._shareCallback) {
  454. self._shareCallback(true);
  455. }
  456. },
  457. fail(e) {
  458. utils.showLog('图片分享失败!' + JSON.stringify(e));
  459. if (self._shareCallback) {
  460. self._shareCallback(false);
  461. }
  462. }
  463. });
  464. }
  465. }
  466. }
  467. /**
  468. * 显示更多游戏按钮
  469. */
  470. public showMoreGamesButton(params: any) {
  471. if (PlatUtils.IsDouyin) {
  472. let left: number = 0;
  473. let top: number = 0;
  474. let width: number = 0;
  475. let height: number = 0;
  476. if (cc.view.getDesignResolutionSize().width < 1080) {
  477. width = 188 / 1080 * this._sysInfo.screenWidth;
  478. height = 223 / 1080 * this._sysInfo.screenWidth;
  479. } else {
  480. width = 188 / cc.view.getDesignResolutionSize().width * this._sysInfo.screenWidth;
  481. height = 223 / cc.view.getDesignResolutionSize().width * this._sysInfo.screenWidth;
  482. }
  483. if (params) {
  484. if (params.left) {
  485. left = params.left / cc.view.getDesignResolutionSize().width * this._sysInfo.screenWidth;
  486. } else if (params.right) {
  487. left = this._sysInfo.screenWidth - params.right / cc.view.getDesignResolutionSize().width * this._sysInfo.screenWidth - width;
  488. }
  489. if (params.top) {
  490. top = params.top / cc.view.getDesignResolutionSize().height * this._sysInfo.screenHeight;
  491. } else if (params.bottom) {
  492. top = this._sysInfo.screenHeight - params.bottom / cc.view.getDesignResolutionSize().height * this._sysInfo.screenHeight - height;
  493. }
  494. }
  495. utils.showLog(`更多游戏按钮参数:left:${left}; top:${top}; width:${width}; height:${height}`);
  496. //@ts-ignore
  497. return this.tt.createMoreGamesButton({
  498. type: "image",
  499. image: "img/more_game.png",
  500. style: {
  501. left: left,
  502. top: top,
  503. width: width,
  504. height: height,
  505. lineHeight: 40,
  506. backgroundColor: "#ff0000",
  507. textColor: "#ffffff",
  508. textAlign: "center",
  509. fontSize: 16,
  510. borderRadius: 4,
  511. borderWidth: 0,
  512. borderColor: '#ff0000'
  513. },
  514. appLaunchOptions: [
  515. ],
  516. onNavigateToMiniGame(res) {
  517. utils.showLog('跳转其他小游戏' + res)
  518. if (res && res.errCode == 0) {
  519. // 跳转成功
  520. }
  521. }
  522. });
  523. }
  524. }
  525. _getShareInfo() {
  526. if (PlatUtils.IsDouyin) {
  527. let shareInfo = utils.getShareInfo();
  528. if (shareInfo) {
  529. return {
  530. title: shareInfo.title,
  531. imageUrl: shareInfo.imageUrl,
  532. success: function (res) {
  533. utils.showLog("分享成功!");
  534. },
  535. fail: function (err) {
  536. utils.showLog("分享失败!");
  537. }
  538. }
  539. }
  540. }
  541. return {};
  542. }
  543. /**
  544. * 比较当前平台版本是否高于指定的版本号
  545. * @param miniVersion 最低平台版本号
  546. */
  547. public isOverMiniVersion(miniVersion: string) {
  548. if (PlatUtils.IsDouyin) {
  549. if (this._sysInfo && miniVersion != null) {
  550. return this._compareVersion(this._sysInfo.SDKVersion, miniVersion);
  551. }
  552. }
  553. return false;
  554. }
  555. _compareVersion(first: string, second: string) {
  556. return parseInt(first.split(".").join("")) >= parseInt(second.split(".").join(""));
  557. }
  558. /**
  559. * 判断是否支持显示更多游戏弹窗
  560. */
  561. isShowMoreGamesModal() {
  562. if (PlatUtils.IsAndroid && this.tt.showMoreGamesModal) {
  563. return true;
  564. }
  565. utils.showLog("当前版本不支持显示抖音更多游戏弹窗!");
  566. return false;
  567. }
  568. /**
  569. * 持显示更多游戏弹窗
  570. */
  571. showMoreGamesModal() {
  572. if (PlatUtils.IsAndroid) {
  573. this.tt.showMoreGamesModal({
  574. appLaunchOptions: [],
  575. success(res) {
  576. console.log("success", res.errMsg);
  577. },
  578. fail(res) {
  579. console.log("fail", res.errMsg);
  580. }
  581. });
  582. } else {
  583. utils.showMsg("当前平台暂时不支持跳转");
  584. }
  585. }
  586. /**
  587. * 获取交叉推广数据
  588. */
  589. public getRecommondGameList() {
  590. if (PlatUtils.IsDouyin
  591. && this.ServerConfig) {
  592. return this.ServerConfig.jump_list;
  593. }
  594. return null;
  595. }
  596. /**
  597. * 上报关卡数据
  598. * @param level 当前关卡ID
  599. * @param levelName 关卡名称
  600. * @param status 状态
  601. */
  602. public postLevel(level: string, status: LevelStatus, levelName?: string) {
  603. if (PlatUtils.IsDouyin) {
  604. let method = "m=rlevel";
  605. let url: string = POST_ServerUrl + method + `&level_id=${level}&level_name=${encodeURI(levelName)}&status=${status}`;
  606. utils.commomHttpRequest(url, function (ret, data) {
  607. if (ret) {
  608. utils.showLog("关卡数据上报成功!");
  609. } else {
  610. utils.showLog("关卡数据上报失败!");
  611. }
  612. }.bind(this));
  613. }
  614. }
  615. /**
  616. * 上报自定义事件
  617. * @param level 当前关卡ID
  618. * @param levelName 关卡名称
  619. * @param status 状态
  620. */
  621. public sendEvent(eventName: string) {
  622. if (PlatUtils.IsDouyin) {
  623. let method = "m=revent";
  624. let url: string = POST_ServerUrl + method + `&event=${encodeURI(eventName)}`;
  625. utils.commomHttpRequest(url, function (ret, data) {
  626. if (ret) {
  627. utils.showLog("上报自定义事件成功!");
  628. } else {
  629. utils.showLog("上报自定义事件失败!");
  630. }
  631. }.bind(this));
  632. }
  633. }
  634. /**
  635. * 弹出提示框
  636. * @param msg 消息
  637. */
  638. public showToast(msg: string) {
  639. if (PlatUtils.IsDouyin) {
  640. //@ts-ignore
  641. tt.showToast({
  642. title: msg,
  643. icon: "none",
  644. duration: 2000,
  645. success(res) {
  646. console.log(`${res}`);
  647. },
  648. fail(res) {
  649. console.log(`showToast调用失败`);
  650. }
  651. });
  652. }
  653. }
  654. public GameExit() {
  655. //@ts-ignore
  656. tt.exitMiniProgram({
  657. success(res) {
  658. console.log("调用成功", res.data);
  659. },
  660. fail(res) {
  661. console.log("调用失败", res.errMsg);
  662. },
  663. });
  664. }
  665. }