Explorar el Código

修改分享回调

smallqiang hace 5 años
padre
commit
76f5a571d3
Se han modificado 2 ficheros con 15 adiciones y 3 borrados
  1. 1 1
      assets/scripts/common/Platform.js
  2. 14 2
      assets/scripts/net/WeChat.js

+ 1 - 1
assets/scripts/common/Platform.js

@@ -381,8 +381,8 @@ class Platform {
             /// 发通知更新跟定时器相关的数据
             GameEvent.fire(GameNotificationKey.GameShowNotificationKey);
 
+            console.log('plat onshow ======= ' + GameGlobal.clickShare);
             if (GameGlobal.clickShare) {
-
                 let onHideTime = cc.sys.localStorage.getItem('onHideTimestamp');
 
                 let curTime = new Date().getTime();

+ 14 - 2
assets/scripts/net/WeChat.js

@@ -1,7 +1,8 @@
 const LoginApi = require('./LoginApi');
 const ShareAction = require('../utils/ShareAction');
 const AlertManager = require('../utils/AlertManager');
-// const SkillApi = require("../net/SkillApi");
+const {GameNotificationKey, WechatShareType } = require('../utils/GameEnum');
+const SkillApi = require("../net/SkillApi");
 
 class WeChat {
 
@@ -195,7 +196,7 @@ class WeChat {
     }
 
     shareAction(type, success, fail) {
-        if (CC_WECHATGAME) {
+        if (CC_WECHATGAME || window.tt != undefined) {
             GameGlobal.isIgnoreShareStatus = false;
             GameGlobal.clickShare = true;
             GameGlobal.gameShareType = type;
@@ -211,6 +212,17 @@ class WeChat {
                 success: (res) => {
                     console.log('分享成功');
                     success && success();
+                    if (GameGlobal.clickShare) {
+                        GameEvent.fire(GameNotificationKey.ShowShareAction, GameGlobal.gameShareType, true);
+                        GameGlobal.clickShare = false;
+                        GameGlobal.gameShareType = WechatShareType.None;
+                        GameGlobal.isIgnoreShareStatus = false;
+                        SkillApi.report(2, (responseData) => {
+
+                        },(error) => {
+
+                        });
+                    }
                 },
                 fail: () => {
                     console.log('分享失败或取消');