SDKUtils.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /** @format */
  2. import {Data, Mgr} from '../GameControl'
  3. import {EVENT, LANGUAGE_TYPE} from '../enums/Enum'
  4. import {msgCmd} from '../proto/msg_cmd'
  5. import {rechargeResult} from '../proto/game'
  6. window['SDKUtils'] = {
  7. adSuccessCB: Function,
  8. adFailCB: Function,
  9. onConfigurationChanged() {
  10. Mgr.platform.getSafeTop()
  11. Mgr.event.trigger(EVENT.screenChange)
  12. },
  13. onFaceBookLoginSuccess(data) {
  14. Mgr.event.trigger(EVENT.facebookLoginSuccess, data)
  15. },
  16. facebookLoginFail(data) {
  17. Mgr.event.trigger(EVENT.facebookLoginFail, data)
  18. },
  19. onGoogleLoginSuccess(data) {
  20. Mgr.event.trigger(EVENT.googleLoginSuccess, data)
  21. },
  22. googleLoginFail(data) {
  23. Mgr.event.trigger(EVENT.googleLoginFail, data)
  24. },
  25. payFail() {
  26. Mgr.ui.hideLoading()
  27. Mgr.ui.tip(LANGUAGE_TYPE.payFailed)
  28. },
  29. payCancel() {
  30. Mgr.ui.hideLoading()
  31. Mgr.ui.tip(LANGUAGE_TYPE.payCancel)
  32. },
  33. googlePaySuccess(data) {
  34. //等待断线重连
  35. Mgr.ui.hideLoading()
  36. data.payType = 1
  37. if (Mgr.net.webSocket.readyState == WebSocket.OPEN) {
  38. Mgr.net.send(msgCmd.cmd_recharge_result, data)
  39. } else {
  40. Data.main.payData.push(data)
  41. }
  42. },
  43. showADSuccess() {
  44. this.adSuccessCB && this.adSuccessCB()
  45. },
  46. showADFail(errCode) {
  47. this.adFailCB && this.adFailCB(errCode)
  48. },
  49. }