{
  "code": "export class ShareUtil {\r\n    constructor() {\r\n    }\r\n    ShareUtil() {\r\n    }\r\n    beginShare(callBack) {\r\n        ShareUtil.beginShareTime = new Date().getTime();\r\n        console.log(\"分享点击时间=\" + ShareUtil.beginShareTime);\r\n        ShareUtil.isSharing = true;\r\n        ShareUtil.callback = callBack;\r\n    }\r\n    onRegister() {\r\n        if (Laya.Browser.window.wx == null) {\r\n            return;\r\n        }\r\n        Laya.Browser.window.wx.onShow(function (option) {\r\n            console.log(\"onshow share start\");\r\n            if (ShareUtil.isSharing) {\r\n                ShareUtil.isSharing = false;\r\n                let time = new Date().getTime();\r\n                console.log(\"分享回到游戏时间\" + time);\r\n                let wait = (time - ShareUtil.beginShareTime) / 1000;\r\n                console.log(\"分享停留时间为：\" + wait);\r\n                let shareSuccess = false;\r\n                let realSuccess = false;\r\n                if (wait >= 2) {\r\n                    if (wait < 4) {\r\n                        shareSuccess = (Math.random() > 0.7) ? false : true;\r\n                    }\r\n                    else {\r\n                        shareSuccess = true;\r\n                    }\r\n                }\r\n                else {\r\n                    shareSuccess = false;\r\n                }\r\n                if (shareSuccess == false) {\r\n                    Laya.Browser.window.wx.showToast({ title: \"请重试一次\" });\r\n                    ShareUtil.callback(false);\r\n                }\r\n                else {\r\n                    Laya.Browser.window.wx.showToast({ title: \"分享成功\" });\r\n                    ShareUtil.callback(true);\r\n                }\r\n            }\r\n        });\r\n    }\r\n}\r\nShareUtil.Instance = new ShareUtil();\r\nShareUtil.shareSuccessTime = 0;\r\nShareUtil.isSharing = false;\r\n",
  "references": []
}
